Trestkon
28th December 2004 17:58 UTC
Loop Help
I have some code that find a specific line in a file and and adds in several other lines directly after it. The loop works great (someone on this forum helped me with it) but I'm wondering how I might add add some more code into the loop to add several other lines to a *different* section of the file.
The code and problem is outlined here:
http://www.offtopicproductions.com/temp/nsishelp.txt
Thanks:-)
Trestkon
28th December 2004 18:23 UTC
After reading up on FileRead I've modified the code a bit and I think it's almost how I want it. The problem seems to be (I think) that when it gets to the second loop it's already at the bottom of the file and so reads nothing and sets the error flag. I think I just need a way to return it to the top of the file before the second loop.
http://www.offtopicproductions.com/temp/nsishelp2.txt
Instructor
28th December 2004 18:55 UTC
"adds in several other lines directly after it"
FileOpen $4 "$INSTDIR\TNM\System\TNM.ini" "r"
GetTempFileName $R1
FileOpen $5 $R1 "w"
loop:
FileRead $4 $6
IfErrors done
FileWrite $5 $6
StrCmp $6 "CacheExt=.uxx$\r$\n" 0 +3
FileWrite $5 "...$\r$\n"
FileWrite $5 "...$\r$\n"
StrCmp $6 "EditPackages=IpServer$\r$\n" 0 loop
FileWrite $5 "...$\r$\n"
FileWrite $5 "...$\r$\n"
Goto loop
done:
FileClose $4
FileClose $5
Trestkon
28th December 2004 19:40 UTC
Awesome! Thanks a lot:D
Now I better decipher exactly what everything does so I can do it myself next time:-)
Instructor
28th December 2004 19:53 UTC
You are welcome.