Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 30th May 2012, 17:45   #1
jazde86
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:
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.
jazde86 is offline   Reply With Quote
Old 30th May 2012, 17:55   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
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
Afrow UK is offline   Reply With Quote
Old 30th May 2012, 18:38   #3
jazde86
Junior Member
 
Join Date: May 2012
Posts: 2
Thanks for your answer.

My ini has two lines above:
code:
[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.
jazde86 is offline   Reply With Quote
Old 30th May 2012, 20:51   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
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
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump