Archive: Passing variable name to File


Passing variable name to File
I'm trying to pass a string to a function and have files added to the install package based on that string. For example,


Push "MyFileName.txt"
Call MyFunction


Function MyFunction

Exch $0

File $0 ; Add the file named "MyFileName.txt" to the install package
...
Do some other things
...

FunctionEnd


The install build croaks on the "File $0" line saying that file $0 is not found. I'm assuming that File doesn't replace the $0 with the string that I passed through the stack.

Is there any way to get File to work in this fashion? Or, do I have to hardcode all of the filenames for File?

Thanks.
-Tony

um, functions are used at run time on the end users computer, how would you expect your file to get there?

macros run at compile time...


Originally posted by Anders
um, functions are used at run time on the end users computer, how would you expect your file to get there?

macros run at compile time...
Ok, but the point still remains that the File command doesn't seem to allow variables to be passed.

For example, let's do it without a function.


Var MyFileName

StrCpy $MyFileName "MyFileName.txt"

File $MyFileName



Why can't something like this work?

-Tony

StrCpy is also runtime, the stuff starting with ! is compile time. File is special, its "both" runtime and compiletime


Ok. The macro method worked for it. Thanks for the suggestion:


!macro MyMacro FILE_NAME

File "${FILE_NAME}"
...
Do other things
...

!macroend


then


!insertmacro MyMacro "myfilename.txt"



-Tony