Archive: Find string from the end of line


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:

Test00 File=xy.dll
Test00 On=1
Test00 No=0
Test00 ID=4ED8-91F4-4a08-9006-0D47
Test01 File=abc.dll
Test01 On=1
Test01 No=0
Test01 ID=78D3-F496-40e4-B08A-ADBA
Test02 File=efg.dll
Test02 On=1
Test02 No=0
Test02 ID=CD5D-73B9-4a2b-BB8F-8751


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.

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


Thanks for your answer.

My ini has two lines above:

[Test]
Number=3

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. :weird:

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