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

Counting No of columns Print E-mail
User Rating: / 2
Written by Chamara Withanachchi   
Counting No of columns

I wanted to count number of columns in a string variable so I did the following trick, and it worked fine so I thought of putting it here. And Hope someone will benefit.

      * Authour : Chamara Withanachchi
     D string          s             80a
     D pos             S              4  0
     D count           S              3  0
     D noCol           S              3  0


          string = '"Chamara W","123 abc St","Sharjah","SH",'+
                   '"ABC Dome", "Central"';

          // Break by double quotes
          pos = *Zeros;
          pos = %Scan('"' : String : pos+1);
          Dow pos < %Len(%Trim(string));
             pos = %Scan('"' : String : pos+1);
             count += 1;
          count += 1;
          noCol = count /2;

          *inlr = *on;


User Comments

Please login or register to add comments

<Previous   Next>