|
Go
![]() |
New
![]() |
Search
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Silver Member |
maybe something like:
SQL SELECT MAX(cost) AS MAX_COST FROM ...; TABLE FILE SQLOUT PRINT * ON TABLE SAVE END -RUN -READ SAVE &MCOST -IF &MCOST EQ 10 THEN GOTO OUT; .... some other stuff done here ... -OUT hth, drew |
|||
|
|
Master |
Make sure you know how wide the field is when stored in SAVE, and initialize &MCOST to that width (or specify it in the -READ).
|
|||
|
| <bigpgo>
|
Thanks for the replies. I tried it just like you said (and added the width):
-READ SAVE &MCOST.I22 But it's asking me to enter a value for MCOST. If I specify "no input parameters" in the properties, it says MCOST value is missing. Any thoughts? |
||
|
|
Master |
Some suggestions:
1. Are you sure that the COST variable stored in SAVE is USAGE=I22 (or P22)? Check the MFD of the source table. 2. Add: -SET &MCOST='0000000000000000000000'; -* (or any string value 22 characters wide) to initialize &MCOST to the appropriate length before the -READ, instead of specifying format in the -READ 3. Add -TYPE ## &|MCOST: -TYPE ## '&MCOST' -TYPE ## *123456789.123456789.123456789. before and after the read, to verify what value &MCOST received (length, content). 4. Use EDIT() to force evaluation as an integer: -IF EDIT(&MCOST) EQ 10 ... |
|||
|
|
Guru |
-IF myReport2.myCost EQ 10 THEN GOTO OUT;
-READ SAVE &MCOST.I22 Why are are you specifying I22? The width being referred to is the width of the value, not the width of the qualified field name. Integer formats are generally I9 or less. |
|||
|
| <Pietro De Santis>
|
The best way for us to help you would be to post an example that we can run on our P.C's.
Here is an example of using Dialog Manager to read a value from a HOLD or SAVE file and then use the value for further processing. This example also illustrates that, in Dialog Manager, you can read a value as an alpha field, but use it in numeric calculations. The problem you're encountering may be occuring because I22 is not a valid numeric format, there is a maximum length for Integer fields, I10, I think. SET HOLDLIST=PRINTONLY TABLE FILE CAR PRINT RETAIL_COST/P22 WHERE RECORDLIMIT EQ 1 ON TABLE SAVE END -RUN -READ SAVE &RET_COST.A22 -TYPE &RET_COST -SET &RET_COST2 = &RET_COST * 239; -TYPE &RET_COST2 -IF &RET_COST GT 5000 GOTO OVER_5; -TYPE UNDER 5000 -OVER_5 -TYPE OVER 5000 (There's ampersands on all the Dialog Manager variables in case this forum removes them) |
||
|
| <bigpgo>
|
Pietro, your solution worked. Specifically, this line:
SET HOLDLIST=PRINTONLY was very important. If I dont have this line, the code doesnt work (it then thinks that MYCOST field that I compute is 0 in my -IF statement, all the time). One question that I have is: can you provide a code sample that reads from a HOLD file, not a SAVE file? I tried doing: SET HOLDLIST=PRINTONLY TABLE FILE report1 COMPUTE MYCOST/I5 = MAX_COST; ON TABLE HOLD AS report2 END -RUN -READ report2 &MYCOST.I5 -IF &MYCOST GT 5 GOTO OVER_5; But it complains that value for MYCOST is missing. What's the proper syntax? Thanks a lot. |
||
|
| <Pietro De Santis>
|
ON TABLE HOLD FORMAT ALPHA
Format Alpha is very important if you want to read the file with Dialog Manager or copy the HOLD file for use with a non-FOCUS program. According to the manual, FORMAT HOLD creates a BINARY file, the data is not stored as you may expect. I always use ON TABLE HOLD FORMAT ALPHA, even if I'm not going to read the file with Dialog Manager. I hope this helps. SET HOLDLIST=PRINTONLY TABLE FILE CAR PRINT RETAIL_COST/I5 WHERE RECORDLIMIT EQ 1 ON TABLE HOLD FORMAT ALPHA END -RUN -READ HOLD &RET_COST.I5 -TYPE &RET_COST |
||
|
| <bigpgo>
|
That worked beautifully, thanks a lot.
Complete code: SET HOLDLIST=PRINTONLY TABLE FILE report1 COMPUTE MYCOST/I5 = MAX_COST; ON TABLE HOLD AS report2 FORMAT ALPHA END -RUN -READ report2 &MYCOST.I5 -IF &MYCOST GT 5 GOTO OVER_5; |
||
|
|
Platinum Member |
Hi Just as a last note... if you have more than one param, just separate them in the same READ line
like ... -READ HOLDFILE &X.A1 &Y.A2 etc. Just make sure you refer to every field in the correct order of course. |
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|

