|
Forms | Field |
FIELD
command displays the current value of variables on the
screen and provides extensive capabilities for
editing and validating data values.
A FIELD
command without any clauses displays the data at a
default position on the screen using the dictionary definitions to control the
prompt, the data format and the edit rules.
When defining custom screens and additional edits, much of the work done by the screen designer is in specifying the various clauses to do with this command. Clauses specified at the Form, Screen, Page and Group levels to apply to all fields within that level.
It is used in record screens for record variables, in table
screens for table columns and in any screen for temporary variables.
The same variable can be referenced by multiple
FIELD
commands on a screen.
The command is executed when the flow of control moves to it. The sequence of the commands determines the flow of control and this is the sequence followed by the cursor on the screen. The key fields for a record, or the index fields for a table, must be the first fields referenced on a screen. Field commands do not have to correspond to the sequence of variables in a row or record. All of the fields on a record or table do not have to be on a screen.
FIELD
command
is the name of the variable.
FIELD variable
BOOLEAN ( expression ) [OPTIONAL]
[NO]DATA
[AT r , c] [HILITE | VIDEO video_options]
DEFAULT expression
DISPLAY ['prompt' | VARDESC | VARLABEL | VARNAME] [VIDEO
video_options]
DSPEDIT
options
DSPTYPE
options
FINAL COMPUTE
variable=expression, ...
HELP
helpscreen | 'help_string'
IF
( expression )
INITIAL COMPUTE
variable=expression, ...
INSERT | OVERSTRIKE
LEFT | RIGHT
LENGTH
min, max
LOOKUP options
NOECHO
PATTERN
'pattern'
PICTURE
'picture'
PMTEDIT
options
PMTTYPE
options
[NO]PROMPT
{'string' | VARDESC | VARLABEL | VARNAME }
HILITE | VIDEO video_options
RANGE
(n,m) ['error message'] .... [OPTIONAL]
REQUIRED
TYPE
options
VALUELABELS
(n [,m]) 'string'
WIDTH
d,w
General Clauses:
ACTIVITIES permissions
AT [r][,c]
[NO]AUTOTAB
CLEAR 'c'
ERROR message_number [ VIDEO video_options ]
'error message'
LABELS n
PAD [n][,m]
BOOLEAN ( expression ) [OPTIONAL]
If OPTIONAL
is specified, and the logical expression is false,
an error message is displayed to alert the user. The user can modify or
accept the field before moving to the next field. If OPTIONAL
is not specified, the user cannot accept a field which fails the test.
Example: To specify that an entry for
BIRTHDAY
is acceptable only if it falls within the last week,
specify:
FIELD BIRTHDAY BOOLEAN - (BIRTHDAY GE (TODAY(0)-7) AND BIRTHDAY LE TODAY(0))
[NO]DATA [ AT r,c] [ HILITE | VIDEO video_options ]
NODATA
suppresses the data area of the field. If NODATA
and
NOPROMPT
are specified nothing is displayed and the cursor
position remains unchanged.
AT
HILITE
VIDEO
FIELD BIRTHDAY DATA HILITE BOLD AT +1
The "AT + 1"
option on the DATA
clause
positions the data area only. The data area is positioned on the next line, and
the column position is not changed. If the "AT + 1"
was
specified as a clause on the FIELD
instead of as a sub-clause
on DATA
, it would position both the prompt and the data.
DEFAULT expression
Example: Set the default for BIRTHDAY
to
today's date.
FIELD BIRTHDAY DEFAULT TODAY(0)
DISPLAY ['prompt string' | VARDESC | VARLABEL | VARNAME] [VIDEO video_options]Specifies that the field is display only. It cannot be modified nor can new data be entered. The options on
DISPLAY
control the prompt
and are the same as the PROMPT
clause.
prompt string
VARDESC
VARLABEL
VARNAME
VIDEO
VIDEO
clause is
applicable. See video treatment
for video_options.DSPEDIT CAPITALIZE EDIT 'edit_template' LEADING 'leading_string' LEFT | RIGHT [FILL 'fill_character'] LOWERCASE MASK {COMMA | DOLLAR | PERCENT} MONEY SCALE n STRIP 'string' TRAILING 'trailing_string' TRUNCATE n UPPERCASESpecifies display edits.
DSPEDIT
alters the way the field is
displayed. If an error occurs in the execution of the DSPEDIT
,
an error message is issued and the field is filled with X's. Use the
TYPE
clause to increase the field length to accommodate extra
characters.
If the user edits the field, the displayed field, including any characters
added or taken out by the display edit, become the input. This must be dealt
with, either by the user clearing the field when editing or by an
appropriate PMTEDIT
clause.
CAPITALIZE
EDIT
FILL
character. If the
template specifies less data characters than exist, an error message is issued
and the field filled with X's.LEADING
LEFT
FILL
character.RIGHT
FILL
character.FILL
LOWERCASE
LOWERCASE
is used with CAPITALIZE
, all
characters are LOWERCASE
d then CAPITALIZE
d.MASK
COMMA
inserts commas every three digits to the left
of the decimal point. DOLLAR
prefixes the number with a
dollar sign ($). PERCENT
appends a percent (%).
MONEY
DOLLAR
and COMMA
mask. A dollar sign ($) is prefixed to the number and commas are inserted every
three digits to the left of the decimal point.SCALE
SCALE 1
in order to have the scaling computation
performed.STRIP
TRAILING
TRUNCATE
UPPERCASE
FIELD SSN - DSPEDIT EDIT '^^^-^^-^^^^'
DSPTYPE DATE 'date_format' EREAL n ,m INTEGER n [,m] REAL n ,m STRING n TIME 'time_map' ZINTEGER n [,m]Specifies the type of a field for display. Specify one of the following:
DATE
FIELD BIRTH DSPTYPE DATE 'MM/DD/YY'
EREAL
TYPE
) at
least six positions greater than the number of decimal places.INTEGER
REAL
STRING
TIME
DECLARE
clause of the FORM
command.ZINTEGER
INTEGER
, but has no effect.
ZINTEGER
formats integers as zero-filled numbers. The field
is zero-filled to the left up to n characters.FINAL COMPUTE variable = expression, ... IF ( expression ) variable = expression, ...Specifies one or more variables computed when the user leaves the field.
Specify multiple COMPUTE
and IF
statements
if required; only specify the keyword FINAL
once. If
multiple COMPUTE
and IF
clauses are used,
use commas as delimiters between clauses.
Use COMPUTE
to compute a variable.
Use IF
to compute a variable under particular conditions.
When the IF
clause is used, variables are computed only when
the expression following the IF
clause is true. The
expression can be enclosed in parentheses if desired.
HELP screen_name | 'help_string'
When the user requests help, if a screen name is specified, that help screen is displayed; if a text string is specified, the string is displayed on the status line at the bottom of the screen.
IF ( logical_expression )
IF
clause to control whether the cursor moves to
the field for data entry. If the expression is true, the cursor moves into the
field and data can be entered. If the expression is false, the cursor skips
over the field and data cannot be entered.
Example: Allow monthly rent to be entered if
OWNHOME
is not equal to 1.
FIELD MONRENT IF (OWNHOME NE 1)
INITIAL COMPUTE variable = expression, ... IF ( expression) variable = expression, ...Specifies one or more variables computed when the cursor moves to the field.
Specify multiple COMPUTE
and IF
statements
if required; only specify the keyword INITIAL
once. If more
than one clause is used, use commas as delimiters between clauses.
Variables can be computed using the COMPUTE
clause or
conditionally computed using the IF
clause. When the
IF
clause is used, variables are computed only when the
expression following the IF
clause is true.
LENGTH min , max
LOOKUP {lookup expression} [NOT]ON screen [/database.record | /tabfile.table] BACKWARDS n | FORWARDS n ERROR nnn 'message' IF ( expression ) IN destination_expression LOCK locktype OPTIONAL | REQUIRED REPORT 'message' RETURNING expression, ... TO variable, ... USING caseid [ * ] | [ key, ...] VIA * | key, ...Uses another screen to locate a record. Use
LOOKUP
to
establish the presence or absence of a record or to retrieve data from the
record that is looked up. Use LOOKUP
to verify the field data
by testing stored value(s) in a record. LOOKUP
can perform a
number of functions:USING
or VIA
clauses. If keys are not specified, the first record of that type is used.
USING
or VIA
clauses.
lookup expression
IN
clause). By default, the field value is
used. For example, if this field were DOSAGE,
and this has to
be multiplied by the doses per day to check the value on a reference record,
specify:FIELD DOSAGE - LOOKUP DOSAGE*QTY ON DRUGREF - USING -1,DRUGID IN MAXDOSE
[NOT]ON
ON
or NOTON
) is the only
required clause. The clause references the screen name. If the screen
name is not the same as the record or table, the record name or table name MUST
be quoted as part of the screen name. Specify the database or tabfile if they
are not the default.ON
checks that the record exists and returns an
error message if a record matching the search criteria is not found.NOTON
checks that no records matching the search
criteria exist. NOTON
returns an error message if a record
matching the search criteria is found.
For example, when adding
new people, the social security number could be tested to be
NOTON
an inverted list of current social security numbers.BACKWARDS n|
FORWARDS n
USING
or VIA
, the direction
of search may be relevant. The default direction is FORWARD.
If a number is specified, the nth record matching the search criteria is
selected.ERROR nnn
IF
LOOKUP
clause is executed. If the expression is true, the
LOOKUP
is performed. If it is false, the
LOOKUP
is not performed. IN
VIA
or
USING
, IN
tests on that record. If a
partial key is specified, the set of records is searched for a match. If a
number is specified on FORWARDS
or
BACKWARDS
, the nth matching record is used.
LOCK
OPTIONAL |
REQUIRED
REQUIRED
, the
value is not accepted and must be re-entered. Specify
OPTIONAL
to issue a warning message, letting the user
continue and accept the field. REQUIRED
is the
default.
REPORT
RETURNING
to bring those values into fields that can be
referenced and displayed on this screen.RETURNING
TO
list. The RETURNING
and the TO
list are
positionally matched. The first variable in the RETURNING
list is moved to the first variable in the TO
list, the second
to the second and so on. Variables referenced in the
RETURNING
list must be available to the lookup record;
variables in the TO
list must be available to the current
record.USING
LOOKUP
uses a different case in
a case structured database. Use VIA
to lookup records in the
current case. Specify the case id value, optionally followed by the key fields.
Specify an asterisk (*) to use the key fields of the current screen. Do not
specify USING
for caseless databases nor in conjunction with
the VIA
clause.VIA
TABLE
screen. Specify values for the key fields.
Specify an asterisk (*) to indicate that the key fields of the current screen
are to be used. If the specified key(s) are not explicit to one record, but
define a set of records, the first record which matches the IN
clause is used. If there is no IN
clause, the first record in
the set is used. (This can be changed from the first to the last or the nth
with the FORWARD
and BACKWARDS
clauses).
A) This checks that a record (LOCREC
) exists with a case id of -1 that has a key of LOCATION
and gives an error message if the record is not there. The lookup screen is also called LOCREC
and is in the form definition solely to be used as a lookup. It has just the keys defined and is never displayed.
FIELD LOCATION - LOOKUP ON LOCREC USING -1, LOCATION- ERROR 59 'Invalid Location Code - Please Re-enter' .. RECORD LOCREC / COMPANY.LOCREC field ID END RECORD
B) This checks for the opposite condition from A, that the record does not
already exist and gives an error message if this is not a new location.
FIELD LOCATION LOOKUP NOTON LOCREC USING -1, LOCATION - ERROR 59 'Location Code Already Exists - Please Re-enter'
C) This checks the record is present and that STATUS
( a field
on the location record) equals 1.
FIELD LOCATION 1 LOOKUP ON LOCREC USING -1, LOCATION- IN STATUS - ERROR 59 'Location Not Found or Not Active'D) This returns the location status to a temporary field
XSTATUS
(which has been DECLARE
d on the
FORM
command) and then displays the result.FIELD LOCATION LOOKUP ON LOCREC USING -1, LOCATION- RETURNING STATUS to XSTATUS - ERROR 59 'Invalid Location Code - Please Re-enter' FIELD XSTATUS DISPLAY 'Location Status'If the screen which referenced the record
LOCREC
had a
different name, say XLOCREC
, for some reason, the lookup
clause must name both the record and screen name:
RECORD XLOCREC / COMPANY.LOCREC
FIELD LOCATION LOOKUP ON XLOCREC / COMPANY.LOCREC
NOECHO
NOECHO
suppresses the display of input for a field as it is
entered and subsequent displays of the data portion of the field.
PATTERN 'edit pattern'
PATTERN
specifies an edit for validating input data. If the
value matches the pattern, the value is accepted. If it does not match, an
error message is issued (Error 113) and the value is not accepted. An edit
pattern is specified as characters that must match exactly and the percent sign
(%), which indicates that from zero to 'n' characters are not tested. Character
codes, such as those on the PICTURE clause, are not used. Both
PATTERN
and PICTURE
clauses can be specified
for the same field.
Example:
PATTERN '%-%'
PATTERN '%-%-%'
PATTERN 'E%/%E'
The first example tests that the input has a "-" somewhere in it. The
second tests that there are two "-", possibly separated by other
characters. The third example tests that the input begins and ends with an "E"
and has a "/" somewhere in the middle.
PICTURE 'picture string'
PICTURE
specifies a picture string for validating user
input. The data is accepted when the value entered by the user matches the
picture. If it does not match, an error message (Error 16) is issued and the
data is not accepted. Any picture specifications are added to the default help
screen for the field.
The picture must be the same length as the input field. When changing the
length of the field to match the picture, the TYPE
clause must
precede the PICTURE
clause.
The picture is composed of characters that must be matched exactly and character codes for each position in the input string. The character codes are:
a any letter
d any digit
n any letter or digit
s a
numeric value (0-9, decimal point, +, -, E)
u any uppercase letter
l any
lowercase letter
x any character
Example: The following PICTURE
clause
validates input of a social security number. The expected picture is 3 digits,
a dash, 2 digits, a dash, and 4 digits (eg., 123-54-6789).
PICTURE 'ddd-dd-dddd'
PMTEDIT CAPITALIZE EDIT 'edit_template' LEADING 'leading_string' LEFT | RIGHT [FILL 'fill_character'] LOWERCASE MONEY SCALE n STRIP 'strip_string' TRAILING 'trailing_string' TRUNCATE n UPPERCASEThe
PMTEDIT
clause specifies permanent edits
(PerManenT EDITs) that are applied to the value in the
variable. The value entered is edited according to the specified options and
the edited value is stored in the database. The editing also updates the data
on the screen. These edits are applied to the field whenever it is modified.
If the user inputs a field once and then edits it for input again without
clearing it completely and re-entering it, this may cause problems.
PMTEDIT
updates the field and, once the field is edited and
re-input, all characters are read again. A PMTEDIT
such as
LOWERCASE
is no problem because making a field lowercase twice
does not impact it; however clauses such as EDIT, LEADING,
SCALE
and TRAILING
, all update the field. If the
field is edited again, these clauses are applied again and may give unexpected
results.
Any edits applied to a numeric field must produce a resulting legal numeric value (digits, a plus or minus character and/or a decimal point).
CAPITALIZE
EDIT
LEADING
LEFT
FILL
character.
RIGHT
FILL
character.
FILL
LOWERCASE
LOWERCASE
is used with CAPITALIZE
, all
characters that are not capitalised are lowercase. MONEY
MONEY
is not specified, dollar
sign and commas are illegal in a numeric field. Increase the width of the field
with the TYPE
clause to allow for these characters.
SCALE
STRIP
TRAILING
TRUNCATE
UPPERCASE
field SS pmtedit strip '-/'
PMTTYPE DATE 'date_format' EREAL n , m INTEGER n REAL n , m STRING n TIME 'time_map'
PMTTYPE
changes the type and width of a field. When a
variable is defined in the database or in a table, it can have a standard
external format. For example, an integer might be defined as 4 characters long.
The PMTTYPE
allows for additional field positions which are
not stripped out by one of the edit clauses.
(The DSPTYPE
changes the width of the display field but not
the number of digits. This allows for additional characters such as dollar
signs or other edit characters.) The TYPE
clause changes both
the DSPTYPE
and the PMTTYPE
.
Fields cannot be changed from numeric to string or vice versa with this clause.
To specify a DATE
or TIME
type for a
temporary variable, declare the variable as real on the
DECLARE
clause of the FORM
command.
DATE
EREAL
EREAL
specifies that numeric data is displayed in scientific
format. The width must be at least six positions greater than the number of
decimal places.INTEGER
REAL
STRING
TIME
[NO]PROMPT [ 'prompt-string' | VARDESC | VARLABEL | VARNAME HILITE | VIDEO video_options AT [r] [,c] ]
PROMPT
specifies how the prompt for this field is displayed.
NOPROMPT
suppresses the prompt for the field. If both
NOPROMPT
and NODATA
are specified, nothing
is displayed and the cursor position remains unchanged.
prompt string
VARDESC
VARLABEL
VARNAME
HILITE
VIDEO
AT
RANGE (value1 [,value2]) ['error message'] (value3 [,value4]) ['error message'] ... [OPTIONAL]
RANGE
(or RANGES
) specifies ranges for edit
checking. Ranges must be within any valid ranges specified for the variable on
the data dictionary. The values specified can be constants or the keywords
LO
or HI
meaning the lower and upper valid
value respectively. Variable names or expressions are not allowed.
If the value entered is within a range, the value is accepted and the cursor
moves on to the next field. If the value entered is within a range with a
message, the message is issued and the user has a chance to correct or
accept the value. If the value entered is outside all ranges, an error message
is issued and the value is rejected unless OPTIONAL
is
specified. This allows the user to accept a value outside any of the ranges
specified here. The user cannot enter a value outside any ranges specified
in the data dictionary. Specify OPTIONAL
once, after the
final range.
Multiple ranges can be specified. The ranges must be in ascending order and cannot overlap.
Example: HEIGHT
is defined in the data
dictionary with the range 48 to 84 inches. The RANGE
is
specified to warn the user when values below 60 or above 78 inches are
entered.
FIELD HEIGHT - RANGES (LO, 60) 'Are you sure they are this short ?'- (61, 78) - (79, HI) 'Are you sure they are this tall ?'
REQUIRED
Keys are required by default and need not be specified as
REQUIRED
.
Example : To ensure that the variable NAME
is
always entered:
FIELD NAME REQUIRED
This tests that the user has entered a value. This value may be blanks since blanks is a valid character string and is a valid missing value. To exclude blank names as well:
FIELD NAME REQUIRED - BOOLEAN (EXISTS(NAME)) - Error 57 'You must enter a name for an employee' - Error 20 'You must enter a name for an employee'
TYPE DATE 'date_format' EREAL n , m INTEGER n [ , m ] REAL n , m STRING n TIME 'time_map' ZINTEGER n [ , m ]Specifies the type and width of the field. The default is the data dictionary definition.
TYPE
does not affect the way the variable is
stored in the database; it is always stored according to the data dictionary.
The following types can be defined:DATE
type is specified for a temporary variable, that variable
must be declared as real on the DECLARE
clause on the
FORM
command.EREAL
EREAL
specifies that numeric data is displayed in scientific
format. The width must be at least six positions greater than the number of
decimal places.INTEGER
REAL
STRING
TIME
TIME
type is specified for a temporary variable, that variable
must be declared as real on the DECLARE
clause of the
FORM
command.ZINTEGER
INTEGER
but has no effect.
ZINTEGER
formats integers as zero-filled numbers.VALUELABELS ( value [ , value ] ) [ 'string' ], . . .
VALUELABELS
clause provides a
means of defining them. If a variable already has value labels defined in the
database, the VALUELABELS
clause provides alternatives.
Example: To specify value labels for a temporary variable named
AGECAT
(age category):
For values 1 through 3, display
"Children".
For values 4 through 6, display "Young Adults".
For values 7
through 9, display "Adults".
FIELD AGECAT - VALUELABELS (1 ,3) 'Children' - (4 ,6) 'Young Adults' - (7 ,9) 'Adults'
WIDTH d,w
For string fields only, if the total width is larger than the display width, the user can scroll horizontally through the field with the right and left arrows. This allows entry, editing and display of long strings in a limited area of the screen.