Thursday, January 31, 2008

String Handling simplified with Variable Length Fields:

The varying-length character type (available in V4R2 and above) can simplify string-handling code as well as make it more efficient.

Use the Keyword “VARYING” on the declaration line (D-Spec) of the character variable.

Example:

Without variable length fields

C EVAL Name = %TRIMR(Lib) + '/' +
C %TRIMR(File) + '(' +
C %TRIMR(Mbr) + ')'


With variable length fields

C EVAL Name = Lib + '/' +
C File + '(' +
C Mbr + ')'

No comments: