× 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.



<<The number of elements in Array must equal the number of characters in
ScanString.>>

That's exactly why it was never suggested.  The string doesn't always have
the same amount of variables.

Michael Schutte
Work 614-492-7419
email  michael_schutte@xxxxxxxxxxxx


                                                                           
             "Terry                                                        
             Richardson"                                                   
             <terry-sssc@adelp                                          To 
             hia.net>                  <rpg400-l@xxxxxxxxxxxx>             
             Sent by:                                                   cc 
             rpg400-l-bounces@                                             
             midrange.com                                          Subject 
                                       Re: RPGLE pgm to parse a string     
                                                                           
             04/05/2006 09:08                                              
             PM                                                            
                                                                           
                                                                           
             Please respond to                                             
              RPG programming                                              
              on the AS400 /                                               
                  iSeries                                                  
             <rpg400-l@midrang                                             
                  e.com>                                                   
                                                                           
                                                                           




I didn't see anyone mention using the SCAN op code.  I know, everyone here
seems to think /free is a must, but the %scan BIF is lacking something the
good old op code gave us.  You can populate an array with the positions of
a
search argument with a string using the SCAN op code.

Take the following string.

'my_string_to_be_scanned_and_fill_array_with_positions_where_underscore_is'

Using the following:

C     '_'           SCAN      ScanString    Array

The resulting array will contain the values
3,10,13,16,24,28,33,39,44,54,60,71,0,0,0,0,0,0,0,......

The number of elements in Array must equal the number of characters in
ScanString.

So to get the word 'where' as you requested, take the resulting array, do a
LOOKUP for the first occurrence of a zero value, and subtract 2 from the
index, save the element value in Y, subtract one more from the index, save
the element value in X, then use the following to get the string you want:

C                   EVAL      WhatIWant = %subst(ScanString:X+1:Y-1)

Note:  I have not tested this, just did this off the top of my head.
****************************************


--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.