INTERACT is meant to be used in models that will be run by ITP/Workstation. There is another statement similar to INTERACT, FORM. FORM is intended to be used with ITP/OnLine Server and to this end has some extra features. INTERACT enables you to ask the end user questions and store the answers. Whenever the keyword INTERACT is encountered by ITP a question box will pop-up on the end user's screen. The answers are stored in variables and can be used, for instance to select data.
The statement INTERACT is modular. Several questions can be put to the end user in one INTERACT statement by repeating the QUESTION or Text Block block of parameters in the INTERACT definition.
ITP uses the standard Microsoft Windows fonts to display data in an INTERACT screen. These fonts might not contain all characters necessary to display the data, especially if the data is entered in a different language version of Microsoft Windows than the system used to display the INTERACT. This problem can be resolved by using a font that supports all characters used by the application. With the settings ITPINTERACTFONT=xxx and ITPINTERACTFONTSIZE=10 you can configure ITP to use font 'xxx' as the font to display its INTERACT screens.
Example
The 'Arial Unicode (MS)' font contains almost all possible characters which can be displayed in ITP WCHAR fields. This font is part of Microsoft Office and can be installed from any Microsoft Office media. If this font is installed, add the following settings to the Miscellaneous tab of the ITP/Administration program to use Arial for INTERACT screens:
ITPINTERACTFONT=Arial
ITPINTERACTFONTSIZE=10
It starts with a first declaration: the ANSWER_variable must be declared outside and before the INTERACT
The second declaration and initiation are for the array. If an array is used as the VALUES parameter it must be declared and filled outside and before the INTERACT:
TEXT, BOOL or NUMBER ANSWER_variable
TEXT or NUMBER VALUES_array[ ]
INTERACT "screentitle"
QUESTION "question-text"
LEN ( length-of-answer )
DFT "default-answer"
DATE
VALUES ( answer1;answer2;answerexpression; … )
ERRORCONDITION formula of type BOOL
MESSAGE "message-text"
HIDECONDITION formula of type BOOL
FILE
ANSWER variable or array element
Repeat the QUESTION block of settings to create more questions in the INTERACT.For ITP/Workstation up to 6 questions/Text blocks are allowed in one INTERACT
Instead of a question you can set a Text block. Questions and Text blockS can be combined in an INTERACT.
TEXTBLOCK "message-text"
ON ENTER
DO
model-part-with-declarations that will be processed when the INTERACT
is submitted.
OD
ON EXIT
DO
model-part-with-declarations that will be processed when the INTERACT is
canceled.
OD
An INTERACT consists of one or more questions and or Text Blocks. These are placed in an INTERACT by repeating the question or Text Block definition in the definition INTERACT.
Every INTERACT-statement must at least contain one QUESTION or Text Block.
The maximum amount of questions you can ask depends on whether the model will be run with ITP/Workstation or with ITP/OnLine Server. For ITP/Workstation, the maximum number of questions is six. For ITP/OnLine Server, the maximum number of questions is 65535 per INTERACT.
In ITP/Workstation an INTERACT statement will be shown to the end user as a dialog containing the questions, and the buttons and . The title of the dialog is the text set behind the keyword INTERACT. Each question in the dialog consists of the actual question, set with the keyword QUESTION, and a control that allows end user input. There are six types of controls:
Control displayed |
Triggered by |
Dropdown box |
ANSWER of type TEXT or NUMBER and VALUES set or |
Check box |
ANSWER of type BOOL. |
Textblock check box (left cursor) |
ANSWER of type TEXT; no VALUES set |
Textbox (right cursor) |
ANSWER of type NUMBER; no VALUES set |
Dateboxes (Three textboxes and a format specifier) |
ANSWER of type NUMBER, DATE set |
File selection box |
ANSWER of type TEXT, FILE set. |
The type of the parameter ANSWER determines what is shown to the end user and what is allowed as an answer.
Following the keyword INTERACT, you can set the title for the window that will be shown.
This parameter is of type TEXT; enclose its value in double quotes. ITP/Workstation: the title can be 60 characters long.
Note
Of a title longer than 60 characters only the first 60 characters will be visible in ITP/Workstation.
ITP/OnLine Server has no such limit.
An INTERACT consists of repeated QUESTION and/or Text Block parameter blocks, and one or none ON ENTER and one or none ON EXIT parameters.
Note
The parameters QUESTION and ANSWER required; all other parameters are optional.
Required.
This parameter is of type TEXT; enclose its value in double quotes.
This parameter is the question that will be displayed on the screen.
ITP/Workstation: a question can be 54 characters long (in fact it can be longer but only the first 54 characters will be shown).
Note
Of a title longer than 54 characters only the first 54 characters will be visible in ITP/Workstation. ITP/OnLine Server has no such limit.
Optional.
This parameter is of type NUMBER.
The maximum length allowed for the answer.
Default: 125 for TEXT answers, ( 15 3 ) for NUMBER answers.
When the variable ANSWER is of type TEXT, LEN stands for the permitted length in characters of the end users answer. The LEN setting is a number from 1 to 255.
When the ANSWER variable is of type NUMBER, LEN stands for the total permitted length in digits of the end users answer; this is a number from 1 to 15. It is also possible to determine the number of decimal positions allowed within the returned number. A space must divide the two numbers.
Example
QUESTION "question-text"
LEN ( 5 3 )
ANSWER variable_of_type_number_name
This will allow as an answer a number of 5 digits. Within this number, 3 decimal positions are allowed. Please note the space between the two numbers.
So, for instance, a valid answer can be:
12345 or 1234.5 or 123.45 or 12.345
In ITP/Workstation the setting LEN also controls the length of the controls shown in the interact screen.
Optional.
This parameter must be of the same type as the variable ANSWER.
The default answer.
This value is suggested as the answer when the INTERACT is displayed.
Note
When the DFT is not set but VALUES is set; the first value in the VALUES setting will be shown.
Optional.
If this keyword is present, the keywords DFT, VALUES and ANSWER will be treated as dates.
These have to be eight digits long and interpreted in the ITP standard date format YYYYMMDD.
DFT, VALUES and ANSWER must be of type NUMBER for DATE to work. Furthermore, DFT and VALUES must have a certain format. Refer to date for details.
The result as stored in the variable ANSWER is a number representing a date and not a date in text. To show the date in words in the result document, you will have to use the function date_in_words.
Note
When DATE is set the LEN setting is ignored.
Optional.
Type depends on the type of the ANSWER variable.
A list of values or expressions separated by semicolons (;) or an array.
Values or expressions set here must be of the same type as the ANSWER variable.
When set the end user is presented with a list of possible values from which one can be chosen.
Example
QUESTION ("Select a fine musician?")
VALUES ("Johnson A";"Franklin A";"Parker C";"Biafra Y")
ANSWER variable_of_type_text_name
When a VALUES list is used, the end user can only select one of the answers from the list. The interact will show the list as a dropdownbox: Johnson A, Franklin A, Parker C and Biafra Y.
When an array is used to set VALUES it must be declared and filled outside the INTERACT and before the INTERACT is defined. The array must be of the same type as the ANSWER variable.
MULTISELECT can be set when VALUES is a TEXT ARRAY.
Optional.
Formula of type BOOL
The ERRORCONDITION's value is calculated when the end user leaves the INTERACT window. When it is found to be TRUE the message is triggered and the end user is not allowed to leave the window.
Required when ERRORCONDITION is set.
When you leave the INTERACT screen/window the value of the error condition is calculated. If this formula is TRUE the message is displayed in a dialog.
Example
This example demonstrates the use of an error condition and the message that needs to be shown when that error condition is met.
#BEGIN
NUMBER answer_number
INTERACT ("Guess a number")
QUESTION ("Please, enter a number.")
LEN (2 0)
ERRORCONDITION (answer_number < 2 OR answer_number > 5)
MESSAGE ("------- I'm sorry; you lost. --------")
ANSWER answer_number
#
The winning number was: @(answer_number).
#
END#
Optional.
Formula of type BOOL.
Before the window INTERACT is shown the value of the HIDECONDITION is calculated. If the formula is TRUE the question is hidden.
If a QUESTION is hidden its ANSWER will contain the value DFT, or when no DFT is set it will be empty for a TEXT ANSWER, 0 for a NUMBER, and FALSE for a BOOL.
Even if all QUESTIONs are hidden the INTERACT itself will still be shown. This method that can be used to conditionally show an INTERACT.
Note
This mechanism cannot be used to show questions conditionally depending on the answer to a previous answer, because the HIDECONDITIONS are evaluated before the INTERACT is shown.
Optional.
This keyword is specified without a value.
This keyword places a file selector in the window INTERACT in which the end user can select a file from the file system.
Note
The variable ANSWER or array-element in which the interact answer is stored must be type TEXT if this keyword is used.
Required.
This parameter must be a variable name or array element.
This parameter must be the last in a question block i.e., a question definition starts with QUESTION and ends with ANSWER.
Following the ANSWER keyword you must specify a variable or an array-element, in which the answer to the question will be stored. This variable or array- element must be declared prior to use.
The type of the ANSWER variable also determines the control shown in the interact dialog.
When an end user closes the window INTERACT by pressing F3 (Exit) or clicking the button , the answers present on the screen will not be stored. The values stored in the variables or array elements will still be the values that were stored in them prior to execution of the statement INTERACT.
If an ON EXIT is specified the model part specified between DO and OD will be executed when pressing F3, or clicking.
When no ON EXIT- and no ON ENTER-line are specified, ITP will continue executing the model-part that follows the statement INTERACT.
When an end user has completed the window INTERACT and presses key the Enter or clicks the button , an extra Enter to confirm input will always be needed. The answers present on the screen will be stored in corresponding ANSWER variables or array elements.
If an ON ENTER is specified the model-part specified between its DO and OD will be executed after is pressed.
When no ON EXIT- and no ON ENTER-line are specified, ITP will continue executing the model-part that follows the statement INTERACT.