|
|
|
|
#1 |
|
Junior Member
|
Replace string in text file at compile time
I need to replace a string inside of a text file at compile time, in the same way that the ReplaceInFile header does. I know that I COULD write a separate script that does it via the command-line, then call
code: Is there an easier way? |
|
|
|
|
|
#2 |
|
Major Dude
Join Date: Feb 2007
Posts: 672
|
http://nsis.sourceforge.net/TextReplace_plugin
Sorry, I was too quick... This will not work at compile time. |
|
|
|
|
|
#3 |
|
Junior Member
|
Hmm... well in the mean time I'll try the other way...
|
|
|
|
|
|
#4 |
|
Junior Member
|
So, the whole point of this question was that I have portable-ized a few programs for the U3 platform, and anyone who has ever perused PortableApps.com knows how useful NSIS is for creating portable application launchers. Unfortunately, I did have to go the route I had indicated, but it ended up not being so bad. I actually added a few more functions in this manner as well. My one gripe was having to use separate helper scripts, which just made the source folder all ugly.
Then I discovered the wonders of !system 'echo ... >> mytempfile' Well, one thing led to another, and it was just too cool using runtime commands at compile time, and then I was like "hey I'll bet I could take all of these helper scripts I'm writing and merge them all into one!" Yes, I did actually managed to write a very useful script whose output file does NOTHING. ...I get the feeling that no one else has done this before... ...perhaps with good reason... ...I scare myself sometimes... |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Dec 2005
Location: Glow
Posts: 285
|
Try this.
code: Also you could use the NSIS !echo command instead of using !system command to call echo in your script. PaR |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Dec 2005
Location: Glow
Posts: 285
|
I just realized that code probably won't work with script files or with any other files that breaks the parameter quoting.
PaR |
|
|
|
|
|
#7 |
|
Junior Member
|
Hmm... I'll have to try that. Can !echo be used with >> the same as the system echo can? I mean, what is the actual difference? And as for breaking parameter quoting, I can usually get around that with $\"
|
|
|
|
|
|
#8 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
There's no !echo, only !appendfile and it works on all platforms and doesn't depend on the existence of echo or platform dependent command line parsing.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#9 |
|
Junior Member
|
Well, there is an !echo command, I guess it just outputs only to the compiler, but thanks for pointing me at !appendfile, it's exactly what I needed.
...also, I'm not sure what you mean by platform-independent, as I'm pretty sure NSIS is Windows only anyways... |
|
|
|
|
|
#10 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
NSIS can build on other platforms other than Windows (but only build installers that run on Windows).
Stu |
|
|
|
|
|
#11 |
|
Junior Member
|
Oh, right, I knew that... just for some reason I wasn't thinking about the fact that it's a compile-time command, which would depend on the compiling system :P Anyway, problem solved, so thanks for the input
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|