TK-Form Manual

table of contents

(main)



SECTION 4 - Creating and Editing Forms

The main menu of TK-FORM is accessed by invoking the following code:

D ^TKFORME
The suffix "E" is for "Edit".

The following menu now appears on your screen:

Notice that the selector comes to rest on the first item, Edit Input Criteria. You may move the selector up and down with the cursor keys or you can press the letter of the desired option. If you have selected "RETURN Required on Menus" in the ^TKINIT initialization routine, then you will also have to press the RETURN key after you press the letter.

Each of the menu items are briefly described below:
MENU OPTION DESCRIPTION
E Edit Input Criteria Enables direct access to the editing of Form Attributes and Field Attributes. Form Drawing can not be edited from this menu option.
B Build Form Format Enables the entering and editing of Form Drawing, Form Attributes, Fields, and Field Attributes.
L List Forms Displays Form Series name, Form Number, and Title of each form in the TK-FORM system.
C Copy Form Duplicates selected form; this feature can be useful when modifying and saving forms.
P Print Form Detail Prints Form Attributes and Field Attributes of selected form.
D Delete Options Purges an individual field or an entire form.
R Recompile All Forms Builds all the internal control information required to invoke forms. Note: this is to be used according to vendor instructions when installing updates to TK-FORM, or when adding new types of terminals to your TK-FORM system.
I Invoke SAMPLE Forms Provides user with option to run the set of SAMPLE forms provided with your TK-FORM package.
O Original SAMPLE
Forms Rebuild
Provides user with option to restore the SAMPLE forms to original specifications.
T TK-SCHEMA Data
Dictionary
Optional data dictionary utility that enables the system designer the ability to define all the data definitions before using the TK-FORM Build Form Format option.
M Maintenance
Utilities
Other utilities for site specific parameters, exporting forms and providing global cross references.
Q Quit Exits the forms editor ^TKFORME.

4.1 Creating the Form

Choose the menu item, "B Build a Form Format", and press RETURN. Another screen with the prompt, "Enter the Form Series", will appear. Up to ten alphanumeric characters may be entered to describe a form series.

Enter the Form Series ___________

Enter the Form Number __________

If you enter a "?" at either prompt, TK-FORM will list the series or numbers which currently exist.

Edit Key Reminder

Remember that you may use the cursor up, cursor down, cursor left, cursor right, insert character, delete character and rubout (del) keys anywhere while using TK-FORM. Although their use may be limited in certain situations, it is helpful to remember that you don't have to retype entries, but that you can edit the current contents.

Once a Form Series name is entered, you will be prompted for a Form Number. The form driver will $Order through the form numbers, so that these form numbers need not be serial numbers. Up to ten characters may be entered. Enter a number and press RETURN. You will be asked to confirm that it is a new form. Press RETURN again to continue.

4.2 Form Attributes

The first screen of the edit and build options is the Field Attributes screen as listed below:

Title

The title may have up to 40 characters. The title should be carefully chosen to reflect form content, since it is this title which is added to the menu allowing users to select among different forms within a series.

Data Video Attributes

You may choose to display fields or data that has been entered on a form in one or more of the following video attributes:

R - Reverse Video
H - High Intensity
U - Underlining
"." ............

Default = Normal Video Display

Edit Video Attributes

Video attribute options for data that is being entered or edited include any of the following:

R - Reverse Video
H - High Intensity
U - Underlining

Default = Normal Video Display

Edit Position

R - Right
L - Left

Default = Left

You can choose to place the cursor to the right or to the left of the data entry field for a given data element. We recommend placing the cursor at the left of the field for most data entry operations: it is easier for the eye to find the cursor in a consistent, predictable position than in a dynamic one (such as that at the end of a field).

Display Code (eXecutable)

This is a line of optional MUMPS code which is eXecuted by the TK-FORM driver. If no code is entered, the driver clears the screen prior to painting the form. If MUMPS code is entered, the screen is not cleared by the driver.

Pre-Edit Code

This is a line of optional MUMPS code which is eXecuted by the TK-FORM driver once the screen is painted and the data is displayed. If the screen is run in "Q" mode, QUIT mode (see section 5.2), this code is not invoked. If the edit control question is invoked prior to data editing, this code is invoked after the edit control question. If the edit control question is answered "Q", quit, by the user, then this code is not invoked.

The purpose of this code is to allow pre-processing of the screen. For example, it will typically be used to deactivate a field prior to any editing.

