RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

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
PoorBest 
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

      /free

          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;
          enddo;
          count += 1;
          noCol = count /2;

          *inlr = *on;

      /end-free                                

User Comments

Please login or register to add comments

<Previous   Next>