Introduction to Grapl
1.1
What is GRAPL?
1.2
Why GRAPL?
1.3
Requirements
Sage-ST
TM
PROCEDURES IMPLEMENTED IN GRAPL
GRAPL SYNTAX
GRAPL-CALLABLE Sage-ST
TM
Package SPECIFICATIONS
5.1
Display Package
5.2
Exec Package
5.3
FX Package
5.4
ModSys Package
5.5
Reports Package
5.6
SAGE Package
5.7
SageLib Package
5.8
Strings Package
5.9
Terminal Package
5.10
ThorPort Package
Introduction to Grapl
What is Grapl?
GRAPL is a simple, interpretive language coupled with some of the
most frequently used Sage-ST
TM
procedures. The data dictionary for the
application must be produced by the THOR editor. The Sage-ST
TM
procedure calls are coded exactly as they would be in an Ada program.
Since GRAPL is an interpretive language developed at the Idaho
National Engineering Laboratory (INL), no compilers or licenses are
needed to execute. GRAPL can run on any MS-DOS machine.
The only difference in developing a prototype using GRAPL instead of
Ada is that no compiler is required and you do not have access to all
of the Sage-ST
TM
libraries or the entire range of commands in the Ada
language. However, a prototype can be developed with full use of
forms, database population and editing, and reports. The application
could then be completed using the entire Sage-ST
TM
library and Ada.
Why Grapl
GRAPL was developed to teach Sage-ST
TM
concepts. There is no intent to
replace Ada as the most complete language available for applications
development. Rather, GRAPL presents the instructor and student with
the optimum learning environment with no requirements for the Ada
compiler and the Sage-ST
TM
libraries being installed on each computer.
An added benefit is the instantaneous execution of the program
without the need to wait for a lengthy compile and bind. The goal of
learning about Sage-ST
TM
by developing programs using Sage-ST
TM
in the
least time possible with the lowest cost computers is realized with
GRAPL.
The initial iterations of an application are largely involved with
building and presenting the menu structure, manipulating the database
and producing reports. GRAPL will likely handle this level of
development completely. When it becomes necessary to write programs
to do math or advanced features within Sage-ST
TM
, GRAPL will be
abandoned for Ada. The source programs developed during the GRAPL
prototype are not lost. Since GRAPL syntax is Ada syntax, the GRAPL
program, progname.GPL, is simply renamed to progname.ADA and compiled
with the Ada compiler. It is likely that a few minutes will be spent
cleaning up minor syntax errors since GRAPL does not do the extensive
syntax checking of an Ada compiler.
It is during the initial generations of a system that GRAPL will be
of the most use to the developer. The user will need to be made
aware of the tools involved and their impact on the development
cycle. It will appear to the user that nearly everything is being
completed very rapidly during the time that GRAPL is being used, then
little apparent progress will be made when the application specific
requirements are implemented. This is typical of any project team
using rapid prototyping with GRAPL or Ada. The team members from the
user community need to be aware of this fact and temper their
enthusiasm when reporting on the degree of project completion to the
customer.
It is highly recommended that the user become part of the development
team. The user can be of great assistance in creating forms using
the THOR editor and serving as a subject matter expert. It is
conceivable that the user with a programming bent can participate in
development of a GRAPL prototype.
Requirements
To run GRAPL you must have:
Hardware/Operating System
IBM compatible computer with 808x or 80x86 processor
512 KB RAM or more
MS-DOS 2.1 or higher
Two floppy disk drives or one floppy and a hard drive
Software
GRAPL
THOR schema editor
Any text editor capable of outputting an ASCII file
Sage-ST tm Procedures Implemented in Grapl
The procedures chosen for inclusion in GRAPL represent those most commonly used in application development. The Sage-ST TM calls are coded exactly as they would be in an Ada program. Refer to the Sage-ST TM User's Manual for the use of these procedures in a GRAPL or Ada program. The following Sage-ST TM procedures are implemented in version 1.0 of GRAPL:
LIBRARY
PROCEDURE
HOUSEKEEPING
Sage OpenSystem
Sage CloseSystem
Sage OpenRelation
Sage CloseRelation
DATABASE I/O
Sage ReadRecord
Sage ReadRecordA
Sage ReadRecordR
Sage WriteRecord
Sage ReWriteRecord
Sage DeleteRecord
SPECIAL EFFECTS - MISC
FX (Sage-ST
TM
3.1) ClearWindow
FX (Sage-ST
TM
3.1) ClipForm
FX (Sage-ST
TM
3.1) MoveForm
FX (Sage-ST
TM
3.1) SetColor
FX (Sage-ST
TM
3.1) SwitchColors
ModSys DEC
ModSys INC
Exec DosCommand
DATABASE OPERATIONS
Sage Current
Sage EQ
Sage First
Sage GE
Sage GT
Sage Last
Sage LE
Sage LT
Sage NE
Sage Next
Sage NextEQ
Sage Positional
Sage Previous
Sage PreviousEQ
DATABASE FIELD MANIPULATION
Sage CompareFieldA
Sage CompareFieldR
Sage GetFieldA
Sage GetFieldI
Sage PutFieldA
Sage PutFieldI
Sage ClearRecord
Sage ClearField
Sage CopyField
Sage ClearPW
Sage SetPW
Sage SageError
Sage ReBuildIndex
SageLib RecordEdit
SageLib ScrollRelation
FORM / TERMINAL HANDLING
Display DisplayForm
Display DisplayBackground
Display DisplayError
Display DisplayMessage
Terminal CondRead
Terminal ReadString
Terminal WriteString
Terminal WriteLn
ThorPort CursorMove
ThorPort ClearScreen
ThorPort Pause
STRING HANDLING
Strings Assign
Strings Conca
Strings Length
Strings Substring
REPORTS
Reports CloseReport
Reports ConsolePrompt
Reports ConsoleTerminate
Reports CurrentPage
Reports DefineConsoleWindow
Reports DefineFooter
Reports DefineHeader
Reports DefineHeader2
Reports DefineReport
Reports DefineTopForm
Reports OpenReport
Reports OverWrite
Reports PositionConsoleRow
Reports RemainingLines
Reports TopOfPage
Reports UnderLine
Reports WrCard
Reports WrCardPos
Reports WrForm
Reports WrLn
Reports WrString
Reports WrStringPos
Grapl Syntax
A GRAPL file is created with any editor which outputs an ASCII file.
The program file must be saved with a ".GPL" suffix. Like Ada, GRAPL
is not case sensitive. Execution of the GRAPL program is begun by
typing: "GRAPL progname" where "progname" may be any program you have
created. To execute in a step mode, type "GRAPL progname STEP".
GRAPL is exactly like an Ada program with the exception of types and
instantiation. Variables are limited to strings, integers, and
Booleans. Types are not allowed. The following Ada reserved words
are allowed in a GRAPL program:
AND FLOAT OTHERS
BEGIN IF OUT
BOOLEAN IN PROCEDURE
CASE INTEGER FILERP
CHARACTER IS RETURN
ELSE LONG_INTEGER STRING
ELSIF LOOP THEN
END NATURAL TRUE
EXIT NULL WHEN
FALSE OR WITH
'IMAGE
'LENGTH
'POS
'VALUE
What You Can't Do In Grapl
TYPES
No programmer-declared types. No arrays. No access (pointer) types.
The only types which can be used are character, string, integer,
long_integer, natural, and float.
Multiple variables on the same declaration line
no
yes
i, j, k : NATURAL; i : NATURAL;
j : NATURAL;
k : NATURAL;
FUNCTION (procedures used as functions)
no
yes
function A return integer is procedure A (i : in out integer) is
begin begin
return 3; i := 3;
end A; end A;
Functions passed as arguments to procedures
no
yes
WriteString (integer'image(i)); WriteString (s);
s := integer'image(i);
WHILE
no
yes
while (i < 10) loop loop
i := i + 1; if (i >= 10) then
end loop; exit;
end if;
i := i + 1;
end loop;
FOR
no
yes
for i in 1..10 loop i := 1;
. loop
. if (i > 10) then
. exit;
end loop end if;
i := i + 1;
end loop;
String Concatenation
no
yes
s := "Hello" & " there" Concat ("Hello"," there",s,done)
Array Slicing
no
s := t(1..3);
Generics - no
PROCEDURE 1 is
WITH Sage;
-- variables (string, integer and boolean)
PROCEDURE n is
-- variables (string, integer and boolean)
BEGIN
(GRAPL code with Sage-ST
TM
calls)
END n;
BEGIN
.
(GRAPL code with Sage-ST
TM
calls)
.
END 1;
GRAPL-CALLABLE Sage-ST
TM
MODULE SPECIFICATIONS
Grapl-Callable Sage-ST ä Package Specifications
The following packages provide the specifications for the Sage-ST TM procedures that may be called from GRAPL programs:
1.
DisplayBackground
2.
DisplayError
3.
DisplayForm
4.
DisplayMessage
1. DosCommand
1.
ClearWindow
2.
ClipForm
3.
MoveForm
4.
SetColor
5.
SwitchColors
type SageOperations is (First, Next, Previous, Last, NextEQ, PreviousEQ, NE, LT, LE, EQ, GE, GT, Positional, Current);
'Positional' is used internally, it is not used by application developers
SageError : ModSys.S_natural; -- Error returned from Sage-ST TM operations
Sage Functions/Procedures
IF
str1 : string (1..10);
Strings.Assign ("Sage-ST
TM
", str1, done);
(str1 looks like "Sage-ST
TM
nul ")
THEN
str1'length = 10 the length of the Ada string
Strings.Length (str1) = 7 the length of the Sage-ST
TM
string
IF
str1 : string (1..10);
Strings.Assign ("IdahoFalls", str1, done);
(str1 looks like "IdahoFalls")
THEN
str1'length = 10 the length of the Ada string
Strings.Length (str1) = 10 the length of the Sage-ST
TM
string
This library is used to manipulate logical strings (Sage-ST
TM
strings)
using apparent lengths (Sage-ST
TM
string lengths). To manipulate only
declared strings with no regard to logical strings, the Ada
predefined language attributes may be used (e.g., P'Length, P'First,
P'Last, and array slicing).
-- number of storage screenchar per screen
MaxScreenSize : constant ModSys.S_integer := 2000;
-- number of normally useable screenchar
ScreenSize : constant ModSys.S_integer := 1920;
type SCREENCHAR is record
c : byte;
a : byte;
end record;
type SCREENCHAR_u_array is array (ModSys.S_integer range <>) of SCREENCHAR;
type SCREENCHAR_u_access is access SCREENCHAR_u_array;
subtype normalScreen is SCREENCHAR_u_array (0..MaxScreenSize1);
type screendef is access normalScreen;
subtype formScreen is SCREENCHAR_u_array (0..ScreenSize1);
type formScreenAccess is access formScreen;
procedure Free_screendef is new UNCHECKED_DEALLOCATION
(normalScreen, screendef);
procedure Free_formScreen is new UNCHECKED_DEALLOCATION
(formScreen, formScreenAccess);
BitsPerPixel : ModSys.S_natural;
PixelsPerByte : ModSys.S_natural;
PixelsPerLine : ModSys.S_natural;
BytesPerLine : ModSys.S_natural;
Mode : ModSys.S_natural;
VideoOn : boolean;
shadowVideo : boolean;
ScreenAppearance : byte;
DMABufLoc : screendef;
warren.merrill@inl.gov
,
ftp://sage.inel.gov
Copyright © 1989-2006. Battelle Energy Alliance