Focal Point
[CLOSED] READ feature Loading record fields into amper variables

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

May 12, 2009, 01:39 PM
IronMaiden
[CLOSED] READ feature Loading record fields into amper variables
CAR LENGTH WIDTH HEIGHT
JAGUAR 190 66 48
JAGUAR 199 70 54

Trying to load 3 amper variables LENGTH WIDTH HEIGHT with decimal data. Length, Width and Height are all D5. I should get
389 136 and 102 but as you can see I don't. What am I doing run?

-* File newfex.fex
TABLE FILE CAR
SUM
LENGTH
WIDTH
HEIGHT
WHERE CAR EQ 'JAGUAR';
ON TABLE HOLD
END

? HOLD
-RUN
-READ HOLD, &vLENGTH
-TYPE &vLENGTH
-EXIT
END

gives me
0 NUMBER OF RECORDS IN TABLE= 2 LINES= 1
0DEFINITION OF HOLD FILE: HOLD
0FIELDNAME ALIAS FORMAT
LENGTH E01 D5
WIDTH E02 D5
HEIGHT E03 D5
fffffFx@fffff÷`@fffffÄY@



IF I change
-READ HOLD, &vLENGTH
to
-READ HOLD, &vLENGTH.D5.
I get
0 NUMBER OF RECORDS IN TABLE= 2 LINES= 1
0DEFINITION OF HOLD FILE: HOLD
0FIELDNAME ALIAS FORMAT
LENGTH E01 D5
WIDTH E02 D5
HEIGHT E03 D5
0 ERROR AT OR NEAR LINE 13 IN PROCEDURE newfex.fex
(FOC299) UNRECOGNIZED FORMAT OF AMPER VARIABLE IN -READ: -READ HOLD,
&vLENGTH.D5.


IF I change
-READ HOLD, &vLENGTH
to
-READ HOLD, &vLENGTH.I5
I get
0 NUMBER OF RECORDS IN TABLE= 2 LINES= 1
0DEFINITION OF HOLD FILE: HOLD
0FIELDNAME ALIAS FORMAT
LENGTH E01 D5
WIDTH E02 D5
HEIGHT E03 D5
fffff

Same for I6, A5, A6

NEXT SCENARIO: Print all 3 Amper varaibles
TABLE FILE CAR
SUM
LENGTH
WIDTH
HEIGHT
WHERE CAR EQ 'JAGUAR';
ON TABLE HOLD
END

? HOLD
-RUN
-READ HOLD, &vLENGTH.D5., &vWIDTH.I5., &vHEIGHT.I5.,
-TYPE &vLENGTH &vWIDTH &vHEIGHT
-EXIT
END

I get (nothing)

0 NUMBER OF RECORDS IN TABLE= 2 LINES= 1
0DEFINITION OF HOLD FILE: HOLD
0FIELDNAME ALIAS FORMAT
LENGTH E01 D5
WIDTH E02 D5
HEIGHT E03 D5

This message has been edited. Last edited by: Kerry,


Webfocus 7.6.6
Solaris 10 Sparc 64bit
May 12, 2009, 02:11 PM
GinnyJakes
Try ON TABLE HOLD FORMAT ALPHA. The WebFOCUS default for a hold file is binary.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
May 12, 2009, 04:10 PM
IronMaiden
Same problem.


Webfocus 7.6.6
Solaris 10 Sparc 64bit
May 12, 2009, 04:16 PM
Tom Flynn
Not a problem if you follow Ginny's advice:

  
TABLE FILE CAR
SUM
LENGTH
WIDTH
HEIGHT
WHERE CAR EQ 'JAGUAR';
ON TABLE HOLD FORMAT ALPHA
END
-RUN
?FF HOLD
-READ HOLD &LENGTH.I5. &WIDTH.I5. &HEIGHT.I5.
-TYPE LENGTH: &LENGTH
-TYPE WIDTH:  &WIDTH
-TYPE HEIGHT: &HEIGHT
-EXIT



Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
May 13, 2009, 08:39 AM
DW Marker
Note that one important change made by Tom is also the removal of the commas (,) from the -READ statement.


WF 7.6.4
Windows XP and UNIX
May 14, 2009, 12:50 AM
TexasStingray
use SAVE FORMAT ALPHA

Hold the file in a location you can read later then you can look at it and determine how many characters to read for each variable.




Scott

As Texas suggests, use SAVE instead of HOLD unless you are going to perform a TABLE request against that file.

SAVE doesn't produce a master file whereas HOLD does as was pointed out by Tom here.

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 
IronMaiden,

The first thing you have to understand is that Dialog Manager deals exclusively with CHARACTERS. &variables contain CHARACTERS which might be only numbers. That is why Ginny, Texas and Tony suggested that you use either HOLD FORMAT ALPHA or SAVE.

Also, when you use HOLD FORMAT ALPHA or SAVE, WebFocus creates records which end with CRLF, something that -READ needs.

When you want to -READ data from a file, there are 2 formats: fixed or comma-delimited. When you use SAVE you create a fixed format, unless you insert commas. So, in your case your -READ command should be:
  
-READ  &vLENGTH.I5. &vWIDTH.I5. &vHEIGHT.I5.


I hope this makes it clear.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

&vars can contain decimals..which is swell..that happened several 7's ago...
so if you need your &vars to contain decimals,
you have to be sure you can actual export a text field that contains those decimals...
might take a little EDIT work up front on your source data. Give it a try




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
quote:
&vars can contain decimals

There's a setting to decide the precision.

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