tags:

views:

590

answers:

1

Hi there,

I'm using nsis for an installer of a webapplication. In one page of the wizard i want the user choice one of three checkboxes: each of them has to set two variables in different ways.

Here is the code i'm trying to run:

!define DATA_ONE data_one.zip !define DATA_TWO data_two.zip !define DATA_THREE data_three.zip

Function myfunc ... ${NSD_GetState} $RadioOne $1 ${NSD_GetState} $RadioTwo $2 ${NSD_GetState} $RadioThree $3

  ; The two variables i want to set
  Var /GLOBAL CUSTOMER_DATA    ; this should be a File (?)
  Var /GLOBAL LENGTH_POS       ; this is a string

  StrCpy $CUSTOMER_DATA ${DATA_ONE} ; default value
  StrCpy $LENGTH_POS ""

  ${If} $1 == ${BST_CHECKED}         
     StrCpy $CUSTOMER_DATA ${DATA_ONE}
 StrCpy $LENGTH_POS "3"
  ${endif}

  ${If} $2 == ${BST_CHECKED}     
     StrCpy $CUSTOMER_DATA ${DATA_TWO}
     StrCpy $LENGTH_POS ""
  ${endif}

  ${If} $3 == ${BST_CHECKED}     
     StrCpy $CUSTOMER_DATA ${DATA_THREE}
     StrCpy $LENGTH_POS ""
  ${endif}   

; here the line i've got the error
  File ${BUILD_DIR}/$CUSTOMER_DATA

...

FunctionEnd

When i try to run it i've got:

File: "./$CUSTOMER_DATA" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
  /oname=outfile one_file_only)

I presume the error is because the File i'm constructing isn't defined at compile time but only at runtime. Is it correct ? Should i use macro ? What is the more elegant way to solve this problem ?

A: 

If you know at compile time that only ONE of those files will be used in that installer, EVER, then you need to do some compile time magic with !defines and !ifdef and maybe !system (You can't use variables in the file command)

If the user/end user's machine is making the choice, then you need all 3 files included:

SetOutPath $instdir
${If} $somevar == 1
 File "file1"
${EndIf}
${If} $someothervar == 1
 File "file2"
${EndIf}
...
Anders