Was this helpful?
Definition Attribute
Data Type: StringObject
4GL Access: RW
This attribute specifies the values that this value definition defines, specified as keyword: expression.
keyword
Identifies how the expression is to be evaluated
Note:  keyword is used here as a syntax element, not to be confused with the ValueDefinition.Keyword attribute.
Supported keywords (grouped by type) are:
list: 'SQL', 'LIST', 'IN', 'ARRAY', 'DSV' or 'FILE', 'XML', 'STRING', 'LPROC'
range: 'RANGE'
single value: 'VALUE'
dynamic: 'PROC', 'LPROC'
expression
Defines the exact way the type of evaluation will be applied. Expressions can contain substitutable elements.
The format of the expression depends on the keyword, but the output of the evaluation must for all list-typed keywords be mappable to a choicelist. In practice this generally means evaluating to either a single element per entry or four or more correctly ordered elements per entry. The elements map to enumvalue, enumtext, enumdisplay, enumbitmap db or file handle, enumsubtext[1].value, enumsubtext[2].value, and so on.
IN: a valid SQL IN clause. For example:
('jan','feb','mar')
SQL: a valid SQL select or a tablename.attribute expression (the first example is equivalent to "select distinct 0, ai_name, ai_name, '' from airline"). Examples:
airline.ai_name
select distinct 0, ai_code, ai_name, '', ai_country, ai_slogan from airline
ARRAY: a set of constants, in-scope variables, and array entries. The array to load data from is identified by the first array variable name encountered. Examples:
business_tf[].name
0, airlines[].code, airlines[].name, airlines[].logo
FILE,DSV: has the following format:
filename layout
filename is a valid source file name ($envvar/…; file://...), where envvar is an environment variable.
layout follows the Ingres COPY statement syntax, but is restricted to the 'c' type, and has an extension for postprocessed values, thus:
(colname=c0delim | colname=cN [, colname=c0delim | colname=cN]) [enumattribute=ppexpr [,enumattribute=ppexpr]]
where delim is any supported COPY delimiter, and ppexpr is any valid expression involving the colnames listed.
In the following example, the file contents will be read, and for each line in the file, the 32 characters following the first comma will become the enumtext, and the text preceding the first comma will be combined with the enumtext value to provide the enumdisplay:
(type=c0comma, enumtext=c32, rem=c0nl) enumdisplay=type+':'+enumtext
STRING: has the following format:
varname layout
The STRING keyword is intended only for situations where file contents are already in memory, in a StringObject (simple text lists are handled by IN). Accordingly, its format requirements are the same as for FILE.
varname is an in-scope StringObject variable containing the values to be processed
layout follows the FILE layout format defined above.
XML: has the following format:
filename layout
filename is a valid xml source file name ($envvar/…; file://...), where envvar is an environment variable
layout maps list attribute to XML variable, and has an extension for postprocessed values, thus:
(enumattribute=xmlname [,enumattribute=xmlname])
[enumattribute=ppexpr [,enumattribute=ppexpr]]
ppexpr is any valid expression involving the enumattributes and xmlnames. For example:
(enumtext=airlinecode) enumdisplay=enumtext+':'+airlinename
LIST: has the following format:
listname condition
listname is an in-scope choicelist variable containing an existing list
condition is an 4GL condition valid in the scope (except that "enumtext", "enumvalue" should be used rather than the full variable name) that can be applied to each list item in turn to determine if it forms part of the required output list. For example:
lastmonth_invoices tooltiptext not like '%unpaid%'
RANGE: has the following format:
Between lowvalue and highvalue [(defaultvalue)]
which must define a valid SQL range between -1 and 2**16-1. For example:
between 0 and 16 (2)
VALUE: a valid SQL value. Examples:
date('now')-'7 days'
8
PROC,LPROC: has the following format:
procedure(parameters)
procedure is the name of an in-scope 4GL procedure that returns either a choicelist (if LPROC is specified) or a validation outcome (if PROC is specified).
parameters is the in-scope parameter expression defining the parameter values that the procedure requires.
The procedure being invoked must have the parameters specified, plus a parameter 'parameters' of type varchar(256), and a local variable declared as type I_Eval (the variable name is irrelevant). I_Eval is a built-in class that will automatically parse and apply the parameter string to the relevant variables in the procedure. Example:
airlinecodes(country='uk', airport='LHW')
Expressions can contain substitutable elements. The following are supported:
in-scope variables, using the format &(), for example:
select distinct &(column_name) from &(table_name)
taggedvalues, using the format &((tag)), for example:
select distinct &((db_column_name)) from &((db_table_name))
List expressions must evaluate either to one element, or to a set of four or more elements in the correct order to map to the list's enumvalue, enumtext, enumdisplay, enumbitmap handle, enumsubtext[1], and so on. Where evaluation produces a single element, the element is used for the enumtext and enumdisplay values, enumbitmap is left null, and enumvalue is given an incrementing count.
List formats are intentionally simple (with the exception of FILE/DSV); complex list creation is for the developer to code. File (non-XML) handling takes advantage of the existing COPY syntax, without which it would be too inflexible to be useful. The postprocessing element enables efficient manipulation of the raw values during uptake and specification of non-file values.
Last modified date: 06/25/2024