Skip to content
⌘ NSIS Forum Archive

Goto's based on string from registry

5 posts

Mark_Ive#

Goto's based on string from registry

Hi all,
I want to jump to different sections based on registry key i thought the following would work...but it compiles then fails when i run it...im guessing it clears the labels on compile because it thinks they are not used ?? any ideas anyone the code is pretty self explanatory

Section "getversion"
readregstr $1 HKEY_LOCAL_MACHINE "Software\mycompany\myapp\" "Version"
goto $1
V2.3.0:
Call 2.3.1
V2.3.1:
Call 2.3.2
V2.3.2:
Call 2.3.3
V2.3.3:
Call 2.3.4
V2.3.4:
Call 2.3.5
V2.3.5:
Call 2.3.6
V2.3.6:
Call 2.3.7
V2.3.7:
Call DONE
SectionEnd
Guest#
Mark_Ive,

i didn't test it yet, but i think what you said is right: it might delete labels at compile because of no use.
Try to do it differently:

in NSIS: create seperate functions for the commands to execute at different versions and use a user variable to indicate whether or not to execute the function, eg:
function v2.1.0
Pop $0
StrCmp $0 "1" Continue210
Return
Continue210:
"commands..."
functionend

Now visit all functions in .oninit with the parameter 0 of course. Now it should be possible to use any function at runtime. Again, i didn't test it yet, so i'm not completely sure, but you could try it.

Or create a NSISdll that does the job, depending on an argument or a by reading a user variable.

Good luck,
greetz,
Hendri.
dTomoyo#
Mark_Ive,

my style of sample code...

Section "GetVersion" 
ReadRegStr $1 HKEY_LOCAL_MACHINE "Software\mycompany\myapp\" "Version"
  StrCmp $1 "2.3.0" v230
  StrCmp $1 "2.3.1" v231
  StrCmp $1 "2.3.2" v232
  StrCmp $1 "2.3.3" v233
  StrCmp $1 "2.3.4" v234
  StrCmp $1 "" InstError Done
InstError:
  ...
  Goto Done
v230:
  Call v233_commands
  Goto Done
v231:
  Call v233_commands
  Goto Done
v232:
  Call v233_commands
  Goto Done
v233:
  Call v233_commands
  Goto Done
Done:
SectionEnd