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 1 By Tym Stegner
This case study looks at the System 1032 Forms feature, a cell-based screen forms and the management system used to create and display an application for interactive data entry. Many applications have been written in the System 1032 environment that make use of the Forms feature, because the Forms feature makes it so simple to create applications quickly. The applications are end-user interfaces for data entry and display.
Programmers new to the System 1032 environment may not be familiar with how easily you can modify a form that adds, removes, or reorganizes fields. This series of articles illustrates how a forms application is generated, and how to modify the application by adding or removing form fields.
Introducing the STORES Application So that you can participate in creating and modifying an application using the Forms feature, I made use of a demonstration dataset in the S1032_DEMO directory, an element of the VIDEO_RENTALS database--the STORES dataset.
The STORES dataset represents establishments that rent videos and, as was shipped to you, has the following attributes:
Dataset STORES Attribute STORE_NAME Text 25 Keyed Attribute STORE_ID Integer Keyed Attribute DIVISION_ID Integer Keyed Attribute CITY Text 15 Keyed Attribute STATE Text 15 Keyed Attribute COUNTRY Text 15 Keyed Attribute STORE_BUDGET Decimal Keyed Attribute GROSS_TO_DATE Decimal
Using the Forms Feature Using the STORES dataset and a Rapid Application Development (RAD) tool called FormGen that is available with the System 1032 software, you can generate a small application. FormGen calls a Fortran program to read the dataset and generates a MAIN menu screen, a data entry form duplicating the datasets attributes, and the System 1032 procedures necessary to add to, display, and update the dataset underlying that form. The form, its supporting procedures, and variables are placed in a library definition file named STORES_LIB.DMD. FormGen also creates this library for you.
To generate your own copy of the STORES application, containing the supporting files and procedures used in this case study, perform the following commands:
1. Choose a working directory and set it as the default. 2. Copy the STORES dataset from S1032_DEMO. 3. Open the TOOLIB library in S1032_TOOLS. 4. Invoke FORMGEN to create the form and application. 5. Accept all the defaults on the FORMGEN screen by pressing the Enter key.:
1. Choose a working directory and set it as the default.
2. Copy the STORES dataset from S1032_DEMO.
3. Open the TOOLIB library in S1032_TOOLS.
4. Invoke FORMGEN to create the form and application.
5. Accept all the defaults on the FORMGEN screen by pressing the Enter key.:
The following form is created for the STORES dataset. The character cell-based rendition displayed below is created by the FORMS_PRINT procedure, which is another utility in support of the Forms feature:
+--------------------------- S T O R E S -----------------------------+|Store Name ________________________ Store ID __ ||Division ID __ City ______________||State/Province _______________ Country ______________||Budget ____________________ Gross to date ______________|+---------------------------------------------------------------------+
Now, just a quick look at the form generated:
That was simple. You now have a form application that can be used for data entry for the STORES dataset. Upon calling the MAIN_STORES procedure, the main menu form will be displayed to allow you to choose to add, update or select records in the STORES dataset.
Modernizing the STORES dataset Now assume the STORES dataset requires certain changes and subsequently the STORES application. Lets make the following changes to the STORES dataset:
First, we will modify and repopulate the STORES dataset, resulting in the following updated dataset definition:
Dataset STORES Attribute STORE_NAME Text 25 Keyed Attribute STORE_ID Integer Keyed! Attribute DIVISION_ID Integer Keyed !omitted Attribute CITY Text 15 Keyed Attribute STATE Text 15 Keyed Attribute COUNTRY Text 15 Keyed Attribute LATITUDE Time_Span Keyed !new Attribute LONGITUDE Time_Span Keyed !new Attribute STORE_BUDGET Decimal Keyed Attribute GROSS_TO_DATE Decimal
Considering Latitude and Longitude Data Latitude and longitude data have several commonly used formats:
System 1032 has a Time-Span data type that can store latitude and longitude data in almost the proper mode, using a format Sddd:hh:mm. So, I chose this format for data storage.
Examining the STORES_FORM Lets take a look at the definition of the STORES_FORM that was generated from the original STORES dataset. This code still includes the DIVISION_ID field, but not the LATITUDE and LONGITUDE fields, because we have not yet updated the form definition, only the dataset definition.
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" End_Group End_Form;
Note that the display title of the form, "S T O R E S", is the prompt assigned to a group field that is comprised of all the attributes from the datatset. A feature of group form fields is to automatically enclose their components within a box.
The form field names are the same as the attribute names. Although this is not a requirement, it makes it easier to recall the attribute names that correspond to the form fields, and facilitates easier assignment for forms applications.
Additional field options that might be unfamiliar to you include:
In Summary You have been introduced to the ease with which you can generate a simple application for form-based data entry, using the STORES dataset. You have modernized the STORES dataset; and you have examined the STORES_FORM definition in readiness to edit it.