Joel
8th February 2003 19:04 UTC
Passing a !define value to a $0
Ok...
I'm trying to detect 15 files in the $SYSDIR...
I make this function:
Function FileSearch
ifFileExists $SYSDIR\$0 yay
MessageBox MB_OK|MB_ICONEXCLAMATION "No file here"
yay:
FunctionEnd
then, I have 15 !define's like this:
!define File1 "bla.dll"
To use'em in .onInit like this
Push ${File1}
Call FileSearch
It doesn't detect the file (The file is there), I think because the "Push" is not "Pushing" :weird: ....
any ideas, please.... Thanks !!! ;)
kichik
8th February 2003 19:11 UTC
You have forgot to Pop the value from the stack into $0 in the function.
dark_boy, the e-mail I have sent you failed. Please let me know how to contact you about the docs.
Joel
8th February 2003 19:32 UTC
Thanks KichiK, it works :p .... then, let me share this to all the
nsis users that they have to search for installed files (a lot of them):
!define FileDude "bla.dll"
!define FileSr "dummy.dll"
Function FindFile
Pop $9
ifFileExists $SYSDIR\$9 yay
MessageBox MB_OK|MB_ICONEXCLAMATION "$9 is not in this machine"
yay:
FunctionEnd
Function .onInit
Push ${FileDude}
Call FindFile
Push ${FileSr}
Call FindFile
FunctionEnd
About the mail: send it again, I change the email address... if not I post it here, ok?
kichik
8th February 2003 19:41 UTC
The problem with your function is that it doesn't abort the installation... What I would do is:
macro checkFile FILE
IfFileExists"$INSTDIR\${FILE}" +2
StrCpy$0 "$0, ${FILE}"
>!macroend
>Function .onInit
>!insertmacro checkFile "bla.dll"
>!insertmacro checkFile "dummy.dll"
>StrCmp $0 "" +3
MessageBox "Error! Can't find $0."
Abort
FunctionEnd
>
This way it will abort the installation and won't pop a seperate message box for every missing file but one message box with them all.
PM me your e-mail address, that would be best.
Joel
8th February 2003 19:55 UTC
Well, in my case... the installer search for a file, if is not the
in the machine, the installer has a section that the end-user can
download the file.... (Can't get the installer automatically
select that section :()
But great code, KichiK.... :p
virtlink
9th February 2003 09:36 UTC
Maybe I'm crazy (I'm sorry, I AM crazy!), but I tought that the last n threads were about the programmatically selection and deselection of sections.
This thread mentioned this archive page.