RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

String Handling with Variable-Length felds Print E-mail
User Rating: / 0
Written by Chamara Withanachchi   
String Handling with Variable-Length felds

Recommend using varying-length fields as CONST or VALUE parameters to every string-handling subprocedure as well as for string temporaries. Here's a little example; not only does it look better, but it's also faster (no %TRIMs). Instead of:

C          EVAL   Name = %TRIMR(FirstName) + ' ' +
C                        %TRIMR(SecondName) + ' ' +
C                        %TRIMR(LastName) 

with variable-length fields, you can use:

C          EVAL   Name = FirstName + ' ' +
C                        SecondName + ' ' +
C                        LastName 

This approach is faster, and it turns out it's more than twice as fast to produce "FirstName SecondName LastName", where all variables (except "Name") are 100 characters long.

<Previous   Next>