I want to check an file at a particulat column and if the certain characters appear, delete the entire line.
Then I need to edit each line at particular columns to replace the text with my new text.
How do I do this?
Edit ini file
Moderators: Dorian (MJT support), JRL
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Here's a rough skeleton of commands to do what you want.
Read each line of the INI:
ReadIniFile>inifile,section,entry,result
Use MidStr to look at certain column positions:
MidStr>%result%,start,length,result2
Use IF to make decisions:
If>%result2%=value,true_label_name[,false_label_name]
Use EditIni to replace lines:
EditIniFile>inifile,section,entry,newvalue
Read each line of the INI:
ReadIniFile>inifile,section,entry,result
Use MidStr to look at certain column positions:
MidStr>%result%,start,length,result2
Use IF to make decisions:
If>%result2%=value,true_label_name[,false_label_name]
Use EditIni to replace lines:
EditIniFile>inifile,section,entry,newvalue
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
I do understand how to read in the line but once I have the line I need to go over to column 70 and 71 and check to see if the letters DI are in those columns. If DI is there, the line should be deleted.
Once that is finished, I need to edit the file again and replace anything in columns 3 - 12 with the numbers 0123456789
I hope this makes it a little more clear.
Let me know if you have any suggestions.
Once that is finished, I need to edit the file again and replace anything in columns 3 - 12 with the numbers 0123456789
I hope this makes it a little more clear.
Let me know if you have any suggestions.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Modified from the earlier posting:
Remember if you use Cut/Paste from the forum to remove trailing spaces. You can do this in the Editor. Click on Edit, Show All Chars, and Remove Trailing Spaces.
This does both tasks in one pass. It rewrites the oldfile to the newfile, replacing characters 3-12, but only writing lines that do not have DI in positions 70-71. Note that this is untested.//Read each line of the old file:
Let>line=0
Label>Start
Let>line=%line%+1
ReadLn>oldfile,%line%,result
If>%result%=##EOF##,End
//Use MidStr to look at certain column positions:
MidStr>%result%,70,1,test
//Use IF to make decisions:
If>%test%=DI,Start
//Replace positions 3-12
MidStr>%result%,1,2,leader
MidStr>%result%,13,1000,trailer
//Use WriteLn to replace lines:
WriteLn>newfile,%leader%0123456789%trailer%
Goto>Start
Label>End
Remember if you use Cut/Paste from the forum to remove trailing spaces. You can do this in the Editor. Click on Edit, Show All Chars, and Remove Trailing Spaces.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!