Var can now be used in sections and functions, but only with the /GLOBAL flag
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4211 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
f5105a50b1
commit
68dc7f9f7e
4 changed files with 36 additions and 7 deletions
|
@ -10,14 +10,17 @@ User variables can be declared with the \R{var}{Var} command. You can use these
|
||||||
|
|
||||||
\S2{var} Var
|
\S2{var} Var
|
||||||
|
|
||||||
\c var_name
|
\c [/GLOBAL] var_name
|
||||||
|
|
||||||
Declare a user variable. Allowed characters for variables names: [a-z][A-Z][0-9] and '_'. Variables cannot be declared in sections or functions.
|
Declare a user variable. Allowed characters for variables names: [a-z][A-Z][0-9] and '_'. All defined variables are global, even if defined in a section or a function. To make this clear, variables defined in a section or a function must use the /GLOBAL flag. The /GLOBAL flag is not required outside of sections and functions.
|
||||||
|
|
||||||
\c Var example
|
\c Var example
|
||||||
\c
|
\c
|
||||||
\c Function testVar
|
\c Function testVar
|
||||||
|
\c Var /GLOBAL example2
|
||||||
|
\c
|
||||||
\c StrCpy $example "example value"
|
\c StrCpy $example "example value"
|
||||||
|
\c StrCpy $example2 "another example value"
|
||||||
\c FunctionEnd
|
\c FunctionEnd
|
||||||
|
|
||||||
\S1{varother} Other Writable Variables
|
\S1{varother} Other Writable Variables
|
||||||
|
|
|
@ -40,6 +40,14 @@ Section "Dummy Section" SecDummy
|
||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
|
Section "Another Section"
|
||||||
|
|
||||||
|
Var /GLOBAL "AnotherVar"
|
||||||
|
|
||||||
|
StrCpy $AnotherVar "test"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
; Uninstaller
|
; Uninstaller
|
||||||
|
|
||||||
|
|
|
@ -5329,10 +5329,28 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
// Added by ramon 3 jun 2003
|
// Added by ramon 3 jun 2003
|
||||||
case TOK_DEFVAR:
|
case TOK_DEFVAR:
|
||||||
{
|
{
|
||||||
SCRIPT_MSG("VAR \"%s\"\n",line.gettoken_str(1));
|
int a=1;
|
||||||
int res = DeclaredUserVar(line.gettoken_str(1));
|
|
||||||
if (res != PS_OK)
|
if (!strcmpi(line.gettoken_str(1),"/GLOBAL"))
|
||||||
return res;
|
{
|
||||||
|
a++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (build_cursection)
|
||||||
|
{
|
||||||
|
if (a==1)
|
||||||
|
{
|
||||||
|
ERROR_MSG("Var: currently, only global variables can be defined.\n");
|
||||||
|
PRINTHELP();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SCRIPT_MSG("Var: \"%s\"\n",line.gettoken_str(a));
|
||||||
|
|
||||||
|
int res = DeclaredUserVar(line.gettoken_str(a));
|
||||||
|
if (res != PS_OK)
|
||||||
|
return res;
|
||||||
|
|
||||||
}
|
}
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ static tokenType tokenlist[TOK__LAST] =
|
||||||
// Added by ramon 23 May 2003
|
// Added by ramon 23 May 2003
|
||||||
{TOK_ALLOWSKIPFILES,"AllowSkipFiles",1,0,"(off|on)",TP_ALL},
|
{TOK_ALLOWSKIPFILES,"AllowSkipFiles",1,0,"(off|on)",TP_ALL},
|
||||||
// Added by ramon 3 jun 2003
|
// Added by ramon 3 jun 2003
|
||||||
{TOK_DEFVAR,"Var",1,0,"VarName",TP_GLOBAL},
|
{TOK_DEFVAR,"Var",1,1,"[/GLOBAL] var_name",TP_ALL},
|
||||||
// Added by ramon 6 jun 2003
|
// Added by ramon 6 jun 2003
|
||||||
{TOK_VI_ADDKEY,"VIAddVersionKey",2,1,"/LANG=lang_id keyname value",TP_GLOBAL},
|
{TOK_VI_ADDKEY,"VIAddVersionKey",2,1,"/LANG=lang_id keyname value",TP_GLOBAL},
|
||||||
{TOK_VI_SETPRODUCTVERSION,"VIProductVersion",1,0,"[version_string_X.X.X.X]",TP_GLOBAL},
|
{TOK_VI_SETPRODUCTVERSION,"VIProductVersion",1,0,"[version_string_X.X.X.X]",TP_GLOBAL},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue