Archive for the ‘RPGLE Functions : %SUBST’ Category
In the never ending loop shown below, STRING is the variable containing the string value which needs leading characters, most commonly leading zeros, stripped from the value.
The following %scan operation shown below tests position 1 of the string to determine if the value found is a ‘0’ (character zero).
position = %scan ('0':STRING:1);
A test for ‘0’ is made on position 1 of the string. If found, the %subst operation is used to remove it.
The string is then trimmed and the loop continues for the next test of position 1.
The loop ends when there are no more leading characters to be stripped.