Sage-ST ä Tutorial
Lesson 15



1. Overview. In this lesson you will begin to implement the Browse_Employee procedure.

2. What You'll Use. You will use the THOR relation editor, your text editor, and the Ada compiler. The following new Sage-ST calls will be used:

Display.ScrollForm
Sage.TotalRecords


3. Assignment. A more user-friendly style of editor is one in which the user can see a listing of employee names, SSNs, and organization numbers. The editor then should allow the user to move through the records using cursor movement, modifying the fields as needed.

Go into the THOR relation editor and add a field "H1" to the Utility relation. This should be a one-character Type 2 field. It will be used by ScrollForm to display the data you request.

Carefully read the information on Display.ScrollForm in the Reference Manual in Volume 2. Create an outer form that leaves an internal invisible paint area for the scroll. Create two other forms: one as the highlighted line will look when the user is in the employee list, the other as the remaining lines will look. Display.ScrollForm will take one highlighted form and as many other forms as will fit in the portion of the outer form that is invisibly painted.

Instantiate ScrollForm with two procedures: one which determines what to do if the user exited the form (FormToRecord) and had made changes; and one which determines what to do if the user is simply scrolling through the entries (up/down arrow, PgUp, or PgDn) (RecordToForm). YourRecordToForm should read the desired record (ReadRecordN).

Some common problems on this lesson:


1. Confused the function of the RecordToForm and FormToRecord procedures.

2. Forms used by ScrollForm are not windowed properly.

3. Invisibly painted area of main display form does not have sufficient space to display data.

4. Get a "Relation not open" error after editing the Org relation.

5. Form is "messed up" at some point.

6. New data does not appear on the editing form. Be sure RefreshCheckScreen is set to true.


4. Our Solution.

BrowseC Enter scroll editor for employ 9 Field(s)
packed picture size -> 4 bytes
predominant color -> yellow on green
-----------------------------------------------------------------------------
░░░░░1░░░░░ ░░░░░░░2░░░░░░░, ░░░░░░░3░░░░░░░ ░4░░ ░░░5░░░░
░░░░░░░░░6░░░░░░░░░░ ░░░░░░░7░░░░░░░ 8░ ░░9░░
------------------------------------------------------------------------------
Field Display Type Record & (Field) - rpt Field Type Help Frm
----- ------------- ---------------------- ---------------------- --------
1 Entry/Display Employee(SSN) - 1 Social Security Number
2 Entry/Display Employee(LastNam) - 1 Alphanumeric
3 Entry/Display Employee(FirstNam)- 1 Alphanumeric
4 Entry/Display Employee(OrgNum) - 1 Alpha/Numbers
5 Entry/Display Employee(HireDate)- 1 Date
6 Entry/Display Employee(StrtAddr)- 1 Alphanumeric
7 Entry/Display Employee(City) - 1 Alphanumeric
8 Entry/Display Employee(State) - 1 Upper Case Alphanumeric
9 Entry/Display Employee(Zip) - 1 Upper Case Alphanumeric
BrowseI Inner scroll editor for employ 9 Field(s)
packed picture size -> 4 bytes
predominant color -> yellow on blue
-----------------------------------------------------------------------------
░░░░░1░░░░░ ░░░░░░░2░░░░░░░, ░░░░░░░3░░░░░░░ ░4░░ ░░░5░░░░
░░░░░░░░░6░░░░░░░░░░ ░░░░░░░7░░░░░░░ 8░ ░░9░░
------------------------------------------------------------------------------
Field Display Type Record & (Field) - rpt Field Type Help Frm
----- ------------- ---------------------- ---------------------- --------
1 Entry/Display Employee(SSN) - 1 Social Security Number
2 Entry/Display Employee(LastNam) - 1 Alphanumeric
3 Entry/Display Employee(FirstNam)- 1 Alphanumeric
4 Entry/Display Employee(OrgNum) - 1 Alpha/Numbers
5 Entry/Display Employee(HireDate)- 1 Date
6 Entry/Display Employee(StrtAddr)- 1 Alphanumeric
7 Entry/Display Employee(City) - 1 Alphanumeric
8 Entry/Display Employee(State) - 1 Upper Case Alphanumeric
9 Entry/Display Employee(Zip) - 1 Upper Case Alphanumeric
BrowseO Outer scroll editor for employ 0 Field(s)
packed picture size -> 379 bytes
predominant color -> light red on black
------------------------------------------------------------------------------
B r o w s e E m p l o y e e R e l a t i o n



with Display ;
with ModSys ;
with Sage ;
with SageLib ;
with Strings ;


package body EditPack is


option : string (1..1) := (others => ascii.nul);


procedure Display_Edit_Message (operation : in string) is . . .

procedure Add_Employee is . . .

procedure Modify_Employee is . . .

procedure Delete_Employee is . . .

procedure Get_Next_Employee is . . .

procedure Get_Previous_Employee is . . .

procedure Locate_Employee is . . .

procedure Edit_Employee is . . .

procedure Edit_Organization is . . .

procedure Load_Record_In_Form(recNum : in out ModSys.S_long_integer;
entryForm : in boolean;
searchString : in out string) is

--*
-- Load_Record_In_Form - ScrollForm's RecordToForm Procedure
--
-- Loads in an employee record by record number on SSN key
--
-- D.H. Schwieder - 02/22/93
--
-- See Display.ScrollForm for descriptions of parameters.
--

begin

if (recNum > 0) then -- A record is requested. Read it.

Sage.ReadRecordN ("Employee", "SSN", recNum);

end if;

end Load_Record_In_Form;



procedure Process_Record_In_Form (recNum : in out ModSys.S_long_integer;
changed : in boolean;
refresh : in out boolean;
exitProc : in out boolean;
recTot : in out ModSys.S_long_integer) is

--*
-- Process_Record_In_Form - ScrollForm's FormToRecord Procedure
--
-- Processes changed employee records by rewriting record.
--
-- D.H. Schwieder - 02/22/93
--
-- See Display.ScrollForm for descriptions of parameters.
--

begin

if (changed) then
Sage.ReWriteRecord("Employee");
refresh := true;
end if;

exitProc := false;

end Process_Record_In_Form;



procedure Employee_Scroll is new Display.ScrollForm
(Load_Record_In_Form,Process_Record_In_Form);


procedure Browse_Employee is

--*
-- Browse_Employee - Browse and edit Employee relation
--
-- This procedure displays a portion of the employee relation. User
-- can scroll through the relation and change fields if desired.
--
-- D.H. Schwieder - 02/22/93
--


recPos : ModSys.S_long_integer;
recTot : ModSys.S_long_integer;

begin
Sage.OpenRelation ("Employee", true);

recPos := 1;
recTot := Sage.TotalRecords("Employee");
Employee_Scroll("BrowseO", "BrowseC", "BrowseI", recPos, recTot);

Sage.CloseRelation ("Employee");

end Browse_Employee;

end EditPack;


Go Back To Tutorial Table of Contents


warren.merrill@inl.gov , ftp://sage.inel.gov
Copyright © 1989-2006. Battelle Energy Alliance