Archive: Label confusion?


Label confusion?
I have the following code that checks a variable for either the value 'microsoft' or 'oracle'. Depending on the value the code will jump to a label:


StrCmp $var_FL_DB_TYPE "microsoft" sqlserver oracle

sqlserver:
ExecWait '"osql.exe" -S SERVER -U USER -P PASS -n -i validate_osql.sql -b'

oracle:
ExecWait '"sqlplus.exe" USER/PASS@DATABASE @validate_sqlplus.sql'


I know for a fact that the value of var_FL_DB_TYPE is 'microsoft', but the oracle label ALWAYS gets executed. I've even tried removing the jump to oracle ref in the StrCmp line, but this line always gets executed!!

What am I doing wrong?

!include LogicLib.nsh

function myfunc
${If} "$var_FL_DB_TYPE" == "microsoft"
ExecWait '"osql.exe" -S SERVER -U USER -P PASS -n -i validate_osql.sql -b'
${Else}
ExecWait '"sqlplus.exe" USER/PASS@DATABASE @validate_sqlplus.sql'
${EndIf}
FunctionEnd


You need to jump over the 2nd label. Code isn't skipped just because there's a label above it.

StrCmp $var_FL_DB_TYPE "microsoft" sqlserver oracle
sqlserver:
ExecWait '"osql.exe" -S SERVER -U USER -P PASS -n -i validate_osql.sql -b'
Goto end
oracle:
ExecWait '"sqlplus.exe" USER/PASS@DATABASE @validate_sqlplus.sql'
end:

Though, if you want to make your "coding" life easy and avoid labels and relative jumps, try to use LogicLib :-)


Sure, although labels are rather useful if he ever adds in more database types :)


Thanks for this guys, both worked a treat.