× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Does this help?
===================================
     D Keywords        S              2S 0 DIM(250)
      ** 1----6----12----18-----
     D TextLine        S           1000A Inz('Word1,Word2,Word3,Blanks')
     D I               S              5I 0

      ** Following block of code probably in a DOW/DOU loop if processing multiple records
     C     ','           Scan      TextLine      Keywords

     C                   For       I = 1 To %Elem(Keywords)
     C                   If        Keywords(I) = 0
      ** Array element is zero - no more commas found
     C                   Leave
     C                   Endif

      ** Next comma found - process TEXTLINE as required
     C     Keywords(I)   Dsply     '*REQUESTER'
     C                   EndFor
     C                   Clear                   Keywords
     C                   Eval      *InLR = *On
     C                   Return
===================================
(I think this should work at V4R5. FOR-loop introduced at V4R4.)

Brian

On 22/08/2020 16:18, Patrik Schindler wrote:
Hello,

information regarding traditional, positional RPG are getting scarce in the net. So I opt to ask the community. Maybe some can remember how to program positional?:-)

I'm parsing a file with 9 different types of line content. One of them contains words or phrases, separated by comma. Different amounts of comma, different length of strings.

I learned that I can get an array of comma positions with:

C ',':1 SCAN TEXTLINE KEYWORDS

TEXTLINE contains the input string (comma separated keywords/phrases). KEYWORDS should receive the comma positions from SCAN:

DKEYWORDS S 2S 0 DIM(250)

How to do I actually do this loop, the equivalent of a for-loop iterating through each entry of the array? How can I know how many elements are actually used in the hard coded, predefined limit of 250 elements, to stop processing after all elements are processed? And, how to reset the array to empty before the next line containing keywords is to be processed? I never worked with array in RPG IV.

Unfortunately, the ILE Reference PDF isn't that much helpful regarding my questions.

Pointers to statements or documentations are very welcome!


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.