System 1032
USE OF AND ACCESS
TO PRODUCTS AND FEATURES ARE IN ACCORDANCE WITH THE TERMS AND CONDITIONS
OF THE USERS SOFTWARE LICENSE. THE PRESENTATION OF MATERIAL HEREIN
DOES NOT, IN ANY MANNER, MODIFY SUCH TERMS AND CONDITIONS.
Forms Feature, Part 2
By Tym Stegner
In the November CCAPRINT,
Forms Feature, Part 1, as a case study
we created a small application called STORES_LIB with ease using FormGen
and the STORES dataset. The application includes the form STORES_FORM,
as shown in Figure 1.
Figure
1. STORES_FORM generated by FormGen
+--------------------------- S T O R E S -----------------------------+
|Store Name ________________________ Store ID __ | |Division ID __ City ______________| |State/Province _______________ Country ______________| |Budget ____________________ Gross to date ______________| +---------------------------------------------------------------------+
|
|
In this part of the
STORES_LIB case study we will refine the layout of the form, which is
itself also an easy task. We are doing these refinements to eliminate
the DIVISION_ID field, as well as to add new fields to the form in support
of corresponding attributes already added to the STORES dataset.
Update
the Form Definition with New Fields
After issuing a SHOW FORM STORES_FORM DEFINITION command with the STORES_LIB
library open, you can modify and save the code shown in Figure 2. (Alternately,
you can extract the form definition STORES_FORM from the library definition
file STORES_LIB.DMD.)
Start the update
of the STORES_FORM by commenting out the DIVISION_ID field, and adding
two new Time_Span fields to the end of the group. (Be sure to add the
new fields within the group definition, that is: before the End_Group
keyword. Otherwise, they will display outside the form box.)
Copy the LATITUDE
and LONGITUDE attribute definitions from the previously modified STORES
dataset definition and paste them directly into the STORES_FORM code.
Then remove the ATTRIBUTE and KEYED keywords and the title option, as
shown in blue. The commented out DIVISION_ID field is shown in red.
Figure
2. Deleting and adding fields to the STORES_FORM code
Form STORES_FORM Message Shared Prompts Bold Values Reverse - Comment "Form for Dataset STORES" - Field STORES_FORM_G1 Group Prompt " S T O R E S " of STORE_NAME or SNAME Text 25 Prompt "Store Name" - Value Reverse Bold - Help "Enter up to 25 characters of text" STORE_ID or SID Integer Comment - "This is the join attribute to DIVISIONS." Format NU2 Prompt "Store ID" - Value Reverse Bold Right_Justified - Help "This is the join attribute to DIVISIONS." ! DIVISION_ID or DIVID Integer Format NU2 Prompt "Division ID" - ! Value Reverse Bold Right_Justified - ! Help "Enter a whole number" CITY Text 15 Prompt "City" - Value Reverse Bold - Help "Enter up to 15 characters of text" STATE or PROVINCE Text 15 Prompt "State/Province" - Value Reverse Bold - Help "Enter up to 15 characters of text" COUNTRY Text 15 Prompt "Country" - Value Reverse Bold - Help "Enter up to 15 characters of text" STORE_BUDGET or BUDGET Decimal Format N$,12.2 Prompt "Budget" - Value Reverse Bold Right_Justified - Help "Enter a decimal number between -9999999999.99 "&- "and 9999999999.99" GROSS_TO_DATE or GROSS Decimal Format N$,12.2 Prompt "Gross to date" Value Reverse Right_Justified - Help "Enter a decimal number between -9999999999.99 "&- "and 9999999999.99"
LATITUDE or LAT Time_Span Range -90:00:00 : 90:00:00 - Precision Seconds Format TS4.9 Prompt "Latitude" LONGITUDE or LNG Time_Span Range -180:00:00 : 180:00:00 - Precision Seconds Format TS4.9 Prompt "Longitude" End_Group End_Form;
|
|
The code in Figure
2 defines the STORES_FORM shown in Figure 3.
Figure
3. STORES_FORM with modified fields
+----------------------------- S T O R E S -------------------------------+ |Store Name _________________________ Store ID __ | |City _______________ State/Province _______________ | |Country _______________ Budget _________________ | |Gross to date ____________________ Latitude _________ | |Longitude _________ | +-------------------------------------------------------------------------+
|
|
When you compare
Figure 1 and Figure 3, note that Forms, via auto-layout, has moved the
next available field to the position formerly held by the DIVISION_ID
field, and that the new LATITUDE and LONGITUDE fields were placed at the
end of the form.
System 1032 Forms,
by default, positions the defined fields so that the form is filled from
left to right, top to bottom, fitting the fields into the default width
of 80 characters.
Using
the Form Editor to Display Field Positions
This functional layout
does not fulfill my requirement to have all the address-related data grouped
together, separated from the financial information. Furthermore, I want
each prompt text adjacent to its value window.
The System 1032 Form
Editor, also called the Stand-Alone Form Editor (SAFE), is a utility residing
in the S1032_FE library, accessed by the EDIT_FORM command variable. The
editor is menu-driven. You can use it to modify or create just about any
form that is syntactically allowed. The Form editor can be used with forms
defined in $TEMP, or those within existing, opened libraries. Used with
the STORES_FORM as input, the Form Editor screen appears as shown in Figure
4.
Figure 4.
STORES_FORM opened in the Form Editor
+----------------------------- S T O R E S -------------------------------+ |Store Name _________________________ Store ID __ | |City _______________ State/Province _______________ | |Country _______________ Budget ____________________| |Gross to date ____________________ Latitude _________ | |Longitude _________ | +-------------------------------------------------------------------------+
(extra blank lines omitted) EDIT FORM Paint Edit Field Edit Group Add Field Add Group Remove Field Remove Group Resequence Auto Layout Replace Form Set Form Options Modes Output Def'n Exit Please select an option
|
|
Revealing
the Field Positions
Press the Tab key to
navigate within the menu at the bottom of the screen to select an action
option. Then press the Return key to run the option. (This in turn often
prompts within the subject form to select the field to be operated upon.
Many other sub-menus and sub-forms appear as needed to process the desired
action on the selected field).
Select the Output
Defn option, which works in a similar fashion to a SHOW FORM DEFINITION
command to output the source for the subject form to an external file. However,
this option creates a form definition file containing layout information,
including the AT and ALIGN clauses.
To explicitly position
the fields, you can modify the values of n,m in the AT clauses for
the form fields. The form definition shown in Figure 2 did not have any
AT clauses, because Forms relies on default form layout to arrange the fields.
Although we could go through each field in the definition to manually add
an AT clause to each field, it is convenient to let the mechanism of the
Form Editor return the definition that includes the AT clauses.
Back
to Repositioning Fields
Now that you have a
version of the form definition with the field positions, you can rearrange
the form display to suit you. Briefly, Figure 5 illustrates the field position
layout: a two-column grid (positions indented to indicate on-screen layout):
Figure 5.
The STORES_FORM code with AT clauses
Form STORES_FORM Form_Field STORES_FORM_G1 Group At 1,1 of STORE_NAME Text 25 At 2,2 Align STORE_ID Integer At 2,45 Align CITY Text 15 At 3,2 Align STATE Text 15 At 3,45 Align COUNTRY Text 15 At 4,2 Align STORE_BUDGET Decimal At 4,45 Align GROSS_TO_DATE Decimal At 5,2 Align LATITUDE Time_Span At 5,45 Align LONGITUDE Time_Span At 6,2 Align
|
|
In my layout I want
all the address information in the second display column and the remaining
fields in the first column, as shown in Figure 6. This arrangement causes
the visit order on the form to proceed down the first column, then down
the second column, rather than left-to-right, as is the default. Initially,
field visit order depends on the order in which the fields were defined.
Figure 6.
Rearranging fields in columns
Form STORES_FORM Form_Field STORES_FORM_G1 Group At 1,1 of STORE_NAME Text 25 At 2,2 STORE_ID Integer At 3,2 STORE_BUDGET Decimal At 5,2 GROSS_TO_DATE Decimal At 6,2 CITY Text 15 At 2,45 STATE Text 15 At 3,45 COUNTRY Text 15 At 4,45 LATITUDE Time_Span At 5,45 LONGITUDE Time_Span At 6,45
|
|
Note the ALIGN feature,
shown in Figure 5, is removed in Figure 6 to move the prompts to be only
one space separated from the value windows. I reordered the fields, because
I expect once the address information is entered, it is less likely to be
changed and that budget and gross data are more likely to be changed, so
I moved those fields forward in the navigation order. The form now displays
as shown in Figure 7.
Figure 7.
STORES_FORM displayed with the fields in the desired groupings
+------------------------------ S T O R E S ------------------------------+ |Store Name _________________________ City _______________ | |Store ID __ State/Province _______________ | | Country _______________ | |Budget ____________________ Latitude _________ | |Gross to date ____________________ Longitude _________ | +-------------------------------------------------------------------------+
|
|
Next I want to tweak
the field positions to line up the data windows as shown in the Figure 8
layout. Using the same technique shown in Figure 6, I changed the m value
(the cell position) in the AT clauses to get the alignment I required.
Figure 8.
STORES_FORM data entry fields aligned
+----------------------------- S T O R E S -------------------------------+ |Store Name _________________________ City _______________ | | Store ID __ State/Province _______________ | | Country _______________ | | Budget ____________________ Latitude _________ | |Gross to date ____________________ Longitude _________ | +-------------------------------------------------------------------------+
|
|
Note:
you can also use either the Paint or Edit Field options of
the Form Editor to rearrange fields in a form. Using the Paint option
you can effectively drag a field to a new position and using the Edit
Field option you can selectively edit field qualities, including position
and alignment. These examples demonstrate the functionality of field repositioning
by editing the form definition.
Coming
Attractions
OK, the Figure 8 layout of the form now suits my requirements. The next
step is to update the procedures in the form application to support the
changes made to the field in the form. We will cover this topic in Forms
Feature, Part 3.