With
CreateStructure you can create a structured
GuiXT variable.
Example
CreateStructureV[customer] account name1 name2 city country
The variable
V[customer]
is created as a structured variable. Its components are:
V[customer.account],
V[customer.name1],
V[customer.name2],
V[customer.city],
V[customer.country].
Other component names such as
ClearV[customer] are not allowed and will produce a syntax error
message.
With
Clear
V[customer]you can reset all components.
The string
representation
"&V[customer]"uses the JavaScript object notation ("JSON").
Example:
GuiXT
Set V[customer.account] "1000"
Set V[customer.name1] "M&S GmbH"
Set V[customer.name2] "Winter tires"
Set V[customer.city] "London"
Set V[customer.country] "UK"
The string representation &V[customer] is as follows: {
"account" : "1000" , "name1" : "M&S GmbH" , "name2" : "Winter
tires"
, "city" : "London" , "country" : "UK" }
This
adds all components of another structured variable or table
variable (CreateTable).
Example:
CreateStructure
V[customerrow]include=V[customer]
selected This
defines the following components: account, name1, name2, city, country,
selected
The
include=
option may be used multiple times.
Transferring values between structures and tables
If V[x] and V[y] are structured variables or table variables, you can assign the values with
SetV[x] "&V[y]".
The source V[y] is converted into JSON format and then assigned to the target structure or table. The following rules apply:
Columns with the same name: The values of columns with the same name are transferred. All other columns remain empty.
Examples:
GuiXT
CreateStructure V[x] a b c
CreateStructure V[y] b d
Set V[x.a] "a"
Set V[x.b] "b"
Set V[x.c] "c"
Set V[y] "&V[x]"
Now V[y.b] has the value "b", and V[y.d] is empty.
GuiXT
CreateTable V[tabx] a b c
CreateTable V[taby] b d
Set V[tabx.a.1] "a1"
Set V[tabx.b.1] "b1"
Set V[tabx.c.1] "c1"
Set V[tabx.a.2] "a2"
Set V[tabx.b.2] "b2"
Set V[tabx.c.2] "c2"
Set V[taby] "&V[tabx]"
Now V[taby.b.1] and V[taby.b.2] have the values "b1" and "b2". Column d, i.e. V[taby.d.1] and V[taby.d.2], is empty.
Assigning a structure to a table: The table receives only row 1, with the values of the source structure according to the rules in 1.
Assigning a table to a structure:
If the table is empty, the target structure is set to its initial values.
If the table has exactly one row, the target structure receives the values of this row according to the rules in 1.
If the table has more than one row, the target structure is set to its initial values and an error message is shown in the script window and in the Script Editor. Processing continues.