Performing a range lookup from external file

Posted by Admin on 02-Oct-2008 11:10

This is my first post to this forum and I am rather new to Progress so I hope I am asking in the correct place.

I have users who manage product pricing in Excel tables. The row/columns of the Excel table are window dimensions such as 12, 24, 36, etc. The result of each row/column coordinate is a price. However, the actual window dimensions are usually in between the row/column ranges. i.e If the actual value for the row is 28, then move up to the 36. The user saves the Excel file as a .csv on the network and program uses this in an application.

There is currently a program that does a lookup to a .csv but for for text values only which will find an exact match. How can I change the following code to do a range lookup using decimal values? From what I have learned about Progress programming, it seems the following example cannot be adapted. If so, what would the basic structure be for a program that would work in this situation?

Thank you for any feedback.

DEF INPUT PARAM fileuse AS CHAR NO-UNDO.

DEF INPUT PARAM colfind AS CHAR NO-UNDO.

DEF INPUT PARAM rowfind AS CHAR NO-UNDO.

DEF OUTPUT PARAM itemout AS CHAR NO-UNDO.

DEFINE STREAM fileread.

DEF VAR linetext AS CHAR NO-UNDO.

DEF VAR cnt AS INTEGER NO-UNDO INIT 1.

DEF VAR numitems AS INTEGER NO-UNDO.

INPUT STREAM fileread FROM VALUE(fileuse).

filereadloop:

REPEAT :

IMPORT STREAM fileread UNFORMATTED linetext.

IF cnt = 1 THEN DO:

numitems = LOOKUP(colfind,linetext).

cnt = cnt + 1.

END.

ELSE DO:

IF ENTRY(1,linetext) = rowfind THEN DO:

itemout = ENTRY(numitems,linetext).

LEAVE filereadloop.

END.

END.

END.

All Replies

Posted by ChUIMonster on 02-Oct-2008 13:34

I cannot picture what your data file looks like. Could you provide a short sample?

Posted by ChUIMonster on 02-Oct-2008 13:38

I cannot picture what your data file looks like. Could you provide a short sample?

Posted by jtownsen on 02-Oct-2008 17:09

You would need to add another parameter to the signature - something like:

[=,,>=]

and then do something like:

This thread is closed