Programmer Guide/Shell Items/Table/TABLE Item Attributes: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
m (Text replace - "S_TOOLS-STx" to "{{STX}}")
Line 36: Line 36:
;<var>!EDITABLE</var>
;<var>!EDITABLE</var>


:The item attribute <code>!EDITABLE</code> indicates whether the respective field (column) of the table is editable when the table is connected to an S_TOOLS-STx dialog item <code>listview</code> control. You may both query the <code>!EDITABLE</code> attribute, and assign to it. By assigning to the <code>!EDITABLE</code> attribute of a column, you may at any time specify if the respective column may be edited by the user: Assigning <code>0</code> prevents editing, whereas any numeric value different from <code>0</code> allows for editing.
:The item attribute <code>!EDITABLE</code> indicates whether the respective field (column) of the table is editable when the table is connected to an {{STX}} dialog item <code>listview</code> control. You may both query the <code>!EDITABLE</code> attribute, and assign to it. By assigning to the <code>!EDITABLE</code> attribute of a column, you may at any time specify if the respective column may be edited by the user: Assigning <code>0</code> prevents editing, whereas any numeric value different from <code>0</code> allows for editing.


:The <code>!EDITABLE</code> attribute has the index of the respective column as its mandatory second argument.
:The <code>!EDITABLE</code> attribute has the index of the respective column as its mandatory second argument.

Revision as of 18:02, 5 April 2011

TABLE Item Attributes

Shell table attributes can be retrieved using the following syntax:

#value := $#table[!ATTRIBUTE]

You can retrieve the number of entries in a table using the following syntax:

#nEntries := $#table[]

Each table entry can also be queried as follows:

$#table[$#index, $#fieldid]

Returns the value of field fieldid (number or field name) of entry index (number)

$#table[$#index, !TAGGED]

Returns 1 if entry index is tagged and 0 if not

$#table[$#index]

Returns the value of table entry at this index in simple tables. For extended tables the return value depends on the mode: for extended tables in data-access mode, the value of all fields of the referenced entry are returned; the result depends on selected format (SHOW or WRITE); for extended tables in configuration mode, the configuration of the field index (number or field name). The format of the result is the same as for attribute !FIELD.

In addition, the following attributes are available:

