LSET: 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 "LSET left-justifies a fixed length string expression based on the size of the STRING variable and string expression. {{PageSyntax}} : LSET {stringVariable = stringExpression | stringExpression1 = stringExpression2} {{PageDescription}} * 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 LSET string expression is smaller, spaces will occupy the extra positions to t...") |
No edit summary |
||
Line 8: | Line 8: | ||
{{PageDescription}} | {{PageDescription}} | ||
* 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 LSET string expression is smaller, spaces will occupy the extra positions to the right in the string. | * If the LSET string expression is smaller, spaces will occupy the extra positions to the right in the string. | ||
* LSET can be used with a [[FIELD]] or [[TYPE]] definition to set the buffer position before a [[PUT]]. | * LSET can be used with a [[FIELD]] or [[TYPE]] definition to set the buffer position before a [[PUT]]. | ||
Line 15: | Line 15: | ||
''Example 1:'' Using LSET with a [[FIELD]] definition. Note: May create an empty (unchanged) file that can be deleted. | ''Example 1:'' Using LSET with a [[FIELD]] definition. Note: May create an empty (unchanged) file that can be deleted. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|OPEN}} "testfile.dat" FOR {{Cl|RANDOM}} AS #1 {{Cl|LEN}} = 15 | {{Cl|OPEN}} "testfile.dat" FOR {{Cl|RANDOM}} AS #1 {{Cl|LEN}} = 15 | ||
{{Cl|FIELD}} 1, 6 {{Cl|AS}} a$, 9 {{Cl|AS}} other$ | {{Cl|FIELD}} 1, 6 {{Cl|AS}} a$, 9 {{Cl|AS}} other$ | ||
Line 26: | Line 25: | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{OutputStart}} | {{OutputStart}} | ||
123456 12 123456789 3456123456789 | 123456 12 123456789 3456123456789 | ||
{{OutputEnd}} | {{OutputEnd}} | ||
Latest revision as of 02:00, 23 January 2023
LSET left-justifies a fixed length string expression based on the size of the STRING variable and string expression.
Syntax
- LSET {stringVariable = stringExpression | stringExpression1 = stringExpression2}
Description
- 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 LSET string expression is smaller, spaces will occupy the extra positions to the right in the string.
- LSET can be used with a FIELD or TYPE definition to set the buffer position before a PUT.
Examples
Example 1: Using LSET with a FIELD definition. Note: May create an empty (unchanged) file that can be deleted.
OPEN "testfile.dat" FOR RANDOM AS #1 LEN = 15 FIELD 1, 6 AS a$, 9 AS other$ FIELD 1, 2 AS b$, 13 AS another$ LSET a$ = "1234567890" LSET other$ = "1234567890" PRINT a$, b$, other$, another$ CLOSE #1 |
123456 12 123456789 3456123456789 |
Example 2: How LSET can define two different string length values in one statement.
TYPE ninestring head AS STRING * 9 END TYPE TYPE fivestring head AS STRING * 5 END TYPE DIM me AS ninestring, you AS fivestring me.head = "ACHES NOT" CLS LSET you.head = me.head PRINT "me.head: "; me.head PRINT "you.head: "; you.head |
me.head: ACHES NOT you.head: ACHES |
See also