summaryrefslogtreecommitdiff
path: root/source/text/sbasic/shared/03120308.xhp
blob: f999364e515ea0b7f8b3863cf5e99d812813bcde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->

<meta>
  <topic id="textsbasicshared03120308xml" indexer="include" status="PUBLISH">
    <title id="tit" xml-lang="en-US">RSet Statement</title>
    <filename>/text/sbasic/shared/03120308.xhp</filename>
  </topic>
</meta>

<body>


<section id="rset">
<bookmark xml-lang="en-US" branch="index" id="bm_id3153345">
  <bookmark_value>RSet statement</bookmark_value>
</bookmark>


<h1 id="hd_id3153345"><link href="text/sbasic/shared/03120308.xhp">RSet Statement</link></h1>
<paragraph id="par_id3150503" role="paragraph" xml-lang="en-US">Right-aligns a string within a string variable, or copies a user-defined variable type into another.</paragraph>
</section>

<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
<bascode>
<paragraph id="par_id3150669" role="bascode" xml-lang="en-US">RSet Text As String = Text or RSet Variable1 = Variable2</paragraph>
</bascode>

<embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
<paragraph id="par_id3148552" role="paragraph" xml-lang="en-US"> <emph>Text:</emph> Any string variable.</paragraph>
<paragraph id="par_id3154924" role="paragraph" xml-lang="en-US"> <emph>Text</emph>: String that you want to right-align in the string variable.</paragraph>
<paragraph id="par_id3149456" role="paragraph" xml-lang="en-US"> <emph>Variable1:</emph> User-defined variable that is the target for the copied variable.</paragraph>
<paragraph id="par_id3153381" role="paragraph" xml-lang="en-US"> <emph>Variable2:</emph> User-defined variable that you want to copy to another variable.</paragraph>
<paragraph id="par_id3154140" role="paragraph" xml-lang="en-US">If the string is shorter than the string variable, <emph>RSet</emph> aligns the string to the right within the string variable. Any remaining characters in the string variable are replaced with spaces. If the string is longer than the string variable, characters exceeding the length of the variable are truncated, and only the remaining characters are right-aligned within the string variable.</paragraph>
<paragraph id="par_id3149202" role="paragraph" xml-lang="en-US">You can also use the <emph>RSet statement</emph> to assign variables of one user-defined type to another.</paragraph>
<paragraph id="par_id3151042" role="paragraph" xml-lang="en-US">The following example uses the <emph>RSet</emph> and <emph>LSet</emph> statements to modify the left and right alignment of a string.</paragraph>

<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
<bascode>
<paragraph id="par_idm1341567472" role="bascode" localize="false" xml-lang="en-US">Sub ExampleRLSet</paragraph>
<paragraph id="par_idm1341566240" role="bascode" localize="false" xml-lang="en-US">Dim sVar As String</paragraph>
<paragraph id="par_idm1341565008" role="bascode" localize="false" xml-lang="en-US">Dim sExpr As String</paragraph>
<paragraph id="par_idm1341563776" role="bascode" localize="false" xml-lang="en-US">    sVar = String(40,"*")</paragraph>
<paragraph id="par_idm1341562528" role="bascode" localize="false" xml-lang="en-US">    sExpr = "SBX"</paragraph>
<paragraph id="par_id3155856" role="bascode" xml-lang="en-US">    ' Right-align "SBX" in a 40-character string</paragraph>
<paragraph id="par_id3152577" role="bascode" xml-lang="en-US">    ' Replace asterisks with spaces</paragraph>
<paragraph id="par_idm1341557824" role="bascode" localize="false" xml-lang="en-US">    RSet sVar = sExpr</paragraph>
<paragraph id="par_idm1341556592" role="bascode" localize="false" xml-lang="en-US">    Print "&gt;"; sVar; "&lt;"</paragraph>
<paragraph id="par_idm1341555344" role="bascode" localize="false" xml-lang="en-US">    sVar = String(5,"*")</paragraph>
<paragraph id="par_idm1341554096" role="bascode" localize="false" xml-lang="en-US">    sExpr = "123457896"</paragraph>
<paragraph id="par_idm1341552864" role="bascode" localize="false" xml-lang="en-US">    RSet sVar = sExpr</paragraph>
<paragraph id="par_idm1341551632" role="bascode" localize="false" xml-lang="en-US">    Print "&gt;"; sVar; "&lt;"</paragraph>
<paragraph id="par_idm1341550384" role="bascode" localize="false" xml-lang="en-US">    sVar = String(40,"*")</paragraph>
<paragraph id="par_idm1341549136" role="bascode" localize="false" xml-lang="en-US">    sExpr = "SBX"</paragraph>
<paragraph id="par_id3145801" role="bascode" xml-lang="en-US">    ' Left-align "SBX" in a 40-character string</paragraph>
<paragraph id="par_idm1341546160" role="bascode" localize="false" xml-lang="en-US">    LSet sVar = sExpr</paragraph>
<paragraph id="par_idm1341544928" role="bascode" localize="false" xml-lang="en-US">    Print "&gt;"; sVar; "&lt;"</paragraph>
<paragraph id="par_idm1341543680" role="bascode" localize="false" xml-lang="en-US">    sVar = String(5,"*")</paragraph>
<paragraph id="par_idm1341542432" role="bascode" localize="false" xml-lang="en-US">    sExpr = "123456789"</paragraph>
<paragraph id="par_idm1341541200" role="bascode" localize="false" xml-lang="en-US">    LSet sVar = sExpr</paragraph>
<paragraph id="par_idm1341539968" role="bascode" localize="false" xml-lang="en-US">    Print "&gt;"; sVar; "&lt;"</paragraph>
<paragraph id="par_idm1341538720" role="bascode" localize="false" xml-lang="en-US">End Sub</paragraph>
</bascode>
<section id="relatedtopics">
    <paragraph role="paragraph" id="par_id161599082457466" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#stringfunctions"/></paragraph>
</section>
</body>

</helpdocument>