|
|
#1 |
|
Junior Member
Join Date: May 2012
Posts: 2
|
Find string from the end of line
Hi there,
I've searched long time at examples and documentation but didn't find a function to search for a string from the end of a line within a ini file. My test.ini looks like this: code: I would like to remove the four lines which start with "Test01" but I only know the ID of the File (ID=78D3-F496-40e4-B08A-ADBA) and not the following Number at "Test" - this number can change. My idea was to search for the ID remove that line and the three lines above. Or save the number in a $var and remove the lines by using this $var within the delete strings. |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,216
|
Read four lines at a time - check the ID in the 4th line and then only write the 4 lines to the new file if required. Then replace the old file with the new.
Also remember FileRead reads new line characters too - you can remove them using ${TrimNewLines} from the manual. Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: May 2012
Posts: 2
|
Thanks for your answer.
My ini has two lines above: code: 1. line = section name 2. line = number of active test I could read four lines at a time, but I have to start on the third line. Hmm, have to understand the code better I think.
|
|
|
|
|
|
#4 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,216
|
Obviously read those 2 lines first before you start reading 4 lines at a time
.If you know how many entries there are then how about looping through them using a ${For} loop and then read using ReadINIStr and delete using DeleteINIStr? Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|