1. Moves a string expression, left justified, to a string.
2. Moves the contents of one type variable to another.
Lset a$ = b$
Lset t1 = t2
a$ | : svar, b$: sexp |
t1, t2 | : typevars |
Lset a$=b$ will, first of all, replace all characters in a$ with spaces. Next, b$ is moved into a$ left justified. If b$ contains more characters than a$, then only as many characters as there are "places" for in a$ are moved.
Similar to VB Lset also moves the contents of one type variable to another.
Lset with strings.
OpenW # 1
Local a$ = String$(15, "-")
Local b$ = "Hello GFA"
Print a$, Len(a$) // prints --------------- 15
Print b$, Len(b$) // prints HelloGFA 9
Lset a$ = b$
Print a$, Len(a$) // prints Hello GFA 15
Lset with a user defined type.
Type a : - Long a : End Type
Type b : - Single b : End Type
Local a As a, b As b
b.b = 1.0
Print LPeek(V:b.b), Hex(LPeek(V:b.b), 16)
Lset a = b
Print a.a, Hex(a.a, 16)
All bytes of the Type variable b are copied into the Type variable a.
Lset for types is similar to a = b, but also works with different Type’s. An alternative would be to copy the contents using a memory copy instruction like MemCpy or Bmove. For instance:
MemCpy(V:a, V:b, Min(Len(a), Len(b)))
There exists no implemented command to copy a String variable and a Type variable together (Lset itself works only with String or only with Type’s, not in mixed case). Nevertheless, it’s very simple to copy a Type variable to a string:
Local t As User_defined_Type
Local a$
a$ = Peek$(V:t, SizeOf(t))
or, when a$ has the correct length:
BMove V:t, V:a$, Len(a$)
To move the string contents back to a type variable use Poke$:
Poke$ V:t, SizeOf(t)
{Created by Sjouke Hamstra; Last updated: 16/10/2017 by James Gaite}