%TRIMZ
Return the length of a variable without trailing blanks
|
WTSupported in traditional Synergy on Windows
|
WNSupported in Synergy .NET on Windows
|
USupported on UNIX
|
VSupported on OpenVMS
|
length = %TRIMZ(variable)
or
xcall TRIMZ(variable, length)
Return value
length
%TRIMZ returns the length of variable minus the number of trailing blanks. If the variable is blank, %TRIMZ return a value of 0. If the variable is null, %TRIMZ also returns a value of 0. In other words, both of the following statements return a value of 0. (i)
%trimz(" ")
and
%trimz("")
Arguments
variable
A variable whose length will be returned. (a)
Discussion
%TRIMZ returns the length of a variable minus the number of trailing blanks.
The difference between %TRIM and %TRIMZ is that with blank strings, %TRIM returns a value of one, and %TRIMZ returns a value of zero.
Examples
The following subroutine displays a prompt, gets the input, and returns the length of the actual data that was input. If no data is input, the return length is zero.
subroutine input
a_data ,a
a_prompt ,a
a_len ,d
proc
display(TTCHN, a_prompt, ": ")
reads(TTCHN, a_data, done)
a_len = %trim(a_data)
done,
xreturn
endsubroutine
The example below checks for valid input.
subroutine chk_inp
a_valid ,a
a_status ,d
.define TTCHN ,1
record
input ,a60
len ,d2
proc
reads(TTCHN, input)
xcall trimz(input, len)
reads(TTCHN, input)
xcall trimz(input, len)
if (len) .and. (input(1:len) .eq. a_valid)) then
a_status = %true
else
a_status = %false
xreturn
endsubroutine
