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

Using C function STRTOK to read .csv table Print E-mail
User Rating: / 4
PoorBest 
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)

      /free

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

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

         *inlr = *on; 

      /end-free


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  
 
http://www.code400.com/forum/showthread.php/10930-Reading-a-CSV-file-using-strtok?highlight=strtok%28

Please login or register to add comments

<Previous   Next>