LSET statement

Purpose

Left-align a string within the space of another string or User-Defined Type.

Syntax

LSET [ABS] result_var = string_expression [USING ustring_expression]

Remarks

LSET left-aligns a string into the space of another string or variable of a User-Defined Type.

ABS

If ABS is specified, or ustring_expression is null (empty), LSET leaves the padding positions unchanged from their original content, rather than replacing them with spaces.

USING

If string_expression is shorter then result_var, LSET left-justifies string_expression within result_var, and pads remaining character positions on the right side using the first character in ustring_expression or spaces if not specified or is null (empty).

If string_expression is longer than result_var, LSET truncates string_expression from the right until it fits in result_var.

LSET can be used to assign the content of a User-Defined Type to a User-Defined Type variable of a different class, or assign a dynamic string to a User-Defined Type.  For example:

LSET MyType = STRING$(LEN(MyType), 0)

LSET MyType = a$

RSET works similarly, but performs right-justification; CSET performs center-justification.

See also

 CSET, CSET$, GET, LET, LET (with Types), LSET$, PUT, RESET, RSET, RSET$, STRINSERT$, TYPE SET

Example

a$ = "SuperBASIC=SuperBASIC"

LSET ABS a$ = "PowerBASIC"

' result: "PowerBASIC=SuperBASIC"

 

LSET a$ = "PowerBASIC" USING "*"

' result: "PowerBASIC***********"