Trim - trim leading and/or trailing characters

Return to Introduction  Previous page  Next page

$return = trim(string[,trimCharacter[,LEFT | RIGHT]])

Where:

$returnthe trimmed string.
stringtext to be trimmed.
trimCharacterthe leading and/or trailing character(s) to trim from string. If this parameter contains multiple characters all of the occurrences of these character will be trimmed. If trimCharacter is not specified, then it defaults to a space character. This parameter may be a variable containing the trim character or characters. Enclose trimCharacter in double quotation marks ("") if it contains spaces or commas.
LEFTtrim leading characters from string. If neither LEFT or RIGHT is specified, then both leading and trailing characters are trimmed.
RIGHTtrim trailing characters from string.        

 

 

The trim command trims leading and/or trailing characters from a variable.

Example

$return = trim($text)

$return = trim($text,0,left)

$return = trim($text," ", right)

$return = trim($text,"$ ")

 

Sample Script

' trim.txt

' Trim trailing zeros.

 

$text = "985.2000000"

$return = trim($text,"0",Right)

MsgBox($return)

exit

 

See Also:

 

Script Command Summary

Script Variables

Using the Scripting Language


TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.