- NSIS Discussion
- Help with my function
Archive: Help with my function
Afrow UK
27th May 2003 22:34 UTC
Help with my function
I re-wrote this script here after finding that it sometimes goes into a infinite loop (and crashes my installer)
Right now, I found out that it never replaces the last occurence of text, no matter what I do.
I'm currently using:
Push "cls$\r$\n"
Push ""
Push "1"
Push "all"
Push "${INSTDIR}\compile.bat"
Call AdvReplaceInFile
So, my script will use these and it should replace like so...
cls$\r$\n
cls$\r$\n
cls$\r$\n
cls$\r$\n
...becomes...
cls$\r$\n
cls$\r$\n
See that it always leaves another "cls$\r$\n" on the end, when it is not meant to.
Can anyone find out what is either wrong with the script, or what I should do to fix this problem.
Thanks
-Stu
Edit:
I think it would be a good idea to add a "Text file manipulation" directory on the archive, unless it's ok that I create one myself?
Sunjammer
27th May 2003 23:08 UTC
You are more than welcome to create directories yourself. Do whatever you want, if you're not allowed the Archive should stop you :) (don't quote me on that :P)
Afrow UK
27th May 2003 23:27 UTC
Ok thanks :)
I'm still not sure why it is not writing the last line down though (or removing it in my case)
Maybe it's just because in the example I was testing under, it's because it is the last line of the file, and IfErrors is bypassing it.
-Stu
Afrow UK
27th May 2003 23:33 UTC
How would I go about adding a subdir within the "Useful Functions" section?
I would like to add "Text file manipulation" as a subsection within the "Useful Functions" section.
Sorry if I am sounding stupid, but I don't want to make a mess of anything :p
-Stu :)
kichik
28th May 2003 13:32 UTC
To add a directory to the archive go to Contribute and choose "a new section that can contain other pages."
I'll have a look at the script and tell you if I find anything.
kichik
28th May 2003 13:36 UTC
I think the problem in the script is in the loop_filter label. The first comparison you do there is with a copy of $7 minus the last character. While this will work for lines where the last character is not a line break it won't work for the last line that probably doesn't have a line break after it.
Afrow UK
28th May 2003 14:34 UTC
You are right!
Anyone know how I would go about fixing this?
Edit: Made the new section, and put all the scripts in.
Could somone delete the old ones for me?
-Stu
kichik
28th May 2003 14:36 UTC
Afrow, just start the counter from -1 :)
About the sections in the archive you should be able to delete the instances yourself assuming the pages were created by you.
kichik
28th May 2003 14:40 UTC
I have went ahead and did it myself since not all of the pages were yours.
Afrow UK
28th May 2003 14:41 UTC
LOL
I was able to insert other peoples' pages into my section, but I couldn't delete the old ones (made by me) because it said I need administrator rights!
Edit; ok I changed StrCpy $5 -1 and it still doesn't work, unless you mean something else?
-Stu :) :p
kichik
28th May 2003 14:46 UTC
Oops, should be 1. You decrease it by one, not increase.
Afrow UK
28th May 2003 14:51 UTC
Yes, thats what I thought.
The only thing is, once $5 becomes 0, doesn't $6 become ""?
-Stu
kichik
28th May 2003 14:58 UTC
No since 0 is the same as "" and is the same as not specifying anything which never results in "".
Afrow UK
29th May 2003 15:23 UTC
It didn't work using $5 as 1, it stops any lines being changed in the file at all.
The function is pretty much ok
-Stu