trim-string
Purpose:
Trim a string.
Syntax:
trim-string <string> [ length [ define ] <new length> ] [ result [ define ] <result> ]
Description:
trim-string trims <string>, both on left and right. You can optionally get the length of the changed string by using "length" clause, in integer variable <new length>, which can be created with optional "define".
Without "result" clause, trimming is in place, i.e. if necessary the bytes within <string> are shifted to the left, and the result is <string>. With "result" clause, <result> points to trimmed value within <string>, i.e. there is no movement of memory - this is a faster trim, but the pointer to the result is no longer <string>.
Examples:
The variable
"str" will be
"some string" and
"new_len" will be 11:
char str[] = " some string ";
trim-string str length define new_len
With
"result" clause, the variable
"str" will be
"some string" and
"new_len" will be 11, and
"res" will point to (str+2):
char str[] = " some string ";
trim-string str length define new_len result define res
See also: