Focal Point
[SOLVED] Trying to print a flat file of text

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

September 26, 2008, 03:13 PM
cburtt
[SOLVED] Trying to print a flat file of text
After an hour or so of banging my head against the 'wall of FOCUS' and reading Chapter 5 of the "Describing Data ..." manual, I've given up and am asking for your help in making this simple bit of code work the way it looks like it should work!

I want list the content of a *.txt file; an application control table containing variable length text strings up to 25 characters long. (If this works, I'll expand it with parameters into a generic control file viewer.)

Here's the code of my test example:
 
-* Put temporary text file into the 'NA' applib
APP PREPENDPATH NA
APP HOLDDATA NA
APP HOLDMETA NA
-RUN
-* Generate a temporary *.mas for the text file
FILEDEF MAS DISK E:\ibi\apps\NA\TEMPTEXT.mas
-RUN
-WRITE MAS FILENAME=TEMPTEXT, SUFFIX=FIX, $
-WRITE MAS SEGNAME=SEG1, $
-WRITE MAS FIELDNAME=HEADER_TEXT, FORMAT=A25V, ACTUAL=A25V , $
-RUN
-* Generate content into the temporary text file
FILEDEF DAT DISK E:\ibi\apps\NA\TEMPTEXT.ftm
-RUN
-WRITE DAT 123456 
-WRITE DAT com-bbb-cccc
-WRITE DAT The quick brown fox ...
-RUN
-* Display the content of the temporary text file
TABLE FILE TEMPTEXT
PRINT
     HEADER_TEXT
ON TABLE PCHOLD FORMAT HTML
END
-RUN
 


What I get as a result is (with message viewer OFF):
 
0 NUMBER OF RECORDS IN TABLE=        0  LINES=      0
 

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


WIN/2K running WF 7.6.4
Development via DevStudio 7.6.4, MRE, TextEditor.
Data is Oracle, MS-SQL.
September 26, 2008, 03:41 PM
GinnyJakes
Chris,

You're going to kill yourself. The ddname for your filedef for the file needs to be the same as the name that you are tableing or you need to re-filedef it.

FILEDEF TEMPTXT DISK NA\temptext.ftm
-RUN
-WRITE TEMPTEXT 123456 
-WRITE TEMPTEXT com-bbb-cccc
-WRITE TEMPTEXT The quick brown fox ...

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


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
September 26, 2008, 03:47 PM
Prarie
Sometime one needs another eye. Wink


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
Ginny is right the master file name must be the same as the data files ddname.

Also I don't think the ACTUAL=A25V is right, you probably only want A25 for ACTUAL and USAGE
-* Put temporary text file into the 'NA' applib
APP PREPENDPATH NA
APP HOLDDATA NA
APP HOLDMETA NA
-RUN
-* Generate a temporary *.mas for the text file
FILEDEF MAS DISK E:\ibi\apps\NA\TEMPTEXT.mas
-RUN
-WRITE MAS FILENAME=TEMPTEXT, SUFFIX=FIX, $
-WRITE MAS SEGNAME=SEG1, $
-WRITE MAS FIELDNAME=HEADER_TEXT, FORMAT=A25, ACTUAL=A25 , $
-RUN
-* Generate content into the temporary text file
FILEDEF TEMPTEXT DISK E:\ibi\apps\NA\TEMPTEXT.ftm
-RUN
-WRITE TEMPTEXT 123456 
-WRITE TEMPTEXT com-bbb-cccc
-WRITE TEMPTEXT The quick brown fox ...
-RUN
-* Display the content of the temporary text file
TABLE FILE TEMPTEXT
PRINT
     HEADER_TEXT
ON TABLE PCHOLD FORMAT HTML
END
-RUN



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

Chris, time for a nap!
we've all been there. Wink




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
CBURTT,

Is there just one field in each record (as in the example you gave)? If there is you will have a whole lot less trouble if you make your USAGE and ACTUAL A25 rather than A25V. If there will be more than one field does the file have a field delimiter?


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
Thanks, all, for your help.
This became one of those classic coding equivalent of the 'Forest 'n' Trees' problem. Looking and looking for the invisible bug that your associate's fresh eyes spot in seconds.
Yep, Susannah, we've all been there many times (See you at the Halloween-eve meeting).

PBrightwell: Yes, only 1 field in this control list.
I'll try fixed length.


WIN/2K running WF 7.6.4
Development via DevStudio 7.6.4, MRE, TextEditor.
Data is Oracle, MS-SQL.
As PBrightwell suggested, fixed format is needed.

With variable length string specified, the file reading processes use the first 2 characters of the *.text file as the variable-string-length-counter and think the string's content begins at character 3. This causes the output report to truncate the first 2 characters of the data.

Changing to fixed length allows the first 2 characters to become part of the string and it displays as expected.


WIN/2K running WF 7.6.4
Development via DevStudio 7.6.4, MRE, TextEditor.
Data is Oracle, MS-SQL.