|
» |
|
|
|
Once you have created a form and saved it in a forms file,
you can create an associated application-ready buffer (ARB) for
that form. There are two steps to the process; first, you must set
up a data type conversion (DTC) record, then you can generate the
ARB. The DTC record need only be set up once for the entire forms
file. You may want to transform data between the screen and application
for several reasons. First, the data the application will store
may differ from what appears on the screen: menu-selection and next-screen
fields, for example, would normally be excluded from the ARB. Conversely,
you may want to store data from a source other than the screen,
such as key fields for an IMAGE dataset, along with the screen data.
This can be done by using "filler" fields, fields that exist on
the ARB but not on the corresponding form (see RES below). Second, the order in which the application stores data may
differ from the order in which it is entered on the screen. An arrangement
of fields that makes logical sense to the user may not be suitable
for a database, for example. Fields can be rearranged on the screen
without affecting their order on the ARB, and vice versa. Third, data type and length may differ from screen to ARB,
and the designer uses the ARB screens, in conjunction with the Data
Type Conversions Menu, to specify conversions (see discussion under
"ARB Data Types"). Figure 3-25 “Menu Sequence for ARB Feature” shows the sequence of menus used
to create, modify and delete an ARB and the fields on it. Figure 3-25 Menu Sequence for ARB Feature Setting Up the Data Type Conversion Record | |
The data type conversion record allows the forms designer
to define the default values for screen and ARB data types. You
must define these values, even if you only press ENTER to accept FORMSPEC's preset defaults, shown in Figure 3-27 “Data Type Conversion Menu” You will probably want to replace some, if not all,
of these defaults with your own. Set up the data type conversion record by following these
steps: Make sure you are at the FORMSPEC Main Menu and select G for "Go to Globals Menu". when you press ENTER, the Globals Menu is displayed. Enter Y for "Define Data Conversions" in the last box. The Data
Type Conversions menu is displayed. This screen allows you to specify
default conversions to and from every available screen and application
data type. Figure 3-27 Data Type Conversion Menu The n in the numeric types stands for
a number of decimal places. When specifying a conversion to one
of these types, you must replace n with a digit
or a. When you set the number of decimals to a,
you are instructing FORMSPEC to determine the decimals algorithmically
on the basis of the source type. Note that you can only select the a option
on this menu, and not on the field menus. For recommendations on
data type conversions, see "Data Types" earlier in this section. When you have set your defaults, press ENTER and then press MAIN/RESUME at the SAVE FIELD Menu to return to the Main Menu.
Generating the ARB | |
Follow these steps to generate an ARB for a form. At the Main Menu, enter B for "Go to ARB Menu" in the Main Menu Selection box. In the "Go to ARB Menu" field, enter the name of
the form for which you wish to generate an ARB and press ENTER. The ARB Menu is displayed. The form name is displayed in the first field. This is a display-only
field: you cannot select a new form from this menu. If you want
to create an ARB for a different form, you must go back to the Main
Menu. The next field shows the number of fields in the ARB: in this
case there are none, since there is no ARB yet.
An ARB may contain two kinds of field. They are live fields
and filler fields. Live fields exist on both the screen
and the ARB. Filler fields exist on the ARB only; for example,
alignment and accumulator fields.
The designer can select one of four options on the ARB Menu. - GEN (Generate)
Create an ARB from scratch, containing a field for
each field on the form. The sequence of the fields accords with their
sequence on the form, and can be altered using the Restructure ARB
Menu Figure 3-29 “Restructure ARB Menu” The type and length of the fields
are determined by comparing the screen attributes with the data
conversion record. They can be changed using the ARB Field Menu. This option is only valid if no ARB exists for the form. - RES (Restructure)
Display the current ARB, showing the sequence of
fields. Allows the designer to add, delete, move and rename fields using
the Restructure ARB Menu. - MOD (Modify)
Modify the length and data type of the designated
field in the ARB, using the ARB Field Menu. - DEL (Delete)
Delete the entire ARB. If you want to make a lot
of changes to the fields on a form, it is usually better to delete
the existing ARB and generate a new one once the form has been altered.
If you copy or delete a form, the corresponding ARB will be copied
or deleted as well.
Table 3-11 “Form/ARB Relationships” shows how an alteration made to
the form will affect the ARB, if at all. Table 3-11 Form/ARB Relationships Form | ARB |
---|
Adding a form... | Does not add an associated ARB. | Copy a form... | Copies the associated ARB. | Renaming a form... | Renames the associated ARB. | Deleting a form... | Deletes the associated ARB. | Changing a form: - adding a
field... | Does not add it to the ARB once the ARB
has been created, unless you create a new ARB. | - changing a field... | Changes the screen length and screen
data type on the ARB, but does not affect the ARB field length and
data type. | - deleting a field... | Changes the corresponding ARB field to
a "filler" field. | No effect on form... | Add, change delete ARB or the fields
in it. | Form can exist without an ARB. | ARB cannot exist without a form. |
The Effect of Renaming a Field on a Form There are three possibilities, which are described below. The old name is in the ARB but the
new name is not: The ARB field is renamed to the new name, retaining
its "live" field type, and the screen length and screen type are
altered if necessary. The old name is not in the ARB, but the new name
is, as a "filler" field: The ARB field changes from "filler" to
"live" field type, and the screen length and screen data type are
updated if necessary. Both old and new names exist in the ARB: The old name
changes from "live" to "filler" type, and the screen length and
screen data type change to zero and blanks respectively. The new name changes
from "filler" to "live" field type, and the screen length and screen
data type are updated.
If your default conversion for any field(s) could cause run-time
errors, you will get a message to that effect (see Appendix B, VPLUS
ERROR MESSAGES). Go to the ARB Field Menu to check that
the conversion does make sense in this case, or to change the target
datatype if it doesn't. - Command
Must state MOVE, ADD, RENAME, or DELETE. DELETE must be spelled out; the other commands may be
abbreviated. - Field or Range
Name(s) or numbers(s) of the field(s). A slash (/)
indicates a range: valid for MOVE or DELETE only. Any field may be deleted. You can ADD only a single field at a time; it may not already
exist on the ARB and it must conform to FORMSPEC naming rules. You
may add a field that does not exist on the associated form. This
"filler" field will have an ARB default length of 1 byte, and ARB
type of CHAR; screen length is zero and screen type is blank. Fillers
are marked with a "+" on the Restructure ARB Menu. To RENAME a field, enter the name of an existing field,
and enter the new name of the field in DESTINATION. "Live" fields exist on both form and ARB; "filler"
fields exist on the ARB only. The following defaults apply to renamed
ARB fields: Live name changed to live
name (new ARB field has corresponding field on the form):
new ARB field length and type derived algorithmically from the length
and type of the corresponding field on the form. Filler name changed to live name (new
ARB field has corresponding field on the form): new ARB field length
and type derived algorithmically from the length and type of the
corresponding field on the form. Live name changed to filler name (new
ARB field has no corresponding field on the form): new field retains
length and type of old ARB, and screen length becomes zero and type
blank. Filler name changed to filler name (new
ARB field has no corresponding field on the form): new field retains
length and type of old ARB, and screen length remains zero and type
blank.
When you
have finished modifying the field order on the ARB, press ARB MENU to return to the ARB Menu, or MAIN/RESUME to go back to the Main Menu. To change the length or data type of an ARB field,
type MOD on the ARB Menu. The ARB Field menu is displayed. Figure 3-30 ARB Field Menu This screen allows you to scroll through all the fields in
the ARB and change their length and data type if required.
| | | | | NOTE: You can change only the ARB field type and length. To
change the characteristics of the field on the form, you must use
the FORMSPEC Field Menu (see figure 3-22). If you use this menu
to change the length or type of a field on the form, the corresponding
screen length and screen type of the field in the ARB will be changed
accordingly, but the ARB length and ARB type will remain the same. | | | | |
The programmer is responsible for: Using the correct data types for each
programming language; for example, REAL is invalid for COBOL applications. Aligning and/or padding the ARB/source code. If
an odd number of bytes is followed by an integer, some languages,
including Pascal and FORTRAN, automatically pad the record definition,
forcing the integer to be word-aligned. No such padding occurs in COBOL
unless the SYNCHRONIZED clause is used (see the COBOL II/3000
Reference Manual).
If you use a language whose compiler pads to ensure word alignment
for integers, you must pad your ARB correspondingly. For example,
suppose you are coding in Pascal and you declare a record that looks
like this: ODD_BYTE_EXAMPLE = RECORD THREE_BYTES : PACKED ARRAY [1..3] OF CHAR; GOTCHA : INTEGER . . END; The Pascal compiler will insert an additional byte after THREE_BYTES to align the integer on a word boundary. You must
do the same with the ARB record; use the ARB LAYOUT screen to add a filler field after the three-byte
field so that the ARB looks like this: Field Name ARB Type ARB Length DEPT CHAR 3 FILLER1 CHAR 1 TOTAL PURCHASES DINT 4 Ensuring the application specifications
match the ARB specifications, for example, if the ARB type is PACK,
the COBOL specification should be COMP-3, not COMP. Avoiding run-time errors, which may occur when: Converting a CHAR or date source to
a numeric destination Converting a numeric or CHAR source to a date destination Invalid length specifications are encountered There are alignment problems; FORMSPEC does not
detect these There is also the possibility that data will be truncated;
for example, if DIG -> INT, but screenlen is greater than 5.
The ARB trace facility may be enabled by setting the JCW VPLUSARBTRACE to
1. This will print trace messages to the stdlist. You may direct VPLUS
screens to a different device by using a FILE command to set the
device of the filename used by VOPENTERM to a device other than the stdlist device. This is an example of a trace from a form that has seven fields. :SETJCW VPLUSARBTRACE,1 :FILE VTERM;DEV=99 :RUN ARBPROG Field 1 : Buffer offset from 0 = 1 Length = 2 Type = INT Value = 1234 Field 2 : Buffer offset from 0 = 3 Length = 2 Type = INT Value = 1234 Field 3 : Buffer offset from 0 = 6 Length = 2 Type = INT Value = 1234 Field 4 : Buffer offset from 0 = 9 Length = 4 Type = DINT Value = 12345678 Field 5 : Buffer offset from 0 = 14 Length = 4 Type = DINT Value = -1234567 Field 6 : Buffer offset from 0 = 19 Length = 4 Type = DINT Value = 12345678 Field 7 : Buffer offset from 0 = 23 Length = 8 Type = CHAR Value = ABCDEFGH END OF PROGRAM : The trace provides the following information. It shows: The location of each field in the
ARB (Buffer offset); The length of each field in the ARB (Length); The type of transformation that occurs (Type); The value that is transformed in the ARB field (Value).
| | | | | NOTE: This ARB is tied to seven form fields, but there are
gaps in the buffer before field 1, and between each field from 2
to 6. These gaps are one-byte filler fields. | | | | |
|