Can some one help me how we can read a master file and compare a value in the master file and append text
i am reading master file FILEDEF master DISK c:/mymaster.mas (APPEND -RUN SET &Text ="some" -REPEAT TOEND WHILE master conatins &Text -WRITE master "abcd" -TOENDThis message has been edited. Last edited by: <Kathryn Henning>,
WEBFOCUS 8.0
July 08, 2015, 12:25 PM
sh98110
One way to do this type of comparison is to issue the command:
CHECK FILE master_name HOLD
This generates a HOLD file with all the components of the MASTER, which may then be examined with a simple TABLE request.
WebFOCUS 8 Windows, All Outputs
July 09, 2015, 03:31 AM
Danny-SRL
Siddu, We need a bit more detail of what you are trying to achieve. For example, in your -REPEAT you are not reading your "master" so how can you issue a CONTAINS test.
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
July 09, 2015, 09:04 AM
siddu1790
Thanks for your replies sh98110 and danny, i started to learn focus programming 2 days ago.. what i am trying to accomplish is , i want to read a master file and search for a particular line in the master file and i want to edit (delete or add) some text or add new lines to the master file and save it. I don't know exactly how can i do that. after a lot of struggling i was able to read the master file , but having a hard time comapring the text and modifying it Below is my sample code :-
-SET &ECHO=ALL;
FILEDEF mymaster DISK mymaster.mas (LRECL 150) FILEDEF mymaster DISK mymaster.mas (APPEND -RUN CHECK FILE mymaster1 HOLD AS testholdfile
TABLE FILE mymaster1 PRINT * ON TABLE HOLD AS COMPDEP FORMAT ALPHA END -RUN -SET &MAS_COUNT = &LINES; -REPEAT :MAS_READ FOR &I FROM 1 TO &MAS_COUNT; -READ mymaster &Text.&I.A150 -TYPE text =&Text.&I.A150 -:MAS_READ
From the above code i can read the master file and i can display it using text variable , next i used IF &Text.&I.A150 EQ " some text" to compare it but i am having UNRECOGNIZED COMMAND IF error
how can i modify the when it matches the text , i know java programming we can use if(text ="someText"){ ----logic to modify }
how can we do it in focus programming
Any help would be appreciated
Thank you
WEBFOCUS 8.0
July 10, 2015, 11:45 AM
George Patton
My question is: Why would you want to add or delete lines from a master file? Since it describes your data surely you are going to have a problem if you mess with it.
On the other hand, if you are creating a new master starting with an old one, why not just copy it and then edit the copy?
This is another of those situations where knowing what the fianl objective is would help a lot in providing the most appropriate solution.