Pre-Filing Code

This is a line of optional MUMPS code which is eXecuted by the TK-FORM driver once data entry is completed but prior to filing. If the screen is run in "Q" mode, QUIT mode (see section 5.2), this code is not invoked. If the edit control question is asked and its answer is not "C", cancel, then this code is invoked.

The purpose of this code is to perform final edit checks before filing the data. For example, you can perform a tie-out of detail to a batch total. Another example is checking a number of fields for functional dependencies, something which might be too difficult on a per-field basis during data entry because all the values are not present, thus it is easier once all of the data has been entered.

If the PRE-FILING code returns $T=FALSE, TK-FORM returns control back to editing. Your application may use the variable named "er" to pass an error message back to TK-FORM. TK-FORM will display this error message on the bottom row of the screen prior to commencing with re-editing.

If the PRE-FILING code does find an error, it may specify the field to start re-editing. The field may be targeted if the PRE-FILING CODE invokes the TK-FORM BRANCH operator, thus naming the field to branch to (see TK-FORM Operators). If no field is targeted, editing resumes at the first field on the form.

Another use of the pre-filing code might be to KILL the MUMPS record before the filing. This might be necessary for grouped data (see Section 6).

Post-Filing Code

This is a line of optional MUMPS code which is eXecuted by the TK-FORM driver once the data entry has been completed and the data has been filed. If the screen is run in "Q" (QUIT) mode (see section 5.2), this code is not invoked. If the edit control question is asked, this code is invoked unless the response to the edit control question is "C" for cancel.

The purpose of this code is to allow inter-form data manipulation and/or control. The edited data can be inverted, keyed, computed, etc., or the form series control may be altered, e.g., the series may be terminated or the series may branch to a specified form in the series apart from the original series order.

Force Window Compile

If a program is invoked which is not part of the TK-FORM package, and which paints a display foreign to TK-FORM, then Force Window Compile should be answered YES to refresh the screen. By compiling the window and properly invoking the foreign display, TK-FORM will refresh its own display once the foreign display is removed. See section 4.6, Refreshing the Form, for instructions on how to manually refresh the display.

Please note that you can only change this question if you entered via "B Build Form Format". Changing Force Window Compile from "E Edit Input Criteria" has no effect because TK-FORM must have its control files for a form's drawing built in order to compile windowing.

If the form has Table fields that contain pop-up menu parameters in the Menu Parameters line, then TK-FORM will force a window compile automatically.

Conserve Symbol Space

Depending on your MUMPS implementation, you might have a local variable storage problem. If you do, answer "Y" to this question. TK-FORM will optionally use the scratch global ^TKF($J).

Optional MUMPS Display Routine

For some MUMPS operating systems it is more efficient to execute routine lines than to execute from globals. Since TK-FORM contains all of its screen information in globals you may choose to have the display, fetch and put logic in a MUMPS routine. If so, enter the name of the routine that you want it stored in.

Optional Screen Timeout

You may specify the length of time in seconds that the user can be inactive within a form. Once the time has expired, all screen processing will cease as if the user had pressed "EXIT" and then the "CANCEL" Edit/Control question option. No data will be stored and any post processing that might exist will not be executed. TK-FORM will indicate that it has timed out by returning "C-TIMEOUT" in the return control piece of the tkform variable.

In order to establish a timeout period, enter a numeric value equal to the number of seconds allowed for inactivity. Remember the timer is started over each time the user performs some operation in the form.

4.3 Painting the Form

Once the Form Attributes are complete, TK-FORM allows you to paint the form. Note that TK-FORM reserves the last two lines of the form for error messages, help text, general directions, and edit control questions. These two lines appear at the bottom of the form painting screen:

Screen: Video Mode: Control Keys: E(Erase Line), F(Fields), L(Lines), V(Video), X(eXit)

Moving the Cursor: (Cursor Step Keys)

Text can be moved and entered anywhere on the screen (even on the bottom line). The cursor is moved with the cursor keys. The RETURN key moves the cursor to the left side of the screen on the same line. Notice that the current row and column position is displayed on the bottom line of the screen. You may be tempted to use the space bar to move the cursor to the right, but remember that if you space over text or graphics already on the screen it will be erased.

Video Modes: (Control V)

