Old 25th January 2011, 20:53   #1
dullboy
Junior Member
 
Join Date: Jan 2011
Posts: 6
A question regarding File command

I tried to use File command as,
File /nofatal $1

NSIS couldn't find $1 but if I print out $1, I check the file does exist. If I use File as,
File /nofatal "C:\temp\test.txt" (assume $1="C:\temp\test.txt"),
then it works. What is wrong with File /nofatal $1? Thanks.
dullboy is offline   Reply With Quote
Old 25th January 2011, 21:09   #2
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 454
The FILE command is used during the compile time to compress the files into the setup program. $1 does not have a value during compile time, so the file you want to point to later cannot be put into the setup program.

During execution, FILE $1 would try to extract the file named by "$1" to the current working directory; unfortunately it will fail because the compile time function won't have worked.
demiller9 is offline   Reply With Quote
Old 25th January 2011, 21:46   #3
dullboy
Junior Member
 
Join Date: Jan 2011
Posts: 6
Quote:
Originally Posted by demiller9 View Post
The FILE command is used during the compile time to compress the files into the setup program. $1 does not have a value during compile time, so the file you want to point to later cannot be put into the setup program.

During execution, FILE $1 would try to extract the file named by "$1" to the current working directory; unfortunately it will fail because the compile time function won't have worked.
I see. Thanks so much for your explanations!
dullboy is offline   Reply With Quote
Old 25th January 2011, 21:54   #4
dullboy
Junior Member
 
Join Date: Jan 2011
Posts: 6
Quote:
Originally Posted by demiller9 View Post
The FILE command is used during the compile time to compress the files into the setup program. $1 does not have a value during compile time, so the file you want to point to later cannot be put into the setup program.

During execution, FILE $1 would try to extract the file named by "$1" to the current working directory; unfortunately it will fail because the compile time function won't have worked.
I have one more question. Since File command is used during the compile time. I wonder if there is any similar command which could be used during the run time? Thanks.
dullboy is offline   Reply With Quote
Old 25th January 2011, 22:30   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,382
Use the /oname= (out name) switch.

Stu
Afrow UK is offline   Reply With Quote
Old 25th January 2011, 23:22   #6
dullboy
Junior Member
 
Join Date: Jan 2011
Posts: 6
Quote:
Originally Posted by Afrow UK View Post
Use the /oname= (out name) switch.

Stu
Could you explain what could be done by using /oname that could NOT be done by using /nofatal? Basically, my trouble is that the file after the command File doesn't exist in compile time. So File command always complains file not found. I wonder if there is any way to execute File command or similar command in run time since the output file can only be determined in run time. Thanks.
dullboy is offline   Reply With Quote
Old 26th January 2011, 06:44   #7
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,894
Quote:
Originally Posted by dullboy View Post
Could you explain what could be done by using /oname that could NOT be done by using /nofatal? Basically, my trouble is that the file after the command File doesn't exist in compile time. So File command always complains file not found. I wonder if there is any way to execute File command or similar command in run time since the output file can only be determined in run time. Thanks.
You're mistaken: You cannot make an installer that only contains file XYZ if some condition is met. If you need it installed at ANY point, the installer MUST have it compressed inside.

What you probably want is this:
${If} (some condition here)
File Yourfile.ext
${EndIf}

The above will always compile Yourfile into the installer, but it will only be extracted (at runtime) if the condition is met.


Or if your problem is that you want to include files dynamically (to make different installers depending on what files you have on your compiling PC), you'll probably have to use this:
File YourDynamicFolder\*.*
MSG is offline   Reply With Quote
Old 26th January 2011, 16:57   #8
dullboy
Junior Member
 
Join Date: Jan 2011
Posts: 6
Quote:
Originally Posted by MSG View Post
You're mistaken: You cannot make an installer that only contains file XYZ if some condition is met. If you need it installed at ANY point, the installer MUST have it compressed inside.

What you probably want is this:
${If} (some condition here)
File Yourfile.ext
${EndIf}

The above will always compile Yourfile into the installer, but it will only be extracted (at runtime) if the condition is met.


Or if your problem is that you want to include files dynamically (to make different installers depending on what files you have on your compiling PC), you'll probably have to use this:
File YourDynamicFolder\*.*
No, my question is that the files to be extracted do not exist before installation and they will be generated during installation. Is there any way I can do that? Thanks.
dullboy is offline   Reply With Quote
Old 26th January 2011, 17:47   #9
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,382
You need to think to yourself how you would go about generating these files? What will the files contain? To write to a file at run time, use FileOpen, FileWrite and FileClose.

Stu
Afrow UK is offline   Reply With Quote
Old 26th January 2011, 18:40   #10
dullboy
Junior Member
 
Join Date: Jan 2011
Posts: 6
I resolved the problems. Thanks for you guys' suggestions. Is there any way to give you guys credits? :-)
dullboy 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