Archive: Cannot Figure out Spaces in Variable File


Cannot Figure out Spaces in Variable File
I feel like I have read the whole internet and tried this in every possible combination. I feel confident I am missing the one obvious solution.

I have a variable $jurisdiction that has spaces. It is part of a path that looks like the first line below. It seems that no matter where I put the quotes and which type I use, it will not find the file. How do I put a variable string with spaces into the File to put?

;File "temp_OK_specific\Region_1\Alfalfa County\Globals.gdx"
File "temp_OK_specific\Region_1\$jurisdiction\Globals.gdx"
File 'temp_OK_specific\Region_1\"$jurisdiction"\Globals.gdx'
File "temp_OK_specific\Region_1\"$jurisdiction"\Globals.gdx"
File "temp_OK_specific\Region_1\'$jurisdiction'\Globals.gdx"

http://forums.winamp.com/showthread.php?t=365044


That actually makes perfect sense. Thank you. I mean, it is disappointing because that would have saved about 2000 conditional statements, but it is crystal clear.

Is there some clever have the contents of a droplist build part of a path? Other than conditionally.

${if} $jurisdiction == "Alfalfa County"
File temp_OK_specific\Region_1\Alfalfa_Co\Globals.gdx

Are you simply looking for this?
!define Client "Alfalfa County"
File "temp_OK_specific\Region_1\${Client}\Globals.gdx"


Thanks for your time. I tried various forms of this without success.

What I am trying to do, is have the user select from "A County" and "B County" in a droplist and then set the File to "path/A County/file.gdx". As it stands, I can sucessfully do Get_Text to determine what they selected then use conditional statements to build the path statically. I would love to put what they select, say "A County", directly into the path without to much logic, but the space seems to cause a problem I cannot overcome.

Here is the code:


Function dialogSelectJurisdiction

nsDialogs::Create 1018
Pop $dialogSelectJurisdiction

${If} $dialogSelectJurisdiction == error
Abort
${EndIf}

!insertmacro MUI_HEADER_TEXT "Templates - " "Selecting Jurisdiction"

${NSD_CreateLabel} 15u 8u 261u 19u "Please choose your response jurisdiction."
Pop $dialogSelectJurisdiction_label

${NSD_CreateDropList} 12u 30u 140u 23u ""
Pop $dialogSelectJurisdiction_selection

; Based on Region
${if} $region_1 == ${BST_CHECKED}
${NSD_CB_AddString} $dialogSelectJurisdiction_selection "Alfalfa County"
${NSD_CB_AddString} $dialogSelectJurisdiction_selection "Texas County"
${NSD_CB_SelectString} $dialogSelectJurisdiction_selection "Alfalfa County"
${elseif} $region_2 == ${BST_CHECKED}
${NSD_CB_AddString} $dialogSelectJurisdiction_selection "City of Stillwater"
${NSD_CB_AddString} $dialogSelectJurisdiction_selection "Osage County"
${NSD_CB_SelectString} $dialogSelectJurisdiction_selection "City of Stillwater"
${endif}

nsDialogs::Show

FunctionEnd

Function dialogSelectJurisdictionLeave

${NSD_GetText} $dialogSelectJurisdiction_selection $jurisdiction

FunctionEnd

; Oklahoma Region
${if} $region_1 == ${BST_CHECKED}
File temp_OK_specific\Region_1\0000005Z.CSI
${if} $jurisdiction == "Alfalfa County"
File temp_OK_specific\Region_1\Alfalfa_Co\Globals.gdx
${elseif} $jurisdiction == "Texas County"
File temp_OK_specific\Region_1\Texas_Co\Globals.gdx
${endif}
${elseif} $region_2 == ${BST_CHECKED}
File temp_OK_specific\Region_2\0000005Z.CSI
${if} $jurisdiction == "City of Stillwater"
File temp_OK_specific\Region_2\Stillwater\Globals.gdx
${elseif} $jurisdiction == "Osage County"
File temp_OK_specific\Region_2\Osage_Co\Globals.gdx
${endif}
${endif}

You can do it like that, or with sections or labels, but you can't extract a file without hardcoding its source path, so there aren't any shortcuts here that I can think of. You could use a zip file, then you could use variables for extraction, e.g. with Nsisunz plugin.


If you don't like the zip idea, this can be an alternative to stacking up conditional statements:

!define NUM_SECTIONS X ;total number of sections
Section /o "Alfalfa County" ; section name = droplist string
File temp_OK_specific\Region_1\Alfalfa_Co\Globals.gdx
SectionEnd
...

You can move the sections to a .nsh so they don't clutter up the script.
To select the appropriate section based on droplist selection:
StrCpy $0 0
SelectSectionLoop:
SectionGetText $0 $1
StrCmp $1 $jurisdiction 0 +5
SectionGetFlags $0 $1
IntOp $1 $1 | 1
SectionSetFlags $0 $1
Goto SelectSectionEnd
IntOp $0 $0 + 1
IntCmp $0 ${NUM_SECTIONS} 0 SelectSectionLoop
SelectSectionEnd: