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

Using C function STRTOK to read .csv table Print E-mail
User Rating: / 4
Written by Chamara Withanachchi   

Originaly from Jamie Flanary, Code400.com

     h dftactgrp(*no) actgrp(*caller) option(*srcstmt)
     h bnddir('QC2LE')

     d counter         s              3s 0
     d displayme       s             20
     d isodate         s               d   inz
     d n12             s             12s 0
     d pointer         s               *
     d reply           s              1
     d response        s           4096a
     d rundte          s              6s 0
     d  token          S            160A   varying
     d                 DS

     dstrtok           PR              *   ExtProc('strtok')
     d string                          *   value options(*string)
     d delim                           *   Value Options(*string)


         response  =  'tree,dog,bird,,cow,horse,flower';
         response = %scanrpl(',,' : ', ,' : response);
         reset counter;
         pointer = strtok(response: ',');

         dow (pointer <> *null);
          token = %trim(%str(pointer));
          pointer = strtok(*null: ',');
          displayme = %trim(token);
          dsply displayme reply;

         *inlr = *on; 


User Comments

Comment by jimmyoctane on 2012-07-06 03:59:06
this looks EXACTLY like the sample I posted on my website..... http://www.code400.com  

Please login or register to add comments

<Previous   Next>