%TRIM removes leading and trailing characters from a string. The format of the %TRIM utility function is:

$$FUNC|$$L|$$R^%TRIM(expr1[,expr2])

You can also use %TRIM as a command line utility routine to read from STDIN and write to STDOUT in the following format:

echo "  string with leading and trailing spaces  " | $gtm_dist/mumps -r ^%TRIM

Example:

GTM>set strToTrim=$char(9,32)_"string with spaces and tabs"_$char(32,32,32) write $length(strToTrim) 
32 
GTM>write "strToTrim=",?24,"""",strToTrim,"""",!,"$$L^%TRIM(strToTrim)=",?24,"""",$$L^%TRIM(strToTrim),"""",!,"$$R^%TRIM(strToTrim)=",?24,"""",$$R^%TRIM(strToTrim),"""",!,"$$FUNC^%TRIM(strToTrim)=",?24,"""",$$FUNC^%TRIM(strToTrim),""""
strToTrim=              "        string with spaces and tabs   "
$$L^%TRIM(strToTrim)=   "string with spaces and tabs   "
$$R^%TRIM(strToTrim)=   "        string with spaces and tabs"
$$FUNC^%TRIM(strToTrim)="string with spaces and tabs"

This example invokes %TRIM as an extrinsic function and demonstrates the use of its $$L,$$R, and $$FUNC labels.

Example:

$ echo " GT.M Rocks! " | $gtm_dist/mumps -r ^%TRIM
GT.M Rocks!
$

This example invokes %TRIM as a command line utility which reads STDIN and writes the trimmed output to STDOUT.

loading table of contents...