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



Pete, have you looked into using the %LookUp BIF?  The result of the
%LookUp returns 0 when it doesn't find that value in the Array, otherwise,
it returns the element it was found in.

Michael Schutte



                                                                           
             Pete Helgren                                                  
             <Pete@xxxxxxxxxx>                                             
             Sent by:                                                   To 
             rpg400-l-bounces@         RPG Midrange Discussion             
             midrange.com              <rpg400-l@xxxxxxxxxxxx>             
                                                                        cc 
                                                                           
             05/05/2006 01:53                                      Subject 
             AM                        Efficient validation of array       
                                       contents                            
                                                                           
             Please respond to                                             
              RPG programming                                              
              on the AS400 /                                               
                  iSeries                                                  
             <rpg400-l@midrang                                             
                  e.com>                                                   
                                                                           
                                                                           




I have a set of five values that come in from a prompt screen that can
be from 1 to 5 and can only occur once.  That is, if a value is entered
(not 0) , it must be a value from 1 to 5 and there cannot be duplicate
values.

The fields are loaded into an array:

     DUDFS             DS
     D  FTSUDF1                       1S 0
     D  FTSUDF2                       1S 0
     D  FTSUDF3                       1S 0
     D  FTSUDF4                       1S 0
     D  FTSUDF5                       1S 0
     D  UDF                                Like(FTSUDF1) Dim(5)
     D                                     overlay(UDFS)

and then I loop through them:

          for LoopCount =  1 to 5;
            if UDF(LoopCount) <> 0;
             // Check to make sure the value is between 1 and 5
                if UDF(LoopCount) > 5;
                      //Error occurs
                endif;
             // Check to make sure the number only occurs once
                ??
            endif;
         endfor;

I can't think of an easy way to check the occurrence of the number in
the array.  The brain is just a wee bit stretched tonight.

A quick solution?

Thanks,

Pete Helgren

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

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.