The screen is first initialized to the TEXT mode in normal video, high intensity. Everything typed on the screen will be displayed, stored and displayed again in that mode. The video mode may be changed at any time by pressing the Control V key. The cursor will jump to the bottom line and you will be asked to enter a R, H, or U for Reverse Video, High Intensity, and Underline. You can simply press RETURN to change the video mode to normal video, low intensity; or you can enter one or more of these letters to switch on the corresponding video characteristic. Every character typed on the screen after switching the video mode will then be displayed in the new mode. The mode may be changed at any time within a form.

NOTE: Some terminals use Control V for cursor positioning. Control W may be used as an alternate control character to change the video mode.

Line Drawing: (Control L and Control E)

As mentioned, TK-FORM is initially set up in TEXT mode. You may change to the LINE mode by pressing the Control L key. In the LINE mode all keys on the keyboard will work as in TEXT mode except for the cursor keys. In LINE mode the cursor keys can be used to draw lines on the screen. You may change back to the TEXT mode by pressing Control L. You may remove any line drawing by spacing over it. To erase continguous lines, place the cursor on the line to be erased and press Control E, for Erase.

NOTE: Some terminals use the Control L for cursor positioning. You can use control Control G as an alternate control character to toggle the line drawing mode.

Positioning a Field: (Control F)

You place data fields on the the screen by moving to the correct position and then marking the spot by pressing Control F. Once Control F is entered, TK-FORM asks for a field identifier. Enter an all-alphabetic name to identify the field. The Field Attributes are then entered. Help text is available by pressing "?". See section 4.5 for a discussion of Field Attributes. TK-FORM will scroll through the field attributes at the bottom two rows of the screen. Once the mandatory fields are answered, you may elect to press TAB to terminate answering the field attribute questions.

If you have defined your data elements using TK-SCHEMA, you need only enter the TK-SCHEMA name in place of the data identifier. You indicate that you are using a TK-SCHEMA name by enter a "^" character first followed by the data dictionary name. TK-FORM will then pull the necessary Field Attributes from the TK-SCHEMA file and insert it into your form. Some of these attributes may not be modified in TK-FORM.

When defining a new field, TK-FORM will ask you if you want to copy the attributes from another field within the screen. If so, enter the name of the field, otherwise just press RETURN.

Exit Drawing: (Control X or R)

Once you have completed drawing and placing data fields on the screen, press Control X to enter the editing order of the fields. You define the field editing sequence. This sequence may be changed at any time. TK-FORM will now compile your form. While your form is compiling, you will see each CRT type listed as its form is being compiled.

4.4 Declaring TK-FORM Variables

TK-FORM first paints a form and then allows data entry or editing. Each data field may have many optional operators invoked before the field is painted; or before, during, or after it is edited. The operand for these operators is the variable X. Most of the operators are eXecuted. Since they are eXecuted, you must take the precaution of maintaining TK-FORM's scope and communication methodology.

Variable X

Variable X may be altered by most of the operators. The operators must not KILL the variable X.

Variable Collision

If an application program is invoked by the operator, care must be taken to protect the scope of TK-FORM. The easiest technique to accomplish this is to invoke NEW at the beginning of the operator. For example, if the field is a date field, and the VALIDATION operator is to check for a valid date with your MUMPS routine ^GOODDATE, it should be as follows:

NEW (X) DO ^GOODDATE

This maintains all of the variables in TK-FORM.

NOTE: It is possible to avoid using NEW to maintain variable scope. Some implementations of MUMPS are slow in executing the NEW command so you may choose to use the following guidelines:

1. Most of TK-FORMs internal variables consist of one-to-three character variable names beginning with a lowercase letter.

2. Those variables not following this convention include: A, B, C, D, E, I, J, L and TK
as well as those control variables mentioned in the following section.

3. You will need to also watch any variables that you may define for subscripts, flags, display only, etc.

TK-FORM Control Variables

See ^TKDEV for a description of the TK array. This array contains all of the video attributes.

TK-FORM uses the following variables as control variables:
I = a TK-FORM system variable. DO NOT USE within a form! NEVER CHANGE THE VALUE OF I!
REFRESH = refresh region; see discussion in section 4.6.
RX = read X terminator. Described below are the results of RX assuming the following values:
= -1 ; moves to the previous field;
= n ; where n is a negative integer, will jump backwards n fields;
= -1000 ; will return to the first field;
= 1 ; will jump forward 1 field;
= n ; where n is a positive integer, will jump forward n fields;
= 1000 ; will jump to the end of the screen.
NOTE: if RX is set in a field attribute, RX may override the user's function key intention. For example, if the user finishes editing a field with a cursor up key, and a field attribute sets RX=5, TK-FORM will jump forward five fields rather than jump backwards one. To resolve this, the code which set RX=5 should be as follows:

