|
|
Sage-ST
ä
Tutorial
|
1. Overview.
This is the first of a series of lessons wherein you will use various procedures from Sage-ST to create a Human Resources System. Once you have implemented the basic features of this system, you will revisit some of these features in order to make enhancements and/or look at other ways of accomplishing the task. This system will be very similar to that discussed in the first part of Learning Sage-ST , but will not involve a "Dependents" relation.
In this lesson you will use THOR to define your schema (relations and their associated file sets and fields) and create the Main Menu form.
2. What You'll Use.
You will need to load THOR.EXE and THOR.DFL into their own directory on your disk. You will need to have a THOR.BAT in your batch directory. See the Sage-ST User Manual section entitled "Using THOR" for instructions on how to load THOR and write your batch procedure.
3. Assignment.
Use THOR to produce a DFL file called "HRS.DFL". Define the file sets, define the three relations (don't forget the Utility relation) and their fields, and create the "MainMenu" form. When you are finished, compile the file and check for errors. Fix errors and recompile if necessary. After you obtain a successful compilation, print out the Form and Record reports.
HELPFUL HINT: During this lesson you may feel as though THOR is trying to sabotage you, eat everything you input, put bogus data in where it does not belong, etc. This is common among those just starting to learn THOR. After a week or so of frequent use these feelings will disappear, and you'll realize that THOR is simply doing exactly what you tell it.
NOTE: The names of relations, fields, and forms defined within THOR are case sensitive , i.e., whether or not a letter is upper- or lower-case makes a difference. Thus "Employee", "EMPLOYEE", and "employee" are three different relations.
Create the SRC. You have designed a data base consisting of the employee and organization relations, with fields defining information regarding these two groups. Now you need to put that design into a format that your application program can use. You must also develop a main menu from which the user can make selections.
Type "THOR" at the DOS prompt, type in "HRS" where it asks for the file name, and press <Enter>. The source file for your data base has now been created, and you are sitting in the THOR main menu. If you exit, you will see that a file called "HRS.SRC" has been created and that, even though there is nothing in the file, it takes up 256 bytes.
HELPFUL HINT: If you've been working on your SRC for some time and suddenly find that all your relations and forms are gone, chances are you accidently typed in the wrong name. Exit out of THOR and see how many SRC's you have. You'll probably discover an extra with a spelling similar to that of your real SRC. Be sure to delete the extra SRC.
Create the File Set. The actual records which some user will eventually enter into your system are NOT stored in the SRC or the DFL: only the data dictionary and forms are stored in the SRC. The actual records are stored in files on your hard drive, floppy drive, or network. You must specify the names for these files; you can also specify the drive and path where you wish the files to reside. The default is the drive and path of the DFL.
Data entered by a user are stored in up to three separate files. The actual information is stored in the data file in no particular order. Primary and alternate keys are also stored in the index file in ASCII-sorted order. If a relation includes a variable length data field, the variable length data is stored in a block data file. All relations that store data must have a data file and an index file.
In our unit, we name our files by the relation name and then an extension of DAT for the data files, IDX for the index files, and BLK for variable length data file (if any). These are merely our conventions; file names may be any valid DOS file name. However, we recommend that your programming team agree upon some sort of naming convention for file names.
From the THOR main menu, select "FiLe set editor" to define the files needed to store your employee data. NOTE: Use the <Tab> or <arrow keys> to move from field to field.
1. Press the <Ins> key to add a file set.
2. Type the number "1" in the file number box and press <Tab>.
3. Type in a description of the file (optional) and press <Tab>.
4. Type "EMPLOYEE.DAT" in the data file name box, "EMPLOYEE.IDX" in the index file name box. You will not need a block data file for this application.
5. Type the maximum number of records a user will be able to store. A typical number is 9,999. Press <Enter>. The message "New file added" will be displayed.
6. Repeat steps 1-5 for the "Org" relation, but increment the file number. Simply type over the existing information from the employee file set.
7. Press the <Esc> key to exit the File Set Editor.
Define the Schema. You have told THOR where to store your data base files, now you must describe exactly what you are going to put in that data base--create a template of what each employee record and organization record will look like. Select "Relation definition edit (schema)" on the THOR main menu.
1. Define the relation. Press the <Ins> key to add a new relation.
NOTE: We won't be using the Alias field in this tutorial.
2. Type "Employee" in the relation name box. The relation name is case sensitive .
3. Type a brief description in the description box. (Optional).
4. Type the number of the corresponding file set. Be VERY sure you have the right number!! (In our sample, we assigned file number 1 to EMPLOYEE, file 2 to ORG).
5. Press <Enter>. The relation "Employee" has been defined.
6. Define the individual fields of the relation. Press <F3> (Edit fields).
7. Press the <Ins> key to add a new field.
8. Type in the field name, description, type, and length of a field. Refer to the THOR reports at the end of this lesson for the list of fields required for each relation. The field names are case sensitive . The order of entry on the fields is NOT important, except with regard to a concatenated field (which can only be entered after its member fields have been entered). THOR will automatically alphabetize your fields by field name.
9. If the field is Type 0 (concatenated), type in the names of the fields of which it is composed at the bottom of the form.
10. If the field is a prime or alternate key, type "P" or "A" respectively in the Keyed Field box. Refer to the Sage-ST User Manual ("Keyed Fields and Indexes") for a discussion on Primary/Alternate keyed fields.
11. Press <Enter>. Repeat steps 7-11 for each non-concatenated field in the Employee relation, then perform steps 7-11 for all concatenated fields. Exit back to the Relation Definition Form.
12. Repeat these steps for the "Org" relation. Repeat these steps for the "Utility" relation but do not enter a file set number (Step 4). The utility relation is used for temporary data storage and exists only in memory, which is why it does not require a file set or file set number. Typical fields in a utility relation include menu option fields, name of a file to which to print a report, current data field, etc.
13. When complete, press <Esc> to return to the THOR main menu.
Define Forms. The fun part is almost here! To prepare for it you need to tell THOR what forms you are going to create.
1. Select "Form/Report Definitions" from the THOR main menu.
2. Press the <Ins> key to add a new form.
3. Fill in the form name ("MainMenu"), description, and display method for the main menu. The form name is case sensitive .
4. Press <Enter>. A blank form with the name "MainMenu" now exists.
Create Forms. Create the main menu for HRS. This menu will be very similar in format and function to the THOR main menu. The menu should show a list of highlighted fields containing the options available to the user, plus an option box where the user may enter his or her menu choice.
What is described next is a very simple, plain box containing menu options. For now don't worry about colors. After Lesson 3 you may want to come back to your main menu and work with various color combinations.
1. Highlight the form definition "MainMenu," and press <F3> (Edit form appearance) to enter the empty form.
2. Position the cursor to the central portion of the screen. (Exact position is not important. The contents of the form can be properly positioned later.) Type in the following list of menu options:
Exit
eMployee edit
Organization edit
Print report
Rebuild index
Browse employee
Load employee
Unload employee
NOTE: For the form appearance commands shown below, refer to the THOR User's Guide ("The Form Appearance Editor") for details.
3. Use <Alt/B> to draw a border around the list. Put an option box below the list.
4. Use <Alt/G>, <Alt/A>, <Alt/D>, <Ctrl/C>, <Ins>, and/or <Del> to position the menu where you want it. Add a title to the form, plus any other embellishments you desire.
5. Position to the first (or second, if necessary. Use the capitalized letter.) letter of each line of the menu and define a highlighted field using <Alt/F>. The relation name is "Utility", the field name, "A1". Lengthen each field (<Alt/L>) to include the entire line. Define a field in the option box--same relation and field name, but type should be "Display & Entry" rather than "Highlighted".
6. Exit and save the form by pressing <Alt E>.
Compilation: the DFL. Compiling the SRC compresses the forms and data dictionary and creates a file with the extension DFL. This is the file which will be used by your application.
From the THOR main menu select "Compile". If the compilation produces errors, exit from the THOR main menu, and use your text editor to examine the HRS.ERR file. Then go back into THOR to correct any errors that may exist. Recompile.
Print THOR Reports. Select "Utilities" from the THOR main menu. Select "Reports" from the Utilities menu. Send a Relation Report and a Form Report to the printer or to a file on your disk. During the coding of the HRS data base application it may be prudent to refer to these reports to ensure correct spelling and case for relation, form, and field names.
NOTE: The numbers which appear on the forms in a form report refer to the list of fields displayed under the form. These numbers should NOT be put on your form!
2.4.1.4 Our Solution. The relations and forms created during this lesson are shown on the following pages.
Record Name : Employee
Description : individual employee records
Fields : 10
Byte Length : 85
File Number : 1
Data File : EMPLOYEE.DAT
Index File : EMPLOYEE.IDX
Field Name Description/Type Length Key Type Sub-Fields Repeat Decimals
-----------------------------------------------------------------------------
City employee's city 15 Non-keyed 1
1 (Alphanumeric)
FirstNam 15 Non-keyed 1
1 (Alphanumeric)
HireDate date employee hired 8 Non-keyed 1
7 (Date) (mm/dd/yy)
LastNam 15 Non-keyed 1
1 (Alphanumeric)
Name first and last 30 Alternate LastNam 1
0 (Concatenated) FirstNam
OrgNum department employee works for 4 Alternate 1
16 (Alpha/Numbers)
SSN employee SSN 11 Primary 1
10 (Social Security Number)
State employee's state 2 Non-keyed 1
2 (Upper Case Alphanumeric)
StrtAddr employee's street address 20 Non-keyed 1
1 (Alphanumeric)
Zip employee's zipcode 5 Non-keyed 1
2 (Upper Case Alphanumeric)
Record Name : Org
Description : organization records
Fields : 2
Byte Length : 25
File Number : 2
Data File : ORG.DAT
Index File : ORG.IDX
Field Name Description/Type Length Key Type Sub-Fields Repeat Decimals
------------------------------------------------------------------------------
Des department description 20 Non-keyed 1
1 (Alphanumeric)
OrgNum department ID number 4 Primary 1
16 (Alpha/Numbers)
Record Name : Utility
Description : utility fields for forms
Fields : 1
Byte Length : 6
Field Name Description/Type Length Key Type Sub-Fields Repeat Decimals
-----------------------------------------------------------------------------
A1 one character upper-case alpha 1 Non-keyed 1
2 (Upper Case Alphanumeric)
FORM REPORT FOR HRS
MainMenu 9 Field(s)
packed picture size -> 1196 bytes
predominant color -> light cyan on black
------------------------------------------------------------------------------
Field Display Type Record & (Field) - rpt Field Type Help Form
------------------------------------------------------------------------------
1 Highlighted Utility (A1) - 1 Upper Case Alphanumeric
2 Highlighted Utility (A1) - 1 Upper Case Alphanumeric
3 Highlighted Utility (A1) - 1 Upper Case Alphanumeric
4 Highlighted Utility (A1) - 1 Upper Case Alphanumeric
5 Highlighted Utility (A1) - 1 Upper Case Alphanumeric
6 Highlighted Utility (A1) - 1 Upper Case Alphanumeric
7 Highlighted Utility (A1) - 1 Upper Case Alphanumeric
8 Highlighted Utility (A1) - 1 Upper Case Alphanumeric
9 Entry/Display Utility (A1) - 1 Upper Case Alphanumeric
Go Back To
Tutorial
Table of Contents
warren.merrill@inl.gov , ftp://sage.inel.gov