m204prgmr Posted June 27, 2005 Report Share Posted June 27, 2005 Ok, I musta be going koo koo but I thought I could find the starting position of text while processing a text file and now I don't see it. I've processed a text file to pull out only lines containing specific text and append T1 to another .txt file. I now want to process that new file and find the starting position of my particular text, hightling that text and append only that part to a newer document. Quote Link to comment Share on other sites More sharing options...
kevin Posted June 27, 2005 Report Share Posted June 27, 2005 Are you thinking of the Process Partial Records option in the Text File Begin Process command? Quote Link to comment Share on other sites More sharing options...
randallc Posted June 27, 2005 Report Share Posted June 27, 2005 or, on each line in "process all records" of new file, check the returned string for "set integer" by position of found text? Is this what you did the first time anyway? best, Randall Quote Link to comment Share on other sites More sharing options...
m204prgmr Posted June 27, 2005 Author Report Share Posted June 27, 2005 My code is such; <BTFBEG:001:000001:000000:C:\Audittest.txt><IFVAR2:1:01:7:M204.><TMVAR2:20:01:00:000:000:C:\junk2.txtT><ENDIF><BTFEND> And below is what junk.txt looks like. The M204.* values do not all start in the same position. 05176095208 4 0 0 AD /// M204.0342: CTTC: 96.219 11:29:56, 05.080 9:54:20 TSIPROD S99257.TSIP. 05176095208 5 0 0 MS *** M204.2079: MINBUF RESET TO (NSERVS + NSUBTKS) * MAXOBUF + 15 = (1 05176095216 0 0 0 AD /// M204.0075: INITIALIZATION COMPLETED. BUFFERS = 10000 05176095216 1 0 0 MS *** M204.0082: TIMELEFT = 86400.564 I want to pull out only M204.* values. Since each line is going to contain a different M204. value, wouldn't it be best to locate the starting position and go 9 character? Thanks Robert Quote Link to comment Share on other sites More sharing options...
kevin Posted June 27, 2005 Report Share Posted June 27, 2005 I think you need to use the Variable Set Integer %N1% from Position of Text in Variable %T1% command. Quote Link to comment Share on other sites More sharing options...
m204prgmr Posted June 28, 2005 Author Report Share Posted June 28, 2005 Bada Bing....thank you so much Kevin. That's what I was looking for. Robert Quote Link to comment Share on other sites More sharing options...
m204prgmr Posted June 28, 2005 Author Report Share Posted June 28, 2005 Kevin, Now that we've determined how to find the starting position, how would you copy 9 characters starting at N1 and place them into a new text document. Can this be done without opening Notepad or wordpad? And sorry for the elemtary questions but I'm having a bad CRS day...lol Robert Quote Link to comment Share on other sites More sharing options...
joe Posted June 28, 2005 Report Share Posted June 28, 2005 To copy your 9 characters use the Variable Modify String command (see picture). As to putting them into a text document, it depends on the state of the text document. Is it launched and waiting? Is the text to be prepended, inserted, or appended? Or are you just creating a text document to hold the lines that you are parsing? Quote Link to comment Share on other sites More sharing options...
m204prgmr Posted June 28, 2005 Author Report Share Posted June 28, 2005 Kevin, The new text document will edd up containing redundent values that will need to be filtered leaving only unique ones. I had seen your previous suggestion in Help and was uncertain if entering 9 was the correct way to do it. The objective of this project is to automate a look up of message numbers from an online audit of 3rd party software running in the mainframe. Each M204.* relates to either informational or error and they will result in return codes GT 00 or none at all. From a DBA standpoint, I don't have all day to review each M204.* number and cross reference it to the manual. But I will take the time to put this information into a easier method of knowing how the nightly batch ran and what caused errors. And, this also lends an opportunity to track occurences of the messages. Robert Quote Link to comment Share on other sites More sharing options...
kevin Posted June 28, 2005 Report Share Posted June 28, 2005 Thank you Joe for supplying answers this morning while I was busy doing other things. I'm not sure if you still have a question but here are a few bits of advice. Using Macro Express commands you can append lines of text to a file. You don't need to worry about creating the file if it doesn't exist. However, you may want to delete the file when the macro runs to clear out stuff from the night before. Or, you could use the date as part of the filename so you don't have to worry about that. Macro Express cannot change the content of an existing file. It can only write to a new file. Using the Variable Set Integer and Variable Modify String commands you can copy from the beginning of a string to the position of the "M204.", you can copy from the beginning of the "M204." to the end of the line, you could copy from the next character after "M204" to the end of the line, or you could copy 9 characters from the beginning of the "M204.". Are you certain that the message numbers are always 9 characters long? You may want to consider looking for the : or a space. Something like this: // Delete the file if it exists If File Exists "OutputFile.txt" Delete File or Files: "OutputFile.txt" End If // Process through the Input File Text File Begin Process: "InputFile.txt" // Set N1 to the position of 'M204' Variable Set Integer %N1% from Position of Text in Variable %T1% // Set N2 to the position of ': ' (colon followed by a space) Variable Set Integer %N2% from Position of Text in Variable %T1% // Copy from the beginning of 'M204' to the beginning of ': ' Variable Modify String: Copy Part of %T1% to %T2% // Append this line to the end of a Text File Variable Modify String: Append %T2% to Text File Text File End Process Quote Link to comment Share on other sites More sharing options...
m204prgmr Posted July 13, 2005 Author Report Share Posted July 13, 2005 Thanks Joe and Kevin, I was on vacation the last few weeks... Robert Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.