S RX=$S(RX=1:RX=5,1:RX)
SCR = form series name
SN = current form number
SNL = form number list, see section 5.3, Form Order, for more information.
TKP = cursor positioning, used with %R and %C. Invoke with "W @TKP".
Y = the current field's data. See ^TKFRMEA for documentation. DO NOT CHANGE.
ZF = a system variable.
%C = when present, the current column or beginning of field, counting from 1.
%R = when present, the current row, counting from 1.
ESCAPE = TKFORM escape control allowing a quick "escape" from the screen temporarily. See section 5.4.
ECTL = optional Edit/Control Question wording.

4.5 Programming Field Attributes

The next screen displayed by TK-FORM allows you to set field attributes. If you have left the TK-FORM sequence followed in this manual, remember that you can access this screen by invoking the TK-FORM editor:

D ^TKFORME
You then select menu item "E Edit Input Criteria" and press RETURN after the Form Attributes screen. The Field Attribute screen is now displayed:


NOTE: The back apostrophe, ASCII decimal 96, is used as a TKFORM delimiter and is not allowed as part of any answer for any attribute. You may use the "$C(96)" syntax to get around this limitation if necessary.
TK-FORM FIELD ATTRIBUTES
Attribute Description
REFERENCE MANDATORY. Any legal MUMPS global or local variable from where the data will be fetched or stored. All subscripts used must be defined external to TK-FORM. Examples:

1. ^ROLODEX(ID,"NAME") might be the name in a rolodex.
2. NAME might contain an individual's name.

All of the fields in the SAMPLE forms have references.

$PIECE If the data is to be pieced out of the above reference, enter the $Piece syntax, such as $P(X,"^",3).

See form SAMPLE-1, field NAME, for an example.

