|
VisualPQL | PQLForms |
A Form can be created and maintained completely through the Forms Painter and this is the recommended way to develop forms. However, it may be necessary to use PQLForms commands and this chapter describes the various commands available.
The PQLForms commands define what variables are on each screen or page of a screen, how they are displayed and edited, how the screen is to look, and how screens are linked together. A PQLForm has built in buttons and associated logic to allow the user to navigate through a set of records and to display, edit and insert data according to the database description. A developer can use all standard VisualPQL commands as necessary and these are executed at appropriate places in the form.
A PQLform can be re-compiled every time it is used or the compiled version of the form can be saved as an executable member on the procedure file. A PQLForm can also be compiled and saved as a sub-routine and can then be executed as part of another PQLform or standard retrieval. A PQLform is run in the same way as any other VisualPQL routine either directly or from a menu.
Once a form has been developed, it can be used by many people for data entry or for querying data.
A default form can be generated for a database and can be used directly to view, create, or delete records.
The form definition starts with the FORM
command. This is similar to a RETRIEVAL/PROGRAM/SUBROUTINE
command and can take all relevant clauses as per those commands plus PQLForms specific clauses. There are no required clauses on a FORM
command. The entire form definition is terminated by the END FORM
command.
The FORM
command may be followed by any standard VisualPQL commands, (for example defining any local variables) and then optionally a CALL SCREEN
command that transfers control to the named screen. The first SCREEN
command begins definition of a screen. All further commands are in a screen definition. Definition of a screen is terminated by the END SCREEN
command. Commands in the screen define the set of fields that are displayed; these can be split into a number of separately displayed pages if necessary.
A form can contain any number of screens. Screens are linked to other screens with the CALL SCREEN
command so that the user or the application can pass control at appropriate points. A single screen can be called from any number of different screens.
The standard VisualPQL commands up to the first SCREEN
or CALL SCREEN
command are executed and then execution starts with the first screen or called screen.
This keyword MENU, RECORD
or TABLE
on the SCREEN
command specifies the type of screen being defined:-
Within each screen, further commands are used to describe the components of the screen and their individual behaviour and appearance. The most common of these is the FIELD
command. This defines an individual variable, possibly displaying it on the screen allowing the user to retrieve data and maybe update data. Default formats and edit rules from the data dictionary are applied automatically. There are clauses on this command to extend the edit rules and alter the position or format of the data.
A form has a structure similar to the following:
FORM . SCREEN RECORD record_name . FIELD field_name . FIELD field_name . CALL SCREEN record__name1 . END SCREEN . SCREEN RECORD record_name1 . FIELD field_name . FIELD field_name . END SCREEN ENDFORMA very simple form definition (on the example
COMPANY
database) might be:form . screen record EMPLOYEE . field id . field name . field currpos . call screen OCCUP . end screen . screen record OCCUP . field id . field position . field startsal . end screen end form
AT
clause on the command that specifies the element.The visual size of the screen is determined by the maximum position taken by any display element plus space for buttons and an area to display messages. There is no absolute maximum row and column size and it is possible to create screens that are too big to view all at once. There is a default font face, color and size of characters. These can be altered and specific colors/sizes/fonts can be used.
EXAMPLE
on the example COMPANY
database. These are named FORMnnnn
and contain comments as to the various features that they illustrate.
SCREEN
PAGE
FIELD
GENERATE
CALL SCREEN
ABUTTON
FBUTTON
FDISPLAY
END SCREEN
END FORM
FIELD
command has the EDITIN
and EDITOUT
clauses that allow the specification of commands to transform data as it is read from the screen or displayed.
:FIELD SALARY EDITOUT (fieldout = pformat(salary,'$zzzz.zz')) EDITIN (if (sbst(fieldin,1,1) eq '$') fieldin = sbst(fieldin,2,len(fieldin)-1); salary = numbr(fieldin); ifthen (salary lt 1000); failmess = 'Salary too low'; failfld = 1; fi)
FIELD
command has the IF
clause that determines whether the field is enabled or disabled (greyed out).FIELD SALARY prompt 'Salary:' IF (EDUC EQ 1)
FIELD
commands. The commands are executed when the user presses ENTER
as follows:-FIELD
command are executed whenever the user presses Enter.
FIELD
command are executed when a user is positioned on that field and presses Enter (with a valid value) after the value from the screen is put into the variable but before the screen is redisplayed.
HELP
clause followed parentheses enclosing any standard PQL expression that resolves to a string. The expression can be a simple string constant in quotes or a concatenated string. To display multiple lines in the pop up box, concatenate char(13)
as a line break character. For example:FIELD BIRTHDAY PROMPT 'Date of Birth' HELP ('Enter as MMM DD, YYYY' + char(13) + 'For example: May 24, 2001')
If there is no defined help text for a field, nothing is displayed i.e. no box is popped. If there is no help text for any fields, the question mark is suppressed.
ERROR
clause for the error message number at any level (form, screen, field). This replaces the default error message for everything within that level. For example:
FIELD SSN ERROR 47 'Social security number is in the wrong format'In this example, error message 47 "Not a valid value", is replaced by the message "Social security number is in the wrong format" if a user makes an error.
Every PQLForm screen has a set of buttons that take standard actions. These buttons vary according to the type of screen but all include an Exit
button to return one level. Typically screens also have various fields for the display and entry of data. Error messages are displayed at the bottom of the screen.
Each data field can have up to three visual elements: a prompt, a data area to enter or to display the data and the set of value labels displayed as a pull down choice list. When a screen is initially displayed, fields may already have data in them or the fields may be blank waiting for data to be entered or a record to be retrieved.
To enter data into a field, type in the data and press Enter
. To skip over fields, use the Tab
keys or position to a field with the screen cursor using a mouse or other pointing device. Shift-Tab
goes back a field, Tab
goes forward a field. Tab
does not process the data nor execute any VisualPQL associated with the field.
Left Arrow
and Right Arrow
position the cursor within the field. The data in a field may be longer than the display space and is scrolled horizontally as characters are typed or the arrow keys are used.
Keys to edit the field are the normal keys for the GUI being used. On Windows systems, Del
deletes the next character, Ctrl-Del
deletes the whole field; Ctrl-C
cuts highlighted characters, Ctrl-V
pastes cut characters, Ctrl-Z
restores the previous edit, etc.
Press Enter
to process the data in a field and move to the next field. If you update a field but do not press Enter
, the edits have no effect.
If a screen is on multiple pages, the Page Down
button moves to the next page; the Page Up
button moves to the previous page. The title of the screen changes to indicate the current page.
To call a screen, press the appropriate button. The Exit
button returns to the calling screen. Lower level screens can call other screens and screens may be nested as deeply as necessary.
There are buttons to browse through sets of records:-
To locate a record, enter data in all the key fields. Press Enter at the last key field and the matching record is then retrieved. If no record matches the exact key, a message that a no record has been found is displayed. This positions in the set of records even if a partial key is entered or the key does not exist and the Next or Previous buttons browse from that point.
WRITE
button to write the changed data. The WRITE
button is only displayed if the form allows updates and is only enabled when some data has been updated.
Prior to writing the data back, the RESET
button restores the original data "undoing" whatever changes were made.
The Clear
button clears the screen data fields except for any key values preset by the CALL
to this screen.
DELETE
button deletes the record. The DELETE
button is only displayed if the form allows updates and a record has been retrieved. The record is deleted after asking the user for confirmation.
FORM SCREEN PAGE FIELDA setting at one level acts as the default for all lower levels. For example, the width of labels could be set on the
FORM
command for the whole form and would apply to every field on every screen. A setting is overridden for a particular level by specifying the clause at that level. If a particular setting is not specified at a given level, the current default applies.These general clauses are:-
[NO]PROMPT [AT r,c] [WIDTH n] [FONT ([NO]BOLD|[NO]ITALIC|[NO]UNDERLINE|SIZE=N|FACE = 'fontname'|FGROUND=RRGGBB|BGROUND=RRGGBB)] ['prompt-string'|VARDESC|VARLABEL|VARNAME|VARDOC] [NO]DATA [AT r,c] [WIDTH n] [FONT ([NO]BOLD|[NO]ITALIC|[NO]UNDERLINE|SIZE=N|FACE = 'fontname'|FGROUND=RRGGBB|BGROUND=RRGGBB)] [NO]LABELS [AT r,c] [WIDTH n] [FONT ([NO]BOLD|[NO]ITALIC|[NO]UNDERLINE|SIZE=N|FACE = 'fontname'|FGROUND=RRGGBB|BGROUND=RRGGBB)] ERROR number 'error text'
VAR LABEL
command). The default position for the prompt is one row down and in the same column as the previous prompt or other displayed element (text, button, etc.) and is 18 columns wide. The first prompt is in the top left corner, row 1 column 1.
FORM
, SCREEN
, PAGE
and FIELD
commands. (See below.) Because the three elements are positioned from left to right relative to each other, if the prompt position or width is specified, the data and label positions are automatically adjusted. Similarly, if the data position or width is specified, the label position is automatically adjusted.The absolute row and column size are dependent on the font size being used. A single row is sufficient to display a field or button. A column approximates to an average character in the font. The number of rows and columns displayable on a screen depend on font size and screen resolution.
Row and column positions can be specified in either absolute or relative terms.
Absolute positions are specified with unsigned integers. For example,
Relative positions are specified by prefixing the integer with a plus or minus sign. Relative positions are relative to the default position for this element. For example,
An asterisk (*) may be used instead of row or column numbers to indicate the default maximum row that is the current pagesize (default 20) or default maximum column (80).
Example
The physical width of any field depends on font sizes in use and, since most fonts are variable width, there is no exact correspondence between columns and characters that can be displayed. A column approximates to an average character in the font. If the displayed data or label is wider than the display width, the user can scroll horizontally with the right and left arrows.
Example: To display 20 characters of value labels next to all data fields that have value labels, specify:
For example
Error messages apply to the level (
The
AT
AT [ row ] [, column ]
AT
is a clause on a number of commands and alters the starting position for the specified display element.AT 5
positions at row 5, AT ,60
positions at column 60, AT 5,60
positions at row 5 column 60.AT -1,+40
specifies one row higher and forty columns to the right and means that the field appears on the same row as the previous field.AT
clauses:
If AT 1,1
positions to the upper left corner.
AT *,1
positions at row 20, column 1.
AT ,12
positions at column 12 of the current line.
AT -1,1
positions at the beginning of the previous line.
AT ,+10
positions 10 columns along from the default column position.AT
is specified on PROMPT
, the default DATA
and LABEL
column positions are updated. Similarly, if AT
is specified on DATA
, the default LABEL
column position is updated.WIDTH
WIDTH n
WIDTH
is a clause on a number of commands and alters the width for the specified display element or the width of all lower level fields if specified on a higher level command.[NO]DATA
[NO]DATA [AT r,c] [WIDTH n]
Specifies position and/or width of the data area for fields.
AT
Specifies the starting position (row and column) of data area. If position is specified on a higher level command, it applies to the first field. If
AT
is specified on DATA
, the default LABEL
column position is updated. WIDTH n
Specifies the width of data area. If
WIDTH
is specified on DATA
, the default LABEL
column position is updated.NODATA
Suppresses the data area of the field. This also suppresses any label for the field.
[NO]LABELS
LABELS [AT R,C] [WIDTH n] | NOLABELS
Specifies position and/or width of the label area of a field. Labels correspond to value labels and are only displayed for fields that have value labels defined. Labels are displayed as a choice control. This is a pull down list with all allowed descriptions and the selected description corresponds to the value in the data field. Choosing a description updates the value in the data field.
AT
Specifies the starting position (row and column) of label area. If position is specified on a higher level command, it applies to the first field.
WIDTH n
Specifies that value labels, "n" characters wide, are displayed where appropriate.
NOLABELS
Suppresses the labels area of the field.
FORM TESTFORM LABELS WIDTH 20
[NO]PROMPT
[NO]PROMPT [ 'prompt-string' | VARDESC | VARLABEL | VARNAME | VARDOC ] [AT r,c] [WIDTH n]]
Specifies how prompts for fields are displayed. Prompts are left justified and followed by a colon (:).
NOPROMPT
suppresses the prompt. This does not alter the default start position of the associated data.prompt string
Specifies a prompt string for a field. This format can only be used when specifying prompt defaults on a specific
FIELD
not on any higher level commands.VARDESC
Specifies that the variable name and label are the prompt.
VARLABEL
Specifies that the variable label is the prompt. If a label does not exist, the variable name is used. This is the default.
VARNAME
Specifies that the variable name is the prompt.
VARDOC
Specifies that the first line of variable documentation (VAR DOC) is the prompt.
AT
Specifies the starting position (row and column) of prompt area. If position is specified on a higher level command, it applies to the first field. If
AT
is specified on PROMPT
, the default DATA
and LABEL
column positions are updated.WIDTH n
Sets the width of the prompt. If
WIDTH
is specified on PROMPT
, the default DATA
and LABEL
column positions are updated. FONT
FONT ([NO]BOLD|[NO]ITALIC|[NO]UNDERLINE|SIZE=N|FACE = 'fontname'|FGROUND=RRGGBB|BGROUND=RRGGBB)
Non-standard fonts can be specified with the FONT
clause wherever a DATA
, PROMPT
or LABEL
clause is specified. Follow the FONT
keyword with a set of specifications enclosed in brackets () using as many as necessary. Note that some changes alter the amount of space required to display the item and other positioning specifications may need to be adjusted accordingly. Fonts specified on higher-level commands alter the default font for all fields within that level. The various specifications are:
BOLD
Display the element as bold.
ITALIC
Display the element as italic.
UNDERLINE
Display the element underlined.
SIZE=N
Increase or decrease the size of the element. Specify a negative number to decrease size.
FACE='fontname'
Display the element using a different font. Specify the name of the font enclosed in quotes.
FGROUND=RRGGBB
Display the element using a different foreground color. Specify the color using exactly six characters; valid characters are 0 to 9 and A to F. These are three sets of hexadecimal specifications of the strength of the red, green and blue components of the color. Each setting has a value from 00 to FF.
FGROUND=RRGGBB
Display the element using a different background color. Specify the color using exactly six characters; valid characters are 0 to 9 and A to F. These are three sets of hexadecimal specifications of the strength of the red, green and blue components of the color. Each setting has a value from 00 to FF.
SCREEN RECORD EMPLOYEE PROMPT FONT (FACE='Ariel')
FIELD ID PROMPT FONT (BOLD)
Note that higher level font settings apply to FIELD
definitions and do not alter defaults for buttons. If you wish to alter the font on a buttons, specify the font on a FBUTTON
command. Currently buttons do not support color but any other font specification can be used.
ERROR
ERROR message_number 'error_text'
Specifies alternate text for a message. Each message consists of the message_number followed by text. See
messages for a full list of default messages.
FORM, SCREEN, PAGE
or FIELD
) at which they are defined and to all lower levels unless overridden by another error message defined at the lower level.
Example: To change the messages for errors 15 and 47 to "This field must be two digits." and "Jobcode must be between 10 and 60.", specify:
FIELD JOBCODE ERROR 15 'This field must be two digits.'
ERROR 47 'Jobcode must be between 10 and 60.'
FORM
FORM
[appropriate standard RETRIEVAL/PROGRAM/SUBROUTINE clauses]
[PQLForms general clauses]
[AUTO]
[CLEAR|NOCLEAR]
[NODATABASE]
[PAGESIZE rows]
[PQLFILE='filename']
[SUBROUTINE name [(input_list)]]
[UPDATE]
General Clauses
[NO]DATA [AT r,c] [WIDTH n]
[NO]LABELS [AT r,c] [WIDTH n]
[NO]PROMPT [AT r,c] [WIDTH n] [VARDESC|VARLABEL|VARNAME|VARDOC]
ERROR number 'error text'
FORM
command is required. All other clauses are optional. All standard RETRIEVAL
clauses can be specified. The PQLForms general clauses can be specified. The following specific clauses can be specified on the FORM
command:
AUTO
|
Specifies that, if updates are allowed, any new records are written to the database without asking for confirmation. NOAUTO specifies that the user is asked to confirm that the record should be written and is the default. |
CLEAR
|
Specifies that, if updates are allowed, the data fields on the screen are cleared after writing. NOCLEAR specifies that the data is not cleared and is the default. |
NODATABASE |
Specifies that the generated form is a PROGRAM not a RETRIEVAL and can run without being attached to a database.
|
PAGESIZE n
|
Specifies the maximum number of data rows in a page of a screen. The default is 20. (See the PAGE ) command. |
PQLFILE |
Specifies that the named file is created. This contains standard VisualPQL code (i.e. all PQLForms extensions have been replaced) that performs identical functions to the specified form. This can be used as the basis for a program with other functionality if necessary. |
SUBROUTINE
|
Specifies that the routine is compiled and saved as a SUBROUTINE . The subroutine name is required and is the name of the compiled subroutine. The name of the subroutine can be qualified with procedure file and family prefixes and passwords.
A subroutine may have input parameters. These are
positional parameters corresponding to the
To pass key variables to a SCREEN defined in a FORM SUBROUTINE you would use: FORM SUBROUTINE name (keys) CALL SCREEN scrname USING (keys) . SCREEN RECORD scrname ... |
UPDATE
|
Specifies that record and table screens allow the reading and writing of records. By default, screens do not update the database or tabfile. Individual screens can be set to allow/disallow updates. Local variables can be input regardless of update status. |
SCREEN {MENU name | RECORD name [/database.record][ INDEXED BY indexname ] | TABLE name [/tabfile.table] [ INDEXED BY indexname ]} [AUTO|NOAUTO] [CLEAR|NOCLEAR] [DELETE (pql code)] [INITIAL (pql code)] [NOBUTTON] [PAGESIZE rows] [READ (pql code)] [SELECT (pql code)] [TITLE (pql code)] [UPDATE | NOUPDATE] [WRITE (pql code)]
[NO]DATA [AT r,c] [WIDTH n] [NO]LABELS [AT r,c] [WIDTH n] [NO]PROMPT [AT r,c] [WIDTH n] [VARDESC|VARLABEL|VARNAME|VARDOC] ERROR number 'error text'
A SCREEN
command starts a screen definition. The screen name must be specified and must be unique within a form. This is displayed as the title of the screen. The name must be a valid SIR/XS name.
Follow the screen command with further commands to display fields, to control the appearance of the screen or to link to other screens. The sequence of the fields within the screen definition determines the sequence for moving to the next field. If the display element positioning clauses are used, this may not necessarily be the order of fields as they appear on the screen.
End the set of commands for a screen with the END SCREEN
command.
There are three screen types defined by the MENU
, RECORD
or TABLE
keyword.
FIELD
commands can only refer to local variables. Menu screens may consist simply of buttons offering choices as to which screens to go to or can display fields or allow data entry providing that these are local variables.
The AUTO
, READ
, SELECT
and WRITE
clauses do not apply to MENU
screens.
Specify the screen name and, optionally, the name of the record and the name of the database. If a record name is not specified, the screen name must be the record name. If a database name is not specified, the current database is the default.
The name CIR
can be used as a record name on a case structured database to refer to the common information record.
An index can be specified for a record and the index variables are treated as the key fields. Only one index can be specified for a record screen. If an index is not specified, the record is processed by any case and record keys.
The same record type can be associated with multiple screen definitions in the same form definition to allow different ways of viewing the same data. Each screen name must be unique.
When control is passed to a record screen, a record can be retrieved or a new entry created. The user can enter the key fields to locate the record, or can find the appropriate record with FIRST, LAST, NEXT
or PREVIOUS
buttons. The record or set of records to retrieve can be determined by clauses on the CALL SCREEN
command.
Specify the screen name and, optionally, the name of the table and the name of the tabfile. If a table is not specified, the screen name must be the table name. If a tabfile is not specified, the default tabfile is used.
An index can be specified for a table and the index variables are treated as the key fields. Only one index can be specified for a table screen. If an index is not specified, the table is processed sequentially.
The same table can be associated with multiple screens in the same form definition to allow different ways of viewing the same data. Each screen name must be unique.
When control is passed to a table screen, a row can be retrieved or a new entry created. The user can enter the key fields to locate the row, or can find the appropriate row with FIRST, LAST, NEXT
or PREVIOUS
buttons. The row or set of rows to retrieve can be determined by clauses on the CALL SCREEN
command.
AUTO|NOAUTO
|
Specifies that any new records are written to the database without asking for confirmation. NOAUTO specifies that the user is asked to confirm that the record should be written and is the default.
|
CLEAR |
Specifies that, if updates are allowed, the data fields on the screen are cleared after writing. This is the default if not set at the FORM level. NOCLEAR specifies that the data is not cleared. |
DELETE (PQL Code)
|
Specify VisualPQL code, enclosed in brackets, that is executed when a record or row is about to be deleted. The record (row) is deleted by the user pressing the DELETE button. The VisualPQL can be any set of commands. The executed code can create and display sub-dialogs or error boxes as necessary. Separate multiple commands with a semi-colon ';'.The DELETE commands can set a value in FAILSCR to warn the user and reject the delete.Example: To test that when employee has a current position, tell the user and ask whether to accept the delete: SCREEN RECORD EMPLOYEE DELETE (IFTHEN (EXISTS(CURRPOS)); COMPUTE FAILSCR = 15; COMPUTE FAILMESS='Employee in current position'; FI) |
INITIAL (PQL Code)
|
Specifies VisualPQL code, enclosed in brackets, that is executed when the user first initiates a screen before anything is displayed, before the first command in the screen and before a record is accessed. The set of VisualPQL to execute is any set of commands but should not display any sub-dialogs or any other graphical elements. Separate multiple commands with a semi-colon ';'. Example: To set the local variable INTIME to the current time when the screen is accessed, specify:SCREEN RECORD EMPLOYEE INITIAL (COMPUTE INTIME=NOW(0)) |
PAGESIZE n
|
Specifies the maximum number of rows in a page of a screen. The default is 20. If the number of rows on a screen exceeds this size, then a new page is created automatically. When a screen has multiple pages, each page is displayed separately, the Page Up/Page Down buttons are displayed and the screen title contains the current page number. There is no limit to the number of pages on one single screen. All pages within a screen are the same size visually. All pages within a screen are one logical entity i.e. record and table screens access one single record or row. Page breaks can be set specifically at given points by the PAGE command.
|
READ (PQL Code)
|
Specify VisualPQL code, enclosed in brackets, that is executed when the user reads a record. The code is executed when a new record is retrieved, after the record is read and before the data is displayed. The VisualPQL can be any set of commands. The executed code can create and display sub-dialogs or error boxes as necessary. Separate multiple commands with a semi-colon ';'. (The executed code is inside the record block being read so it has access to the current case and record data). |
SELECT (PQL Code)
|
Specify VisualPQL code, enclosed in brackets, that is executed as the user moves to another record. The code is executed after a record is read and selects whether this record is wanted. The VisualPQL can be any set of commands that eventually set FAILSCR to non-zero if the record is not wanted. Records that are not wanted are skipped and the user is presented with the next wanted record. Separate multiple commands with a semi-colon ';'.Example: To ignore records where salary is under 2500, specify: SCREEN RECORD EMPLOYEE SELECT (IF (SALARY LT 2500) FAILSCR = -1) |
TITLE (PQL Code)
|
Specify VisualPQL code, enclosed in brackets, that is executed as each page of the dialog is displayed and constructs the title of the dialog. If this clause is specified, the default title is suppressed. The VisualPQL can be any set of commands that issue a SET DIALOG TITLE command to set the title. There are two predefined variables available. PAGENO is the current page number; PAGES is the total pages. These are both string variables so can easily be included in a title expression if required. Separate multiple commands with a semi-colon ';'.Example: To put out a title, specify: SCREEN RECORD EMPLOYEE TITLE (SET DIALOG TITLE 'People Page ' + PAGENO + ' of ' + PAGES) |
[NO]UPDATE
|
UPDATE specifies that this record or table screen allows the reading and writing of records. NOUPDATE specifies that this record or table screen does not allow the reading and writing of records. By default, screens are set to the update status of the form. Local variables can be input regardless of update status. |
WRITE (PQL Code)
|
Specify VisualPQL code, enclosed in brackets, that is executed when a record or row is written. If data has been updated, the record (row) is written directly by the user pressing the WRITE button or when the user retrieves a new record (row) on this screen or exits from the screen. The code is executed after all local variables have been set to the values displayed on the screen.
This VisualPQL Code could be used to implement ACCEPT /REJECT RECORD and REQUIRED field functionality from old style SIRForms.The VisualPQL can be any set of commands. The executed code can create and display sub-dialogs or error boxes as necessary. Separate multiple commands with a semi-colon ';'. The WRITE commands can check the validity of a record (row) and can set a value in FAILSCR to warn the user and reject the write.Example: To compute the sum of VAR1, VAR2 and VAR3 , specify:SCREEN RECORD EMPLOYEE WRITE (COMPUTE TOTAL = VAR1 + VAR2 + VAR3)To test that when salary is greater than 5,000, tell the user and ask whether to accept the record: SCREEN RECORD EMPLOYEE WRITE (IFTHEN (SALARY GT 5000); COMPUTE FAILSCR = 15; COMPUTE FAILMESS='Salary over $5,000'; FI) |
CautionSince there is only one fail flag for a screen, if you want to test multiple conditions then you should ensure that you don't reset an error status to a warning. For example:WRITE ( IFTHEN (EXISTS(NAME) EQ 0) SET FAILSCR(-1); SET FAILMESS ("You MUST enter a name"); ENDIF; IFTHEN (EXISTS(DOB) EQ 0) SET FAILSCR(1) ; SET FAILMESS ("You really should enter a birthday"); ENDIF; IFTHEN (EXISTS(GENDER) EQ 0) SET FAILSCR(1) ; SET FAILMESS ("You really should enter a gender"); ENDIF; )If none of the variables above is entered then only one warning about gender is displayed.
However, with: WRITE ( SET FAILMESS ("You really should enter:") IFTHEN (EXISTS(DOB) EQ 0) SET FAILSCR(1) ; COMPUTE FAILMESS = FAILMESS + "Birthday; "); ENDIF; IFTHEN (EXISTS(GENDER) EQ 0) SET FAILSCR(1) ; COMPUTE FAILMESS = FAILMESS + "Gender; "); ENDIF; IFTHEN (EXISTS(NAME) EQ 0) SET FAILSCR(-1); SET FAILMESS ("You MUST enter a name"); ENDIF; )If none of the variables above is entered then an error message on name is displayed. Then on the next write attempt the warning message about birthday and gender is displayed.
|
END SCREENA screen must be ended with the
END SCREEN
command. There are no further clauses on the command.
PAGE [PAGESIZE rows]
[NO]DATA [AT r,c] [WIDTH n] [NO]LABELS [AT r,c] [WIDTH n] [NO]PROMPT [AT r,c] [WIDTH n] [VARDESC|VARLABEL|VARNAME|VARDOC] ERROR number 'error text'The
PAGE
command specifies that a new page begins at this point. A new page resets the row position of the next display item to the top of the screen. When a screen has multiple pages, the Page Up/Page Down buttons are displayed and the screen title contains the current page number.There is no limit to the number of pages on one single screen. All pages within a screen are one logical entity related to one single record or row.
If any of the general clauses are specified, these apply to the first field on the page.
PAGESIZE n
If the row placement for a field or button exceeds the page size, a new page is created, the row is reset to the default row for a page (1 if not specified) and subsequent display elements are included in this new page. Lines, boxes and other elements specified with FDISPLAY
commands do not trigger automatic paging.
The page size is checked after any positioning clauses are processed and a new page is created if necessary.
PAGESIZE n
can be specified on the FORM
command, on a SCREEN
command or on a PAGE
command.
FIELD variable_name [EDITIN (pql commands)] [EDITOUT (pql commands)] [HELP (help string expression)] [IF (pql condition)] [NOECHO] [READONLY] [TYPE [INTEGER | STRING | REAL | DATE | TIME]]
[NO]DATA [AT r,c] [WIDTH n] [NO]LABELS [AT r,c] [WIDTH n] [NO]PROMPT [AT r,c] [WIDTH n] ['prompt-string'|VARDESC|VARLABEL|VARNAME|VARDOC] ERROR number 'error text'The
FIELD
command displays the current value of a variable on the screen and provides the capability to invoke standard PQL for editing and validating data values.
The only required clause on the FIELD
command is the name of the variable. 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.
The FIELD
command is used in record screens for record variables, in table screens for table columns and in any screen for local variables. The same variable can be referenced by multiple FIELD
commands on a screen.
The sequence of the FIELD
commands determines the sequence followed by the cursor on the screen when the user presses Enter or uses the Tab keys. 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.
The FIELD
command creates visual entries in the screen together with appropriate logic to display and modify the data.
If VisualPQL commands are interspersed with FIELD
commands then:
FIELD
in a screen are executed whenever the user presses Enter;
FIELD
are executed when a user is positioned on that field and presses Enter.EDITIN (pql commands)
FIELDIN
and sets the value of the record, row or local variable. Separate multiple commands with a semi-colon ';'.FIELD ssn EDITIN (COMPUTE ssn = REPLACE (fieldin,'-','',LEN(fieldin),1,0))If the
EDITIN
commands check the validity of a field, set a value in a predefined variable, FAILFLD
, to indicate what is to be done with the field. A value of zero (0) is the default and means accept the field; a positive value means warn the user that the field has failed validity tests but they can choose to accept it; a negative value means the field has failed validity tests and is not accepted. The standard error message is number 57 'Failed Edit tests'. Set the value of the string variable FAILMESS
to display a different message for the test that fails. If a positive error code is set, the text 'OK to save?' is appended to the message.
The EDITIN
commands completely replace the default field assignment and validation so your PQL code must assign a value to the variable named in the FIELD variable_name
.
FIELDOUT
. The form then uses this as the field displayed in the screen. Separate multiple commands with a semi-colon ';'.FIELD SSN EDITOUT (compute fieldout = edit (ssn,"^^^-^^-^^^^"))N.B. If the user just edits the field then any characters added or taken out by this process become the input. This must be dealt with, either by the user clearing the field when editing or by appropriate logic in the
EDITIN
command.
HELP (string expression)
IF (pql condition)
OWNHOME
is not equal to 1.FIELD MONRENT IF (OWNHOME NE 1)
NOECHO
READONLY
TYPE
FIELD
command, the TYPE
specifies the type of field being referenced. By default, the type is INTEGER
. The local variable should also be defined using standard PQL in the beginning of the form.CALL SCREEN screen_nameThe
[AT r,c] [AUTO [(pql condition)]] [HELP (help expression)] [IF (pql condition)] [ONCALL FIRST | LAST] [PROMPT 'prompt'] [USING (caseid,*| key,...) [VIA (* | key,...) [WIDTH n]
CALL SCREEN
command passes control from one screen to another, typically when the user presses the button generated by the command.
The only required clause on the CALL SCREEN
is the called screen_name. This references another screen that is included in this form. If the name is a non-standard name, ensure that it exactly matches the screen name as specified on the called screen.
The default prompt is the called screen name.
A called screen can be blank for the user to enter any keys and retrieve any records or rows, or the key fields can be passed by this command to control the set of records or rows that the called screen is to reference.
The data fields on the called screen may be blank for the user to select the required screen (first or last in the set) or a record or row may be retrieved automatically with an ONCALL FIRST
or ONCALL LAST
clause.
AT
CALL SCREEN
button is displayed.AUTO [(pql condition)]
AUTO
option suppresses the display of a button and does not affect the position of subsequent fields. The visual clauses AT
, PROMPT
and WIDTH
thus have no effect. If the user needs a normal button to choose to call the screen, specify a second CALL
command.Specify a VisualPQL condition (enclosed in brackets) that controls whether the screen is called at this point. If the condition is true, the screen is called.
HELP (string expression)
CALL SCREEN
field.If the user requests help, the string is displayed as a pop up box.
IF (PQL condition)
CALL NEXTOFKIN IF (RELATIVE = 1)
ONCALL FIRST | LAST
FIRST
or LAST
record in the set of records available to the called screen is retrieved and displayed automatically.PROMPT 'string'
PROMPT
is not specified, the name of the called screen is used.
USING (list,...)
INDEX
that references a new case with a case id of -1 and two other keyfields:CALL INDEX USING (-1,NAME,ID)
VIA (list, ...)
VIA
to select records within this case, to access other records on a caseless database or to access a SCREEN TABLE
. Do not specify a case id on the VIA
clause. Do not use USING
and VIA
on the same CALL SCREEN
command.
If a CALL
is within a SCREEN RECORD
the key specification for either USING
or VIA
keys can contain an asterisk (*) indicating that the key fields of the record from the current screen are used. The asterisk can be preceded or followed by other values. If an asterisk is preceded by values, these values are used positionally. e.g. If a record has three keys, the expression (1,*) means use '1' as the first key and take the second and third key values from this record.
If an asterisk is followed by values, the values are used positionally after the number of keys in the calling record. e.g. If the current record has three keys, the expression (*,1) means use the first, second and third keys from this record and use '1' as the fourth key (presumably the record being called has at least four keys).
If one or more of the lower level keys are omitted, all records with the specified keys are accessible.
If a CALL
is within a SCREEN RECORD
and a USING
or VIA
clause is not specified, all higher level keys are passed automatically that is equivalent to USING (*)
or VIA (*)
.
WIDTH n
CALL SCREEN
button.CALL SCREEN
can appear before the first SCREEN block and is typically used to pass on keys that have been sent to the FORM routine:FORM SUBROUTINE name (keys) CALL SCREEN scrname USING (keys) . SCREEN RECORD scrname ...
FDISPLAY [AT r,c] [[DRAW [HEIGHT N] [IMAGE (bitmap_filename_expression) [BORDER]]] [TEXT (text_expression) [FONT ([NO]BOLD|[NO]ITALIC|[NO]UNDERLINE|SIZE=N|FACE = 'fontname'|FGROUND=RRGGBB|BGROUND=RRGGBB)]] [WIDTH n]The
FDISPLAY
command puts a line, box, image or text on the screen. Expressions are evaluated and the display updated when the screen is refreshed (e.g. when a new record is read).
AT
PROMPT
start position.DRAW
WIDTH
specifies how wide the line/box is and HEIGHT
specifies how high the line/box is. If the height is zero (or unspecified), a horizontal line is produced. If the width is zero (or unspecified), a vertical line is produced. If both width and height are specified, a box is produced.
The IMAGE
clause specifies an expression that is resolved to the name of a bitmap file and the image from this is displayed in the box. The BORDER
clause puts a border around the image. If an image is displayed, the default position is updated by the height of the image.
TEXT
WIDTH
specifies how wide the text is. The default is the current default PROMPT
width. A FONT
sub-clause can be specified as per the FONT
sub-clause on the standard PROMPT
clause.FDISPLAY TEXT ('Welcome to the Administration System') FONT (UNDERLINE SIZE=2) WIDTH 30 FDISPLAY TEXT ('Please contact ext. 123 for help') at +2,+5 FDISPLAY TEXT (NAME) AT 4,30 WIDTH 20 | Displays value in variable NAME FDISPLAY DRAW WIDTH 80 | Draws line for 80 columns FDISPLAY AT 1,1 DRAW HEIGHT 10 WIDTH 50 | Draws box FDISPLAY DRAW HEIGHT 5 WIDTH 40 IMAGE ('LOGO.BMP') | Displays image from file
ABUTTON {FIRST | LAST | NEXT | PREVIOUS | EXIT | RESET | WRITE | CLEAR | DELETE | PAGEDOWN | PAGEUP}
The ABUTTON
command is equivalent to the user pressing a button, except that it is done under program control. This command can be used anywhere in-line VisualPQL can be used but cannot be used in clauses on other PQLForms
commands.
LAST
NEXT
PREVIOUS
EXIT
RESET
WRITE
CLEAR
DELETE
PAGEDOWN
PAGEUP
FBUTTON [button_name | ACTION (pql commands)] [AT r,c] [ID n] [IF (pql condition)] [PROMPT ''] [REMOVE] [WIDTH w]
FBUTTON
command alters the visual appearance (position, width and prompt text) of a system button or defines a user button.button_name
FIRST|LAST|PREVIOUS|NEXT|EXIT|CLEAR|
STATUS|WRITE|RESET|DELETE|PAGEUP|PAGEDOWN|
ACTION (pql commands)
AT
ID
ACTION
button. Only specify this if you need to refer to this button in some other VisualPQL code in the form, for example, to enable or disable the button under particular circumstances rather than using the IF
clause on this command. The specified ID is a number from 13 to 99 (1 - 12 are used for standard buttons). The id for a button is normally automatically allocated by the compiler and is one greater than the previous button. If you specify an id, it must not conflict with any previously automatically allocated id, and, if there are subsequent automatically allocated ids, there must be sufficient numbers available under 100 to allocate. It is strongly recommended that, if it is necessary to specify an id for a button, you specify ids for all user buttons on that form.IF (pql condition)
PROMPT 'string'
PROMPT
is not specified, the prompt is USER BUTTON
plus a unique number.REMOVE
WIDTH
GENERATE EXCLUDE | INCLUDE SCREENS (screennames, ...) VARS (variable, ...)
[NO]DATA [AT r,c] [WIDTH n] [NO]LABELS [AT r,c] [WIDTH n] [NO]PROMPT [AT r,c] [WIDTH n] [VARDESC|VARLABEL|VARNAME|VARDOC] ERROR number 'error text'The
GENERATE
command in record or table screens uses the record or table schema to give the equivalent of default FIELD
commands for every field. GENERATE
in a menu screen produces the equivalent of a default CALL SCREEN
to every previously defined record or table screen.
The EXCLUDE
and INCLUDE
clauses specify fields that are affected or not by the GENERATE
and allow specific FIELD
commands to be combined with a GENERATE
command. When a FIELD
command is specified for a variable, the variable should be EXCLUDED
from the GENERATE
otherwise it appears on the screen twice.
The general clauses on the GENERATE
command apply to all fields generated by the command. The DATA
, LABELS
and PROMPT
AT
clause refers to the row position of the first field.
GENERATE
. When EXCLUDE
is specified, any variable not EXCLUDED
is INCLUDED
automatically (similarly any screen not EXCLUDED
in a generated menu is INCLUDED
).INCLUDE
GENERATE
. When INCLUDE
is specified, any variables (or screens in menus) not INCLUDE
d are EXCLUDE
d.SCREENS
INCLUDE
or EXCLUDE
in menu screens.VARS
For example, to specify particular options for three fields and then bring in all the remaining fields in the EMPLOYEE
record:
SCREEN RECORD EMPLOYEE/COMPANY.EMPLOYEE TEXT 'This is the Demographic Record' AT +2 FIELD ID PROMPT 'Employee ID:' FIELD NAME PROMPT 'Name of Employee' FIELD SSN EDITOUT (COMPUTE FIELDOUT = EDIT (SSN,"^^^-^^-^^^^")) EDITIN (COMPUTE SSN = REPLACE (FIELDIN,'-','',LEN(FIELDIN),1,0)) GENERATE EXCLUDE VARS (ID NAME SSN) END SCREEN
CALL SCREEN
resembles the old Forms CALL
; SCREEN RECORD
resembles old Forms RECORD
.
EDITOUT
and EDITIN
clauses on the FIELD
command (instead of keywords such as DSPEDIT
); the INITIAL
, READ
and WRITE
clauses on the SCREEN
command (instead of keywords such as ACCEPT
).
LOOKUP
command approximates this command in old Forms.
FBUTTON ACTION
to define a help button.
Number Text 15 Text too long 27 Record not found 30 Record Written 37 Case not found 38 No more records 47 Not a valid value 56 Not in valid range 57 Failed Edit tests 110 Record failed write tests 118 Record was modified - OK to save ?