RSET: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
(Created page with "The '''RSET''' statement right-justifies a string according to length of the string expression. {{PageSyntax}} :: RSET string_variable = string_expression * If the ''string_expression'' is longer than a fixed length string variable the value is truncated from the right side in LSET or RSET. * If the ''string_expression'' is smaller than the fixed length, spaces will occupy the extra positions in the string. * RSET can be used with a FIELD or TYPE strin...") |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
The '''RSET''' statement right-justifies a string according to length of the string expression. | The '''RSET''' statement right-justifies a string according to length of the string expression. | ||
Line 8: | Line 8: | ||
* If the ''string_expression'' is longer than a fixed length string variable the value is truncated from the right side in [[LSET]] or RSET. | * If the ''string_expression'' is longer than a fixed length string variable the value is truncated from the right side in [[LSET]] or RSET. | ||
* If the ''string_expression'' is smaller than the fixed length, spaces will occupy the extra positions in the string. | * If the ''string_expression'' is smaller than the fixed length, spaces will occupy the extra positions in the string. | ||
* RSET can be used with a [[FIELD]] or [[TYPE]] string definition to set the buffer position before a [[PUT]]. | * RSET can be used with a [[FIELD]] or [[TYPE]] string definition to set the buffer position before a [[PUT]]. | ||
''Example:'' | ''Example:'' | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|CLS}} | {{Cl|CLS}} | ||
{{Cl|DIM}} thestring {{Cl|AS}} {{Cl|STRING}} * 10 | {{Cl|DIM}} thestring {{Cl|AS}} {{Cl|STRING}} * 10 | ||
Line 23: | Line 23: | ||
{{Cl|PRINT}} anystring$ | {{Cl|PRINT}} anystring$ | ||
{{Cl|RSET}} thestring = "Over ten characters long" | {{Cl|RSET}} thestring = "Over ten characters long" | ||
{{Cl|PRINT}} thestring | {{Cl|PRINT}} thestring | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{OutputStart}} | {{OutputStart}} | ||
Line 35: | Line 35: | ||
{{PageSeeAlso}} | |||
* [[RTRIM$]], [[FIELD]] | * [[RTRIM$]], [[FIELD]] | ||
* [[LSET]], [[LTRIM$]] | * [[LSET]], [[LTRIM$]] |
Latest revision as of 01:02, 29 January 2023
The RSET statement right-justifies a string according to length of the string expression.
Syntax
- RSET string_variable = string_expression
- If the string_expression is longer than a fixed length string variable the value is truncated from the right side in LSET or RSET.
- If the string_expression is smaller than the fixed length, spaces will occupy the extra positions in the string.
- RSET can be used with a FIELD or TYPE string definition to set the buffer position before a PUT.
Example:
CLS DIM thestring AS STRING * 10 PRINT "12345678901234567890" RSET thestring = "Hello!" PRINT thestring anystring$ = SPACE$(20) RSET anystring$ = "Hello again!" PRINT anystring$ RSET thestring = "Over ten characters long" PRINT thestring |
12345678901234567890 Hello! Hello Again! Over ten c |
- Explanation: Notice how "Hello!" ends at the tenth position because the length of thestring is 10. When we used SPACE$(20) the length of anystring$ became 20 so "Hello Again!" ended at the 20th position. That is right-justified. The last line "Over ten c" is truncated as it didn't fit into thestring's length of only 10 characters.
See also