LSET - QB64 Wiki

LSET

From QB64 Wiki

Revision as of 23:12, 9 May 2011 by Clippy (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

LSET left-justifies a fixed length string expression based on the size of the STRING variable and string expression.


Syntax:

LSET {string_variable = string_expression | string_expression1 = string_expression2}


  • 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.


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:



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page