LTrm$: Difference between revisions
m (1 revision) |
No edit summary |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
The [[LTrm$]] [[internal function]] deletes leading blanks from variable | LTRM$(<string>,"<chr>") | ||
The [[LTrm$]] [[internal function]] deletes leading blanks from the variable. So named, because it ''left-trims'' the blanks from the string. | |||
====Comments and Examples==== | ====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. | 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. | ||
Line 12: | Line 15: | ||
====Related Functions==== | ====Related Functions==== | ||
See [[RTRM$]] to trim blanks from the right and [[LPAD$]] | |||
See [[RTRM$]] to trim blanks from the right and [[LPAD$]] and [[RPAD$]] to add blanks. | |||
<noinclude> | <noinclude> | ||
[[Category:Internal Functions]] | [[Category:Internal Functions]] | ||
</noinclude> | </noinclude> |
Latest revision as of 20:33, 12 May 2016
LTRM$(<string>,"<chr>")
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) 00440 READ #2,USING 450,KEY=LNAME$: ADDRESS$,CITY$,ST$
Related Functions
See RTRM$ to trim blanks from the right and LPAD$ and RPAD$ to add blanks.