From Br Wiki
Jump to: navigation, search

The LTrm$ internal function deletes leading blanks from the variable. So named, because it left-trims the blanks from the string.

Comments and Examples

When an operator enters a character string which will be used as a key field (such as last name), any spaces on the front part of the name will probably cause the string entered to not match anything in the key file. To minimize these errors, the program can remove any leading spaces with the LTRM$ function. However, when LTRM$ successfully removes one or two spaces from the beginning of the string, this causes another problem because now the string is one or two characters shorter; this second problem can be solved by adding spaces on the right with the RPAD$ function. Combining these two functions as in line 430 below is a common data clean-up technique.

An optional second parameter ("char") has been added to LTRM$ and RTRM$ to specify the character to strip (instead of blanks, which are still the default). The "char" parameter is limited to one character in length (error 0410 will result if it is longer). Nulls and CHR$(0) are allowed. The following statement would return the value 12:

00410 PRINT FIELDS "10,30,C 20: "Enter LAST NAME"
00420 INPUT FIELDS "12,30,C 10,R": LNAME$
00430 LET LNAME$ = RPAD$(LTRM$(LNAME$),10)

Related Functions

See RTRM$ to trim blanks from the right and LPAD$ and RPAD$ to add blanks.