Focal Point
-READ a hold file in MRE

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2061076452

October 29, 2007, 10:19 PM
JohnB
-READ a hold file in MRE
I have created a 1-record hold file and need to load its field values into variables. This is an MRE, and I'm having difficulty getting -READ to work. Evidently I need some assistance with either APP HOLD, APP FI, or FILDEF.

Please advise.

Thank you,

John
October 30, 2007, 01:14 AM
JohnB
I found the following example in another topic, and it worked fine:
TABLE FILE CAR
PRINT MAX.CAR
ON TABLE HOLD
END
-RUN
-READ HOLD &CAR.A16
-TYPE Car: &CAR

The problem is when trying to load into more than one variable:
TABLE FILE CAR
PRINT MAX.CAR MIN.CAR
ON TABLE HOLD
END
-RUN
-READ HOLD &CAR1.A16, &CAR2.A16
-TYPE Car: &CAR1.A16, &CAR2.A16

Why does this not work?

Thanks,

John


WF 7.7.03, Windows 7, HTML, Excel, PDF
October 30, 2007, 03:42 AM
Tony A
John,

The likely reason that your initial attempt did not work, is that you did not put -RUN after your table request before your -READ statement.

Because -READ is dialogue manager it is executed in a pre-process situation (almost) and therefore you need to ensure that the table request is executed beforehand. The -RUN executes the stack that has been built upto that point and therefore ensures that the temp file is available to it.

Incidently, unless you want to run a table request against the temp file, use SAVE instead of HOLD as no master file description is created for it and the default save format is alpha. If you HOLD numeric data without specifying a format (e.g. ON TABLE HOLD FORMAT ....) the data will be held as internally formatted data which you will not be able to read properly using your -READ.

Now, the reason that your example is giving you JAGUAR, JAGUAR is that you are using PRINT where each row will be read and printed. You should notice that you get 10 rows of output into your temp file and each one relates to a CAR segment. If you use SUM instead then you will get only one line of output and also the result that you expect -

Car: Triumph, Alfa Romeo

TABLE FILE CAR
SUM MAX.CAR MIN.CAR
ON TABLE SAVE
END
-RUN
-READ SAVE &CAR1.A16, &CAR2.A16
-TYPE Car: &CAR1.A16, &CAR2.A16


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10