<@ASSIGN>Syntax<@ASSIGN NAME=name VALUE=value [SCOPE=myscope]> DescriptionAssigns a value to a variable. If the specified variable does not yet exist, it is created. For more details on variables, see Chapter 7, "Using Variables," in the User's Guide. The value may be text or an array. If the variable being assigned to exists and contains an array, this tag also lets you set the values of individual elements in that array. <@ASSIGN> can assign an array (or array section) to a variable, or to another array (or array section). Array assignments require that the source and target arrays (or array sections) have the same dimensions. The NAME attribute specifies the name of the variable to assign the value to. The following restrictions apply to the value specified in the NAME attribute:
Variable names are case insensitive; for example, myVar is the same variable as MYVAR and MyVaR. If you are assigning to an array variable element or section, the name includes the element or section specification specified within square brackets as [rownumber,colnumber], with an asterisk indicating all rows or all columns; for example, NAME=myArray[1,2] or NAME=myArray[*,3]. The VALUE attribute specifies the value to assign to the variable. If you are assigning to an array section, the value specified here must match the dimensions of the array variable specification in NAME.
The SCOPE attribute specifies the name of the scope in which to assign the variable. If this attribute is omitted, the following steps are taken to determine the scope in which the assignment takes place:
For more information, see "defaultScope".
Examples<@ASSIGN NAME="foo" VALUE="123456" SCOPE="user"> This example assigns the value "123456" to the variable foo in user scope. <@ASSIGN NAME="foo2" VALUE="abcdef"> This example either assigns the value "123456" to the variable foo2 in local, user, domain or system scope, depending on the first instance of foo2 that Tango Server encounters; or, if it does not exist, it creates a new variable called foo2 in default scope and assigns the value "123456" to it. <@ASSIGN NAME="foo3" SCOPE="user" VALUE="<@ARRAY ROWS=5 COLS=3>"> This example assigns an array of five rows and three columns to the user variable foo3. <@ASSIGN NAME="foo4" SCOPE="user" VALUE="<@POSTARGNAMES>"> This example assigns the evaluated value of the meta tag <@POSTARGNAMES> (an array) to the user variable foo4. <@ASSIGN NAME="initValue"
VALUE="1,2,3;4,5,6;7,8,9;a,b,c;d,e,f;g,h,i">
This example creates an array variable called array2, initializes it, and then creates a new one-column array variable (foo5), containing all the values in column 2 of array2. <@ASSIGN NAME="orders[1,*]" VALUE="@@myOrder" SCOPE="user"> This example puts the single-row array stored in the myOrder variable into the first row of the orders user variable, replacing the existing values. This assignment generates an error if myOrder is not an array, contains more than one row, or does not contain the same number of columns as the orders array. <@ASSIGN NAME="zips" VALUE="@@orders[*,4]" SCOPE="local"> Assigns to the local variable zips a one-column array of all the values from column 4 of the orders array. <@ASSIGN NAME="curr_cust" VALUE="@@orders[1,1]"> Assigns the value from the first cell in the first row of the orders array to the curr_cust variable, using default scoping rules. <@ASSIGN NAME="race_results[*,3]" VALUE="<@VAR NAME='new_results[*,1]'>"> Copies the values from column 1 of the new_results array to the third column of the race_results array. Both arrays must contain the same number of rows, or an error occurs. See Also |
Copyright © 1998, Pervasive Software Inc. All rights reserved.