Old 2nd November 2009, 09:18   #1
EmL
Junior Member
 
Join Date: Feb 2007
Posts: 21
FileName as a variable while compile time

I add a file while compilation with the file command. The File has a Format like PatchXYZ-12345.exe ... is it possible to extract the 12345 string while compiling and use it as a variable inside the script?
EmL is offline   Reply With Quote
Old 2nd November 2009, 13:03   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
You can't use it as a variable, since those operate at runtime. You can use it as a define (which operate at compiletime), but how to get the number I don't know. Perhaps make a bat file that passes both the filename and the scriptfile to the compiler? Not sure how to get a filename in a bat file either, though.
MSG is offline   Reply With Quote
Old 2nd November 2009, 13:58   #3
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
Take a look at the !searchparse command. For your example, you would use it like
code:
# ${AFile} = PatchXYZ-12345.exe
!searchparse ${AFile} PatchXYZ- Serial .exe Unused
# ${Serial} = 12345

I'm not sure how you are adding the PatchXYZ-12345.exe file to the compile, but if you would create a defined value for it, you can use that define in the !searchparse command without extra work.
code:
!define AFile PatchXYZ-12345.exe
File ${Afile}
!searchparse ${AFile} PatchXYZ- Serial .exe Unused
DetailPrint "${Serial} was compiled"

File "AnotherRelatedFile${Serial}.txt"

demiller9 is offline   Reply With Quote
Old 2nd November 2009, 14:33   #4
EmL
Junior Member
 
Join Date: Feb 2007
Posts: 21
Maybe i told not clearly. I have File (it is only one) which is located inside a folder and which is added to installer while compiling ... maybe:

c:\files\Patch12345.exe

I add the file via this command line ...
code:
File c:\files\*.exe

... to the installer.

How can i "scan" for the one filename inside c:\files and extract the 12345 from the File and put it inside a variable while compiling the script?
EmL is offline   Reply With Quote
Old 2nd November 2009, 14:51   #5
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
You'll probably need an external program to do this, as there are no NSIS commands that can do this as far as I know.
MSG is offline   Reply With Quote
Old 2nd November 2009, 17:55   #6
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
The wiki has an example showing how to call an external program when you compile your NSIS script:

http://nsis.sourceforge.net/Invoking...n_compile-time

The external program generates a file which is used when the main NSIS script is compiled.
pengyou is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast 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