You may also nest $PIECE functions to reference a subset of a piece, such as $P($P(X,"\",3),"^",1).

LENGTH MANDATORY. Enter the allowable data length, a value from 1 to 80. This determines the number of characters that the user may enter.

An optional comma and value may follow the length to provide for right justified numbers. The syntax is similiar to the arguments of the $JUSTIFY MUMPS function so that a value of "12,2" in the length attribute would format the data right justified in a field of 12 characters with 2 places to the right of decimal point. Right justified values shift left when edited.

PATTERN MATCH String compare or match to validate input, such as:
X?1.3U or "YN"[X or X?3N,X"300,X"600
This expression will be invoked as "IF @pattern". Not invoked if X is nil.

See form SAMPLE-1, field ZIP, for an example.

MANDATORY Enter Y for YES, to indicate that the answer must be returned. This is checked at the completion of the form.

Enter R for real-time require: TK-FORM will not continue to the next field unless this field has an answer.

Note that a "M" flag is displayed at the lower right corner when the field is entered for editing.

For fields which are multiples and mandatory, TK-FORM only checks the first occurring item of the multiples to see if it was answered. If a user answers the first occurance as nil but completes other occurances, TK-FORM will consider the field as not answered. Use the "C" flag in the multiple parameters to force a check on each item.

See form SAMPLE-1, field LAST, for an example.

DITTO If this field is to be duplicated from another on the screen, enter the field identifier of the source field. For example, assume that HOME PHONE is identical to WORK PHONE, and that HOME PHONE appears prior to WORK PHONE on a form. During editing WORK PHONE, the user may press the DITTO function key; HOME PHONE then will be copied and displayed in WORK PHONE.

Note the "D" flag in the second to last row.

See form SAMPLE-2, field RADDR, for an example.

TAB STOP Enter Y if you want a TAB stop at this field. It functions in the same way as a TAB stop on a typewriter. Good candidates for TAB stop fields include any fields which are edited frequently, or which are at the beginning of a logical group of questions.

See form SAMPLE-2, field RNAME, for an example.

HELP/ERROR
REFERENCE
,
Enter the HELP or ERROR references as are required. The format for each reference is the same and is as follows:
OPERAND;OPERATOR;PARAMETER
There are four formats that are allowable for either the HELP or ERROR references:

1. ^GLOBAL

This format will display the contents of the global on the bottom two lines of the screen. The default operand is a "W" for write and there is no parameter

2. ^GLOBAL;;TKPOP MENU PARAMETERS

Displays the contents of the global in a pop-up window rather than the bottom. TKPOP parameters define where and how the pop-up should look.

3. ^ROUTINE;D;OPTIONAL PARAMETER

The referenced routine is executed and the optional parameters are passed to the routine in the variable "hp". These parameters may be the error code, number or other context sensitive information.

4. STRING;X;OPTIONAL PARAMETER

The referenced string is eXecuted and any optional parameters are passed in the "hp" variables.

If either the first or second formats are used, the variable operand may be any legal MUMPS variable name, where operand(0) is the number of lines of the message and those lines are found in operand(1...n), such as ^HELP("NAME"), where:

^HELP("NAME",0)=2
^HELP("NAME",1)=Here is some NAME help.
^HELP("NAME",2)=To demonstrate a HELP MESSAGE
TK-FORM automatically refreshes the screen after displaying formats 1 and 2. In formats 3 and 4, if your MUMPS code changes the appearance of the form, then it is up to you to refresh it after your routine is finished. Please refer to Section 4.6, Refreshing a Form. Note that %R and %C are valid and point to the current field.

Other HELP/ERROR reference notes:
1. If you want the same message for both the HELP and ERROR conditions, enter only the HELP reference.
2. If you want separate messages - then provide two references separated by a "/".
3. To suppress the ERROR message, follow the HELP reference with a "/".
4. To suppress the HELP message but still enable the error message, enter "/" followed by the ERROR reference.
5., When a field has no HELP reference, two different messages are invoked if HELP is pressed. If it is a multiple, general instructions for a multiple appear on the last two lines of the screen. If the field is not a multiple, a "Sorry..." message appears in the same place.
6. When no error instruction exists, TK-FORM displays appropriate error messages on the bottom two lines of the screen.
7. If the HELP/ERROR reference executes the user's MUMPS code and that module changes the value of X for the purpose of putting X, then the module must perform two secondary effects. One of these effects is that it must change RX to a valid jump value. Assigning RX results in processing X for a put. The other effect is that X must have the format:
put value_"`"_display value

(where the delimiter is an ASCII 96)

For example, if a help module is returning an ANSI date and is to continue to the next field, then help should set:

S RX=1,X="52961`01/01/86"

where RX tells TK-FORM to continue to the next field, $P(X,"`") is the put value for the current field, and $P(X,"`",2) is the display value. The display value is displayed and the put value is put by TK-FORM before TK-FORM proceeds to the next field. TK-FORM Help/Error processor does not perform the TK-FORM PUT TRANSFORM, PATTERN MATCH, or the VALIDATE. TK-FORM assumes HELP/ERROR will perform these.

Some HELP/ERROR reference examples:

^help("NAME") Displays a message in the bottom two lines of a form for HELP or for an error. The message is scrolled through if it is longer than two lines.
^help("NAME")/, Same as above but for HELP only.
^help("NAME");;
\YRL\1\Name/
Help in a TKPOP window
/^error("NAME");;
\YRH\1\Error Message
Error message in a TKPOP window.
^help("NAME")/
^ERROR;D;NAME
Help in bottom two lines of screen. Errors invoke the program ^ERROR with the variable par="NAME".
See form SAMPLE-1, field NAME, for an example of help text in the bottom two rows.

See form SAMPLE-2, field RNAME, for an example of pop-up help text that is refreshed.

DISPLAY ONLY &
INPUT TYPE
The field may be designated as a display only field or have specific input characteristics. The following parameters change the use of the field as follows:

Y Display Only Field - the user cannot edit this field
N Normal Input Field - this is the default type for the field
A AutoReturn Input Field - forces a carriage return when the last character is typed in the field. You may use this on short fixed length fields where pressing RETURN between fields does not make sense.
P Password Input Field - TK-FORM will suppress character echo for the duration of the field to allow for the entry of user passwords and other data that should not be seen on the screen.
K Key Input Field - key input fields are processed before the remaining fields are fetched and displayed. This enables you to design screens where the subscript for the data comes from the key input field. Note that the key fields are only processed once for each screen and are outside of the Edit/Control Question loop (see the following "R" modifier).
R Repeat Modifier - if the field is a key input type, an "R" modifier will allow the user to go back to the key field upon the completion of the screen. This will happen regardless of the outcome of the Edit/Control Question. Returning a key of null or by pressing the EXIT function key will then exit the screen.
See form SAMPLE-2, field PNAME, for an example of display only.

TABLE ATTRIBUTES The following five attributes are used when defining a table lookup field. A field is designated a table lookup field if there is a variable reference in the TABLE LOOKUP-REFERENCE attribute. If it is blank, then all other entries in these five attributes are ignored.

There are currently six types of table lookups and each one has slightly different parameters. Section XX summarizes each of these types and how they are used and you will find a more detailed explaination of these attributes listed there.

TABLE PARA\
MNEMONIC REF
This two part attribute defines the TABLE PARAMETERS and an optional MNEMONIC REFERENCE which is delimited from the parameters by a "\" (ASCII 92).

Allowable parameters are: 0,1,2,3,4,5,A,D,F,H,K,L,V

See Section XX for a more detailed explaination of each of these parameters.

The MNEMONIC REFERENCE is only used in Type 1,2,3 and 5 tables where the displayed mnemonic is not the contents of the TABLE REFERENCE, but is another reference or is a $P or $E of the TABLE REFERENCE.

TABLE LOOKUP
REFERENCE
The TABLE LOOKUP REFERENCE is a variable reference that is used by TK-FORM to validate the user's entry and display the referenced table item on either the screen or in the pop-up menus. This attribute is manditory for table fields.

Table types 1,2,3 and 5 use the TABLE LOOKUP REFERENCE in the lookup logic and validation, and use the TABLE REFERENCE in the display logic.

TABLE REFERENCE This attribute is used with table types 1,2,3 and 5 to provide an alternate reference that can be accessed directly by the table code. It is not used by types 0 and 4.

See Section XX to see how it is used.

TEXT LENGTH &
REFERENCE
To display the text of the table to the right of the field input, enter the length of the display area. If the text is to be altered prior to its display, include the appropriate MUMPS code in this format:

length,MUMPS FUNCTION

For example, if the fifth piece of a string is to be displayed in a 20 character field, enter:

20,$P(^TABLE("RELIGION",X),";",5)
The "L" parameter in the TABLE PARAMETERS will cause the text to be left justified within the text field.

See form SAMPLE-2, field PREL, for a simple example. See form SAMPLE-2, field PMAR, for an example with a MUMPS function.

MENU PARAMETERS The TKPOP parameters to allow a TKPOP window to appear when HELP is pressed for table lookup. The format is:

column,optional row\flags\# columns\title\

where flags are:
B = Bottom (pop-up)
C = Current row+1. Note: if the window does not have enough room between the stated row and the bottom of the screen, the window appears above the field. PLEASE NOTE: this is different from the "row+1" of TKPOP.
R = Reverse video
L = Line border
H = High intensity
W = Write only
T = Top (pull down)
Note that if no column is specified, the current column is used. If no row is specified, TK-FORM will use the top row for T, pull-down, and the bottom row for B, pop-up.

See Toolkit I, TKPOP, for a more thorough discussion.

See form SAMPLE-2, field PREL, for an example.

PROCESS ACK Process Acknowledgements, Yes or No. TK-FORM normally skips processing a field if an answer had no editing activity. If answered yes, the field is always processed, i.e., pattern match, validate and put transform always occur as they are described.

No current example in the SAMPLE forms.

VALIDATION CODE Enter eXecutable MUMPS code if additional validation of the input, X, is required. The code should set $Truth to true if the answer is valid, false if it is invalid. Nil answers are checked. Please see MULTIPLE ITEMS (defined in this section) for varied behavior of these parameters.

See form SAMPLE-3, field DOD, for an example.

FETCH TRANSFORM Enter eXecutable MUMPS code if X is to be modified before it is displayed on the screen. This code is always executed at least once when the screen is first displayed, and then again everytime the value of field is edited.

An example of a FETCH TRANSFORM would be to transform a date stored in $Horolog format to a calendar format prior to the date being displayed on the screen.

See form SAMPLE-3, field DOD, for an example.

PUT TRANSFORM Enter eXecutable MUMPS code if X is to be modified after it is entered or edited by the user and before it is "put" into the database. An example might be transforming a calendar format date into $Horolog format.

The PUT TRANSFORM is only executed if the field is edited or if PROCESS ACKNOWLEDGE is on.

See form SAMPLE-3, field DOD, for an example. In this particular example, please note that since VALIDATE was required to perform a transformation in order to perform a date check, VALIDATE has a secondary effect of leaving the transformed value in the variable ANSIDATE. Thus, the PUT TRANSFORM simply has to pick up the already transformed value rather than transform it again.

MULTIPLE ITEMS A field may be designated as a multiple by defining parameters effecting the display, storage and editing of the multiple. The format of this parameter string is an eight piece string as follows:

V or H, # display, V or H, inc, # max, W or C, J or S
Parameter Description
1 Display: Horizontal or Vertical
2 # of items to display originally.
3 Storage: Horizontal or Vertical.
4 Increment between lines (Vertical storage)
5 Maximum # of items.
6 W=Wrap on.
C=Check each item.

Note that you cannot check if wrap is on. C is necessary if field is a table reference. Nil allowed. If C is not the value, and validation occurs, X is the first item. Transformation occurs for each item regardless of parameter 6.

7 Miscellaneous Flags

S=Strip empty trailing lines. If the user does not enter the maximum number of lines, TK-FORM will still pass back to the application the maximum number of lines unless this flag is set.

J=Jump Out of Field on Last Line. Without this flag, TK-FORM requires the user to press a TAB or EXIT to terminate editing a list. This flag lets the user exit a list on the last line by pressing carriage return or cursor step down.

These flags may be combined.

8 Put Multiple Count Reference.

If a count of the total number of lines entered by the user is required by the application, enter the reference here. Include any $Piece information, e.g., $P(^TKFORMS(ID),";",4) would put the count for a list in the 4th semi-colon piece of ^TKFORMS(ID). NOTE 1: the Strip flag, para 7, must be set. NOTE 2: TK-FORM is not a database manager. It is important that your application check the count before and after a form is invoked. If the old count exceeds the new count, you may want to remove the remaining old lines from your database. If you KILL the entire record with the PRE-FILE execute, then you do not have this problem.

See form SAMPLE-1, field ADDRESS, for a "Wrap off" example.
See form SAMPLE-1, field REMARK, for a "Wrap on" example.
See form SAMPLE-3, field CONSULT, for a "Check" example.

WINDOW Not implemented.

4.6 Refreshing the Form

If a field operator needs to refresh the form, it may do so by invoking AP0^TKFORM4 with a DO. The refresh code requires the following parameters:

REFRESH=Starting row:ending row

The rows must be inclusive. REFRESH will be killed by AP0. The rows must be counted from home, starting at 1. For example, if:

REFRESH=5:14

then rows 5 through 14 will be refreshed if AP0^TKFORM4 is invoked.

The form attribute Force Window Compile must be answered YES.

The refresh module requires TK-FORM's scope. The refresh module will not work if you invoke it within your application's NEW.

4.7 TK-FORM Operators

TK-FORM has an instruction set which may be accessed via the eXecuted MUMPS code from the Field Attributes, or via the modules invoked by these attributes. The variable "opi" is assigned the operator and its operands in the following format:

operator;field id;reference

The reference is the MUMPS reference used to return or send any values associated with the operation. For example, the operator FD (fetch the current display value for a field in TK-FORM) would return the value in this reference. The reference may contain valid $Piece syntax such as $P(^MYGLOB(S1,1),"^",4) or $P(NAME,"\",12) if the value is to be fetched or stored from a delimited reference.

These instructions do not change the value of $T.

To process the instruction, eXecute the MUMPS variable "op".

If a field is a multiple (see TK-FORM Field Attributes section), and data are being put or fetched from the screen, then the instruction format is:

operator;field.multiple;reference

This syntax would not be used for the Activate, Deactivate, Mandatory, Required, or Not Mandatory operators which relate to an entire field. The first instruction set format identified in this section would be used for these operators. The multiple is the occurance in the multiple answers which is of interest. Multiples start counting from one inclusively. The occurance identifer is the multiple suffix of the operand.

For an example of an instruction with a multiple suffix, consider that many forms have a field called REMARKS. This field typically is a multiple since it allows and displays many lines of text. Often remarks utilize standard phrases. To place the phrase "BAD DEBT" in the first line of REMARKS, use the following MUMPS code:

S LINE1="BAD DEBT",opi="PDSP;REMARKS.1;LINE1" X op
The eXecuting of op results in "BAD DEBT" being put into the display data and the stored data, and being displayed on the form in the first line of the REMARKS field.

The above instruction should be placed in a field which preceeds REMARKS. Its exact location may vary within the selected preceeding field: the instruction may be placed in the VALIDATE or PUT attribute since these attributes are eXecuted. If the latter two attributes invoke a MUMPS program, then the MUMPS program might incorporate the TK-FORM instruction.

When using the PUT and FETCH operators with multiples or groups, remember that you can only PUT or FETCH to items that have been displayed. The Form Attribute called Force Window Compile must also have been answered "YES".

TK-FORM Operators
Operator Description
A Activate a field. TK-FORM fields start as active fields, but may be deactivated by the deactivate operator. The activate operator takes a deactivated field and activates it. The multiple suffix is ignored. No reference.
AM Activate and make Mandatory. Combines the operators Activate and Mandatory into one instruction.
AR Activate and make Required. Combines the operators Activate and Required into one instruction.
B Branch to the identified field. This operator changes RX, so it may not work if the application code also changes RX after op is invoked. The multiple suffix is ignored. No reference.
C Cancel and return. Cancels current field and form. No data is stored and the control is returned back to the calling routine with a "C" in the return code of tkform.
D Deactivate a field, i.e., remove it from the list of fields which may be edited. The multiple suffix is ignored. No reference.
DN Deactivate and make Not Mandatory. Combines the operators Deactivate and Not Mandatory into one instruction.
FD Fetch Display Value. Fetches the current displayed value in TK-FORM for the identified field. Requires a return reference.
FS Fetch Store Value. Fetches the current stored value in TK-FORM for the identified field. Requires a return reference.
M Mandatory. Makes a field mandatory. The multiple suffix is ignored. No reference.
N Not Mandatory. Changes a previously mandatory field to one that is not mandatory. The multiple suffix is ignored. No reference.
PD Put Display Value without painting the value on the screen. Puts the value from the reference into the identified field for the display. Example: if a field is a date, the displayed value is in calendar format rather than $Horolog format. Thus, if the field's displayed value must be changed, this instruction would change the displayed value but not the display itself. Requires a source reference.
PDP Put Display Value with Paint. Same as above, but also paints this value onto the screen. PDP changes the displayed value as well as the display.
PS Put Store Value. Puts the value from the reference into the identified field's storage. Example: the $Horolog format for a date.
PDS Put the Display and Store Value without painting the value on the screen.
PDSP Put the Display and Store Value and Paint on the screen.
R Real-time required mandatory. Makes a field real time required mandatory, so that TK-FORM will not continue to the next field unless this field is answered. The multiple suffix is ignored. No reference.
V Validate. Executes the validation code for the designated field using the value stored in the reference as X.
X MUMPS eXecute. Special instruction format:
X;;MUMPS code to be eXecuted
Operator Example:

Given the example of a transaction entry system with the following fields: TRANSACTION CODE, FEE, COMMENT. Assume the codes are from the list ^trans(code)=description;fee. If the fee piece of the data is nil, then the fee is to be asked. The problem is that this must be determined after CODE is answered. Therefore, CODE should have PROCESS ACKNOWLEDGEMENT answered YES. CODE's PUT TRANSFORMATION should invoke a module which does the following if FEE is not to be asked:
1 S opi="PDSP;FEE;$P(^trans(X),"";"",2)" X op
;This will put the FEE into the display and into storage
;actually displays the FEE in the FEE's field.
2 S opi="D;FEE" X op
;FEE is deactivated. It will not be asked. CODE will
;proceed to COMMENT. If the cursor up key is pressed in
;COMMENT, TK-FORM will move to CODE, not FEE, since FEE is
;deactivated.
To make this truely useful, the PUT TRANSFORMATION module needs to do the following, which would be invoked instead of the code found above:
0 I X]"",$P(^trans(X),";",2)]"" G 1
S opi="FS;CODE;OLDX" X op ;fetch the current code into OLDX
I OLDX]"",$P(^trans(OLDX,";",2))]"" S opi="A;FEE" X op
;the above makes sure FEE is active
Q

4.7.1 TK-FORM Operators: A Program

If many instructions must be invoked, a TK-FORM program may be written. The TK-FORM program has the following format:
opi = n, the number of instructions to be invoked
opi(1) = first instruction
opi(2) = second instruction
.
.
.
opi(n-1) = n-1 instruction
opi(n) = n'th instruction
Once this TK-FORM program has been written, eXecute "op" to invoke the program.