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



Steve,

the %lookupxx() function comes leaping into my already crowded mind (from 
WDSCi help on %bif's):


The following functions return the array index of the item in array that 
matches arg as follows: 
%LOOKUP 
An exact match. 
%LOOKUPLT 
The value that is closest to arg but less than arg. 
%LOOKUPLE 
An exact match, or the value that is closest to arg but less than arg. 
%LOOKUPGT 
The value that is closest to arg but greater than arg. 
%LOOKUPGE 
An exact match, or the value that is closest to arg but greater than arg. 
If no value matches the specified condition, zero is returned. 
The search starts at index startindex and continues for numelems elements. By 
default, the entire array is searched. 
The first two parameters can have any type but must have the same type. 
They do not need to have the same length or number of decimal positions. 
The third and fourth parameters must be non-float numeric values with zero 
decimal positions. 
For %LOOKUPLT, %LOOKUPLE, %LOOKUPGT, and %LOOKUPGE, the array must be 
defined with keyword ASCEND or DESCEND. The ALTSEQ table is used, unless arg or 
array is defined with ALTSEQ(*NONE). 
Built-in functions %FOUND and %EQUAL are not set following a %LOOKUP 
operation. 
The %LOOKUPxx builtin functions use a binary search for sequenced arrays 
(arrays that have the ASCEND or DESCEND keyword specified). 
Note:
Unlike the LOOKUP operation code, %LOOKUP applies only to arrays. To look 
up a value in a table, use the %TLOOKUP built-in function. 
For more information, see Array Operations or Built-in Functions. 
Figure 203. %LOOKUPxx Example


 *..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
 /FREE
   arr(1) = 'Cornwall';
   arr(2) = 'Kingston';
   arr(3) = 'London';
   arr(4) = 'Paris';
   arr(5) = 'Scarborough';
   arr(6) = 'York';
 
   n = %LOOKUP('Paris':arr);
   // n = 4
 
   n = %LOOKUP('Thunder Bay':arr);
   // n = 0 (not found)
 
   n = %LOOKUP('Kingston':arr:3);
   // n = 0 (not found after start index)
 
   n = %LOOKUPLE('Paris':arr);
   // n = 4
 
   n = %LOOKUPLE('Milton':arr);
   // n = 3
 
   n = %LOOKUPGT('Sudbury':arr);
   // n = 6
 
   n = %LOOKUPGT('Yorks':arr:2:4);
   // n = 0 (not found between elements 2 and 5)
 /END-FREE



HTH,

Peter Colpaert
Application Developer
Massive - Kontich, Belgium
-----
Yoda of Borg are we.  Futile is resistance, assimilated will you be.
-----




"Raby, Steve (GE Advanced Materials, consultant)" <steve.raby@xxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
23/06/2005 11:36
Please respond to RPG programming on the AS400 / iSeries

 
        To:     "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx>
        cc: 
        Subject:        RE: RPG Free Format question


 
>In the past two years we had a lot of people in and out on short term
>contracts.  It was interesting to see the variety of coding styles.  A
>few hadn't made it much past RPGII and a few had a very modern approach.
>I think the average was RPGIII compiled with CRTBNDRPG.  Mostly no left
>hand indicators, but indicators for file ops and lookup. 

Now I show my total ignorance, I don't use indicators for most things 
anymore but how do I code a lookup without using indicators? I am just 
about to do that in a program so I would be grateful for pointers. :-)

Steve
An old git trying to drag himself into the 21st century.  :-)



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.