GRIDPLUS - Reading And Setting The Value of GRIDPLUS Widgets
Home Reference Manpage Examples Download License Contact

Reading And Setting The Value of GRIDPLUS Widgets

The values of the GRIDPLUS widgets are stored in a global array with a null name.

For Example:

global {}

Note: See the appropriate command/mode reference page for reading the values of specific widgets.

The recommended method to set all GRIDPLUS widget values is to use the either gpset or gpmap commands.

There is also a command to unset GRIDPLUS widget values (gpunset), though I have yet to find a use for it!!

It is intended that GRIDPLUS widget values would normally be unset using the GRIDPLUS clear command/mode.

Using The gpset Command

The gpset command can be used to set one or more GRDIDPLUS widget values. It can also be used to set the value of non-GRIDPLUS widgets if they have an associated variable which is an element in the array with a null name.

There are two possible syntax options:-

gpset item value

...or...

gpset {item value ... ...}

Note: The GRIDPLUS tablelist, text and tree widgets can only be set using the first of the above syntax options.


Checkbutton

For GRIDPLUS Checkbutton widgets the array element has the same name as the widget: Thus the value of ".savings" in a Checkbutton Grid called ".account" is referenced as "$(.account,savings)".

The value will be either "0" (zero) when "deselected" or "1" when "selected".

For Example:

gpset .account,savings 1


Entry

For GRIDPLUS Entry widgets the array element has the same name as the widget: Thus the value of ".name" in an Entry Grid called ".person" is referenced as "$(.person,name)".

For Example:

gpset .person,name "Mary Smith"


Radiobutton

For GRIDPLUS Radiobutton widgets the array element has the same name as the Radiobutton Grid: Thus the value of the ".gender" Radiobutton Grid is referenced as "$(.gender)".

The value will be that specified for the currently selected radiobutton. If no button is selected the value will be null.

For Example:

gpset .gender female


Tablelist

For GRIDPLUS Tablelist widgets the array element has the same name as the widget frame: Thus the value of ".accounts" is referenced as "$(.accounts)".

Note: For the GRIDPLUS tablelist only the value of the selected row is stored in the array. If no row is selected there is no entry in the array.

The value of the tablelist is a list. Each element in the list corresponds to a row in the tablelist. Each row element is itself a list, where each element in the list corresponds to a column in the row.

For Example:

gpset .accounts {
   {000001 {Fred Smith} 120.45}
   {000004 {Mary Jones} 5156.67}
   {000003 {Susan Freeman} -987.03}
   {000002 {David Miles} 10654.84}
}


Text

For GRIDPLUS Text widgets the array element has the same name as the widget frame: Thus the value of ".notes" is referenced as "$(.notes)".

For Example:

gpset .mytext "This is some text\nThis is another line"


Tree

For GRIDPLUS Tree widgets the array element has the same name as the widget frame: Thus the value of ".mytree" is referenced as "$(.mytree)".

Note: For the GRIDPLUS tree only the value of the selected node is stored in the array. If no node is selected there is no entry in the array.

The value of the tree is a list. Each element in the list corresponds to a node in the tree. Each row element is itself a list, which contains the full hierarchic name of the node together with any required node options (See Reading and Setting GRIDPLUS Tree Values).

For Example:

gpset .mytree {
   /File1
   {/Dir1 +}
   {/Dir1/Dir2 +}
   /Dir1/Dir2/File2
   /Dir1/Dir2/File3
   /Dir1/File4
   /Dir1/File5
   /File6
}


Setting Multiple Multiple Values With One Command

It is possible to the values of several widgets with one gpset command.

For Example:

gpset {
   .account,savings 1
   .person,name     "Mary Smith"
   .gender          female
}

Note: tablelist , text and tree widgets cannot use the "multiple set" facility of gpset.

Using The gpmap Command

The gpmap command can be used to set one or more GRDIDPLUS widget values by mapping a list of GRIDPLUS widget data names to a correspnding list of values. It can also be used to set the value of non-GRIDPLUS widgets if they have an associated variable which is an element in the array with a null name.

Syntax:-

gpmap {item ...} {value ...}

The list of items must have the same number of elements as the list of values.

For Example:

gpmap {
   .account,savings
   .person,name
   .gender
} {
   1
   "Mary Smith"
   female
}

This could be particularly useful when using the result of a database access command/procedure to populate all or part of a screen.

For Example:

gpmap {
   .phone,firstname
   .phone,lastname
   .phone,phone
   .phone,department
} [mk::get db.data![lindex $(.phonelist) 0] firstname lastname phone department]

Note: The GRIDPLUS tablelist , text and tree widgets should not be set using this command.

Using The gpunset Command

The gpunset command can be used to unset one or more GRDIDPLUS widget values. It can also be used to unset the value of non-GRIDPLUS widgets if they have an associated variable which is an element in the array with a null name.

Syntax:-

gpunset item ...

Example:

gpunset .person,name .person,gender


Copyright © 2005
Adrian Davis.