1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00
QB64-PE/internal/help/LSET.txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

64 lines
1.7 KiB
Plaintext

[[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 the right in the string.
* LSET can be used with a [[FIELD]] or [[TYPE]] definition to set the buffer position before a [[PUT]].
{{PageExamples}}
''Example 1:'' Using LSET with a [[FIELD]] definition. Note: May create an empty (unchanged) file that can be deleted.
{{CodeStart}}
'' ''
{{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, 2 {{Cl|AS}} b$, 13 {{Cl|AS}} another$
{{Cl|LSET}} a$ = "1234567890"
{{Cl|LSET}} other$ = "1234567890"
{{Cl|PRINT}} a$, b$, other$, another$
{{Cl|CLOSE}} #1
{{CodeEnd}}
{{OutputStart}}
123456 12 123456789 3456123456789
{{OutputEnd}}
''Example 2:'' How LSET can define two different string length values in one statement.
{{CodeStart}}
{{Cl|TYPE}} ninestring
head {{Cl|AS}} {{Cl|STRING}} * 9
{{Cl|END TYPE}}
{{Cl|TYPE}} fivestring
head AS {{Cl|STRING}} * 5
{{Cl|END TYPE}}
{{Cl|DIM}} me {{Cl|AS}} ninestring, you {{Cl|AS}} fivestring
me.head = "ACHES NOT"
{{Cl|CLS}}
{{Cl|LSET}} you.head = me.head
{{Cl|PRINT}} "me.head: "; me.head
{{Cl|PRINT}} "you.head: "; you.head
{{CodeEnd}}
{{OutputStart}}
me.head: ACHES NOT
you.head: ACHES
{{OutputEnd}}
{{PageSeeAlso}}
* [[RSET]], [[RTRIM$]]
* [[FIELD]], [[TYPE]]
{{PageNavigation}}
<