!CHUNKSZ
The number of entries per memory chunk used when allocated memory runs out. This is the value passed to NEW table with the option /N=m.
!DIRECTORY
1 if table is a segment directory and 0 if not
!EDITABLE
The item attribute !EDITABLE indicates whether the respective field (column) of the table is editable when the table is connected to an STx dialog item listview control. You may both query the !EDITABLE attribute, and assign to it. By assigning to the !EDITABLE attribute of a column, you may at any time specify if the respective column may be edited by the user: Assigning 0 prevents editing, whereas any numeric value different from 0 allows for editing.
The !EDITABLE attribute has the index of the respective column as its mandatory second argument.
E.g. $#table[!editable,$#iField]
An optional third argument can be used to specify number of fields to set (if omitted, just the one field #iField is set).
Examples:
// query if the 3rd column of table #tab is editable
#txt := COND $#tab[!edit,2] == 0 ? 'is NOT' : 'IS'
um 'Column 2 (i.e. 3rd column) $#txt editable.'
// allow for the 3rd column (index 2) of table #tab to be edited
$#tab[!edit,2] := 1
// prevent its first column (index 0) from being edited
$#tab[!edit,0] := 0
// set the 2nd and 3rd columns to editable
$#tab[!edit,1,2] := 1
See the example script editabletable.sts for a complete example.
!EXTENDED
1 if table is an extended table and 0 otherwise.
!FIELDS
The !FIELDS attribute returns the number of defined fields (note that this is the same as !NCOL).
If specified with a field name or index (e.g. $#table[!FIELDS,$#fieldId]), then the configuration for that field is returned in the following format:

type name show showname scale format [mvalue msymbol]:Where the above values have the following meanings:

type numeric type id (0=undefined, 1=NAME, 2=STRING, 3=INTEGER, 4=NUMBER)
name field name
show 1 if field is included in show format
showname 1 if name is included in show format
scale show scaling factor for numeric types
format format string used for show
mvalue,

msymbol

missing value and
If the field does not exist, an empty string is returned.
If a field attribute is also specified (e.g. $#table[!FIELDS,$#fieldId,!ATTRIBUTE]), then the field's attribute value is returned. A list of field attributes are can be found here: Field Attributes
!HASFIELD
$#table[!hasfield,hugo] evaluates to 1 in case of table #table having a field (i.e. column) called "hugo" (for arbitrary values of "hugo"). It evaluates to 0 otherwise.
If you do not supply a "hugo", the expression will evaluate to 1 if the table has at least one column. If the table is completely devoid of columns, the expression evaluates to zero.
!INTFORMAT
C-format string for integer fields. Must be a valid format for one integer number.
!IO
The index of selected I/O format (0 or 1):
0 all fields of an entry are stored; fields are separated by the list-separator (!LSEP)
1 the index and the value of assigned fields are stored; index and value are separated by the value-separator (!VSEP) and fields are separated by the list-separator (!LSEP).
Note: the values of the attributes !IO, !LSEP, !VSEP, !NUMFORMAT and !INTFORMAT can be modified with the command SET table FORMAT.
!LSEP
The list-separator string, used to separates fields.
!MEMORY
Returns the size of the pre-allocated memory in bytes and the amount of memory currently being used in bytes in the following format:
reserved used
This attribute is currently only supported by extended and parameter tables (-1 is returned by other table types).
!NCOL
The number of columns
!NROW
The number of rows ((Note that this is the same as !FIELDS).
!NUMFORMAT
The C-format string for numeric fields. This must be a valid format for one float number.
!PARAMETER
1 if table is a parameter table (numeric fields only) and 0 if not
!RANGED
1 if only tagged entries are visible and 0 if all entries are visible
!SHELL
Id of the shell creating the table item (8 digit hex number)
!SORT
The table sort mode in the following format:
C F1 O1 F2 O2 F3 O3 ...
where C is 0 or 1 indicating that sorting is case-insensitive (0) or case-sensitive1;
where F1 is the field number of the first sort field (the "main key"), and O1 indicates whether for this key the table will be sorted in ascending order (0) or in descending order(1); where F2/O2 is the field number and the sort order for the second sort key; and so on. There will be as many "Fn On" pairs as there are sort keys.
If the table is unsorted, the "!SORT" attribute will be empty.
!STARTZ
The number of entries allocated on initialization. This is the value passed to NEW table with the option /I=n.
!USERS
Number of linked items using the table item.
!VSEP
The value-separator string, used to separate the field name from the field value.

Field Attributes

Table field attributes are queried using the following syntax:

$#table[!FIELD,$#fieldid,attribute]

The following attributes are available:

ALIGN

0 if the field's text is left aligned, 1 if it is right aligned.

EDITABLE

1 if this field is editable, 0 otherwise.

FORMAT

Returns the field's show format string (as set using the SET table CONFIG fieldid command).

HEADER

The field's text header, displayed at the top of the column in an attached listview.

MMODE

1 if missing value replacement is enabled, 0 otherwise.

MSYMBOL

The symbol used to represent missing values in a listview.

MULTIROW

The table field attribute !MULTIROW can be used to query and set the "multirow" property of a table row. If set to '1', the table field will support multirow entries.

MVALUE

The numerical value of a values to be recognised as 'missing'.

NAME

Returns the name (id) of the field.

SCALE

The value numerical fields are multiplied with when displayed in the show format. See SET table CONFIG for details.

SORTABLE

1 if clicking the associated column in a listview will sort the column, or 0 to disable column sorting.

TYPE

Returns the field type: INT|NUM|STRING|NAME

VDEFAULT

Returns the value list default value, if defined.

VFIELD

Returns the index of the value field in the value list table (if specified). See the table item command CONFIG for details).

VISIBLE

1 if the field is visible in an attached listview, 0 if it is hidden.

VONLY

1 if only values in the associated value table are permissible, 0 otherwise.

VTABLE

The name of the value list table (if specified). See SET table CONFIG for details.

VUSERDEFAULT

The table field attribute VUSERDEFAULT returns the 1 if the SET table CONFIG parameter setuserdefault was set to ON for this field.

WIDTH

Returns the width of the column in characters (this value is used by an associated listview).

Navigation menu

Personal tools