basic.trim Function/BASIC Program

basic.trim

Command basic.trim Function/BASIC Program
Applicable release versions: AP 6.2, R83, R91
Category BASIC Program (486)
Description removes leading, trailing, and/or redundant characters from a string.

If only one parameter is specified, then "trim" removes all leading and trailing blanks from a string expression, and compresses multiple embedded blanks to one embedded blank.

If the "trimchar" character is specified (only available on 6.2 and up), then that character substitutes for the space. If the "type" parameter is missing, then type R is assumed.

If the "type" parameter is specified (only available on 6.2 and up), then the trim behavior can be controlled more specifically. Available values are:

L trim leading
T trim trailing
B trim leading and trailing
A trim all
R trim redundant
Syntax trim(string.expression, {trimchar {,type } } )
Options
Example
string = trim("   cat   dog   bird   ")

After trimming, "string" contains : "cat dog bird". 

readt record else stop
name = trim(record[1,25])
address = trim(record[26,40])

In this case, the "trim" function is used to convert fixed length 
fields to variable length fields by removing trailing and leading blanks.

The following program:
line = '--a--b--c--'
print trim(line,'-')
print trim(line,'-','L')
print trim(line,'-','T')
print trim(line,'-','B')
print trim(line,'-','A')
print trim(line,'-','R')

Would produce the following output:
-a-b-c
a--b--c--
--a--b--c
a--b--c
abc
-a-b-c-
Purpose
Related basic.statements
basic.string.expression
basic.functions