PROGRESS 4GL
PROGRAMMING MODELS
Differ in flow of execution and structure.
Procedure Driven – Procedures explicitly directs the flow of data
and control. Flow of execution is determined by the programmer.
Generally Top down approach.
Structure
Test for Condition.
Execute a block of code.
Control the [Link]
Event Driven – Procedures responds to the flow of data and
control. Flow of execution determined by the system. An event is
any time of interaction a user of operating system can have with
an application. Each trigger is a programmed response, a self
contained block of code that performs a specific task. The
sequence of events determines which of the predefined triggers are
to be executed and in what order.
Structure
Definitions – Functional objects(buttons, frames, triggers)
of user interface.
Triggers – Response to events
Main Logic – Establish a WAIT-FOR state to interact with
user interface objects and then dismiss the interface when
the WAIT-FOR condition is satisfied.
BLOCKS in Progress
Procedure Blocks
External Procedure
Non-Persistent
The context of a non-persistent procedure remains in scope
only until the RUN statement that executes it completes.
External procedure is non-persistent by default.
Persistent
A persistent procedure creates its context when it
executes and then maintains that context after it returns
until the end of the Progress session, or until it is
explicitly deleted.
RUN filename PERSISTENT [ SET handle ] [ run-options ]
DELETE PROCEDURE handle [ NO-ERROR ]
The handle is a field or variable defined with the HANDLE
data type. The RUN statement sets handle to a procedure
handle value that identifies the current context of the
persistent procedure. You can use this procedure handle to
invoke procedure triggers or internal procedures defined
in the persistent procedure context.
If you do not specify handle when you create a persistent
procedure, you can obtain the handle for the procedure
using the SESSION system handle. Progress maintains all
handles to persistent procedure instances in a chain that
you can access. The SESSION handle has two attributes,
FIRST–PROCEDURE and LAST–PROCEDURE, that provide access to
the first and last persistent procedures (respectively)
that are created. These attributes return procedure
handles that you can use to reference attributes of each
persistent procedure context.
Internal Procedure
Iteration Blocks
(Ex: FOR-END, DO-END, REPEAT-END)
Editing Blocks
Executes once for each keystroke received during the execution of the
input statement and thus allows the application to manage the input
for each field one key stroke at a time.
Transaction Blocks
Trigger Blocks
STANDARD EXECUTION OPTIONS (internal & external procedures)
The run-options of the RUN statement can include run-time parameters,
compile-time arguments and NO-ERROR option for handling run-time errors.
Run-time parameters include comma-separated data items enclosed in
parentheses. Each data item is preceded by INPUT, OUTPUT, INPUT–OUTPUT,
or BUFFER, corresponding to the type of parameter defined by the DEFINE
PARAMETER statement in the procedure. In general, the data items passed
in the RUN statement must match, in data type and order, the
corresponding parameters defined in the called procedure.
Compile-time arguments consists of any space-separated strings that you
want to pass to the procedure at compile time. When executed with
compile-time arguments, Progress automatically recompiles the procedure,
substituting each argument for {n} in the 4GL, where n is an integer
specifying the ordinal position of the argument in the RUN statement,
starting at 1. Compile-time arguments must follow any run-time
parameters in the statement. You can only specify compile-time arguments
when running external procedures.
SCOPE OF A RECORD
Scope of a record is the smallest enclosing block that encompasses all
references to the record. The exceptions are;
A strong-scoped reference occurs for buffers that are referenced in the
header of a REPEAT FOR or DO FOR block. Any reference to that buffer
within the REPEAT FOR or DO FOR block is a strong-scoped reference.
A weak-scoped reference occurs for buffers that are referenced in the
header of a FOR EACH or PRESELECT EACH block. Any reference to that
buffer within the FOR EACH or PRESELECT block is a weak-scoped
reference.
All other references to records are free references.
TRANSACTIONS
A transaction is a set of changes to the database that is either
executed completely or leaves no modification to the database.
A subtransaction is nested in a transaction and encompasses all activity
within one iteration of the following kinds of blocks: DO ON ERROR, FOR
EACH, procedure, REPEAT, and triggers.
ERROR PROCESSING
Depends in what type of error is generated. Progress recognises the
following errors.
Procedure-generated error – Performs UNDO,RETRY
Predefined error key – Performs UNDO,RETRY
Predefined ENDKEY key – Performs UNDO,LEAVE
The END-ERROR Key - Performs UNDO,LEAVE(if user has not
specified any keyboard events) or UNDO, RETRY (if they have).
A system or software failure – Undoes any partially completed
transaction in the system for all users on the system.
The STOP key - Undoes the current transaction and retries the
startup procedure.
DATABASE TRIGGERS
A database trigger is a block of 4GL code that executes whenever a
specific database event occurs. A database event is an action performed
against a database.
Ex: CREATE, WRITE, FIND, ASSIGN, DELETE.
Two Types of Database Triggers;
Schema Trigger
A .p procedure that you add through the Data Dictionary to the
schema of the database. They are independent procedures and
always executed when a specified event occurs.
This trigger definition is stored in a trigger procedure. A
trigger procedure is a Progress procedure file that begins with
a trigger header statement. When defining the trigger, you have
the option to specify CRC checking. Thus Progress can verify that
the trigger procedure is valid before running it.
Session Trigger
A section of code that you add to a larger enclosing procedure.
They are defined as part of an application and are only in effect
for that application.
When both triggers are defined for the same table/event or field/event
pair, then session trigger executes first except for FIND event. For
FIND session trigger can be executed first if schema trigger is defined
as overridable (OVERRIDE = YES) and specify the OVERRIDE option in
session trigger.
TEMPORARY TABLES & WORK TABLES
TEMP TABLE
Temporary tables are stored on disk in a temporary database and are
available for the duration of the procedure that defines them. Indexes
can be defined for TEMP-TABLE.
WORK TABLE
Defines a work table (a temporary table stored in memory) for use within
a procedure or within several procedures. The WORKFILE keyword is
allowed for backward compatibility only; using WORK-TABLE or WORKFILE
has the same effect. Indexes cannot be defined for WORK TABLE.
Work tables are to DB tables what variables are to DB fields.
BUFFER
PROGRESS provides you with one buffer for each table that you use in a
procedure. PROGRESS uses that buffer to store one record at a time from
the table as the records are needed during the procedure.
Temporary tables are not limited to the value of the buffer size defined
by the –Bt parameter. Progress stores any overflow of temporary table
records to disk. Work tables, however, are limited by the amount of
memory available on your system.
Progress Database Table Temporary Table Work Table
Feature
Database Progress uses Progress uses the Progress does not
manager the database database manager use the database
manager in a in single-user manager when
single- or mode to access working with work
multi-user mode the temporary tables. Work tables
when working database that are stored in
with database contains the memory.
tables. temporary tables.
Indexes You can define You can define You cannot define
indexes for indexes for indexes for work
database tables. temporary tables. tables.
Record To remove If you do not If you do not
deletion database records explicitly delete explicitly delete
from the records in the records in a work
database, you temporary table, table, Progress
must explicitly Progress discards discards those
delete them with those records and records and the
the DELETE the temporary work table itself
statement. table itself at at the end of the
the end of the procedure that
procedure or initially defined
session that the work table.
initially defined
the temporary
table.
Record A database table A temporary table Work tables cannot
movement can move data cannot move data move data between a
between a record between a record record buffer and a
buffer and a buffer and a database record.
database record. database record.
Multi-user Multiple users Users do not have Users do not have
record can access access to access to
access the same each other’s each other’s work
database table temporary tables.
at the same tables.
time.
Transactions Progress You must start You must start
automatically transactions transactions
starts explicitly. explicitly.
transactions for Temporary tables Work tables use the
certain blocks use the local local before-image
and statements. before-image file file to roll
Database tables to roll back back transactions.
use the before- changes.
image file to
rollback changes
Buffer size Use the –B Use the –Bt Available memory
parameter to parameter to determines the work
specify the specify the table
database table temporary table buffer size.
buffer size. buffer size.
Location Database tables Temporary tables Work tables are
are stored are stored in the stored in memory.
directly in the directory where
database. Progress stores
temporary files.
Special data You can store You can store You can store RAW,
type support RAW and RECID RAW, ROWID, and RECID
fields, but not ROWID, and RECID fields in a work
ROWID fields, in fields in a table.
a database temporary table.
table.
Triggers and Database tables Temporary tables Work tables do not
Events support triggers do not support support
and events. triggers and triggers and
events. events.
Type Options Visibility Life Span
Not Shared DEFINE... The creating The creating
and procedure procedure
Not Global
Shared DEFINE NEW SHARED... The creating The creating
(in the creating procedure, and the procedure
procedure) procedures that the
DEFINE SHARED... creating procedure
(in the procedures that calls that want to
the creating procedure share the temporary
calls that want to table.
share the temporary
table)
Global DEFINE NEW All procedures in The Progress
GLOBAL... the Progress session
(in the creating session
procedure, and in other
procedures the Progress
session want to access
the temporary table)
APPLICATION SECURITY
Progress provides the following levels of application security:
Connection security ensures that only authorized users can connect
to the database.
Schema security ensures that only authorized users can modify
table, field, and index definitions.
Compile-time security ensures that only authorized users can
compile procedures that perform specific data accesses.
Run-time security ensures that only authorized users can run
specific precompiled procedures.
The security administrator can define security for the first three
levels (connection time, schema, and compile time) in the Data
Dictionary.
KEYWORDS
FIND
Locates a single record in a table and moves that record into a record
buffer. If there are multiple records satisfying the same criteria FIND
will fail.
FIND FIRST
Finds the first record in the table that meets the characteristics you
might have specified with record.
FIND LAST
Finds the last record in the table that meets the specified
characteristics of the record.
FIRST-OF
Returns a TRUE value if the current iteration of a DO, FOR EACH, or
REPEAT . . . BREAK block is the first iteration for a new break group,
and modifies all three block types. Break group is the The name of a
field or expression you name in the block header with the BREAK BY
option.
LAST-OF
Returns a TRUE value if the current iteration of a DO, FOR EACH, or
REPEAT . . . BREAK block is the last iteration for a particular value of
a break group.
FOR FIRST
Uses the criteria in the record-phrase to find the first record(based on
the primary index) in the file that meets that criteria. PROGRESS finds
the last record before sorting.
FOR LAST
Uses the criteria in the record-phrase to find the last record in the
file that meets that criteria. PROGRESS finds the last record before
sorting.
NO-UNDO
When the value of a variable is changed during a transaction and the
transaction is undone, PROGRESS restores the value of the variable to
its prior value. If you do not want, or if you do not need, the value of
a variable to be undone even when it has been changed during a
transaction, use the NO-UNDO option with the DEFINE VARIABLE statement.
NO-WAIT
Specifies not to wait for a record that is currently locked by another
process. Instead, the record in conflict will be made available in NO-
LOCK mode and the LOCKED function for that record will return TRUE.
ECHO
Sends all input data read from a file to the output destination. Data is
echoed by default.
NO-ECHO
Suppresses the echoing of input data to the output destination.
EXTENT
Specifies the extent of an array variable, where n is an integer
contant. If you are using the AS datatype option and you do not use the
EXTENT option (or specify n as 0), the variable is not an array
variable. If you are using the LIKE field option and you do not use the
EXTENT option, the variable uses the extent defined for the database
field you name.
If you want to define a variable that is like an array variable or
field, but you do not want the variable to be an array, you can use
EXTENT 0 to indicate a non-array field.
COMBO-BOX
A COMBO-BOX consists of a field value and an associated drop down list
of possible values.
ALERT-BOX - ALERT-BOX QUESTION BUTTONS YES-NO-CANCEL TITLE ""
Specifies that the message is displayed in an alert box rather than in
the window message area. The value of alert-type determines the type of
alert box. MESSAGE, QUESTION, INFORMATION, ERROR, WARNING.
LIST-ITEMS
Specifies a delimiter-separated list of items associated with the combo
box or selection list.
EXPORT
Converts data to a standard character format and displays it to the
current output destination (except when the current output destination
is the screen) or to a named output stream. You can use data exported to
a file in standard format as input to other PROGRESS procedures.
IMPORT
Reads a line from an input file that might have been created by the
EXPORT statement.
ENTRY(element,list [,delimiter])
Returns a character string entry from a list based on an integer
position.
LOOK-UP(expression,list [,delimiter])
Returns an integer giving the position of an expression in a list.
Returns a 0 if the expression is not in the list.
CAN-FIND
Returns a TRUE value if a record is found that meets the specified FIND
criteria; otherwise it returns FALSE. CAN-FIND does not make the record
available to the procedure.
INDEX(source,target [,starting])
Returns an integer that indicates the position of the target string
within the source string.
CAN-DO(list, user-id)
Compares the current user ID with a list of users who have permission to
access a specified file. Returns a TRUE value if the user ID matches an
entry in the [Link]-DO is executed by the client and is designed to be
used with user-ids only.
NUM-ENTRIES
Returns the number of items in a list.
CASE-SENSITIVE
CASE-SENSITIVE indicates that the value stored for a character variable
is case sensitive, and that all comparisons operations involving the
variable are case sensitive. If you do not use this option, PROGRESS
comparisons are usually case insensitive. If you define a variable LIKE
another field of variable, the new variable inherits case sensitivity.
Use [NOT] CASE-SENSITIVE to override this default.
USE-INDEX
Identifies the index you want to use while selecting records. If you do
not use this option, PROGRESS selects an index to use based on the
criteria specified with the WHERE, USING, OF, or constant options.
USING [ FRAME frame ] field [ AND [ FRAME frame ] field ]
One or more names of indexed fields for selecting records. The field you
name in this option must have been entered previously, usually with a
PROMPT-FOR statement.
NO-LOCK
Records can be read even when they are in update mode.
SHARE-LOCK
Records can be read but cannot be updated even by another user. Default
lock for READ mode.
EXCLUSIVE-LOCK
Records can be read and updated only the user who has given this lock.
To read the record NO-LOCK should be given. Default lock for UPDATE
mode.
Parameter File(.pf)
Used to start a progress session. Only a limited no of parameters can be
passed to PRO (9) or _progress. Hence we use .pf to write all the
startup parameters in this file.
.i and .p files
During compilation .i file will be replaced by the section of code
in .i. In the case of .p subprogram control passes to that .p. This will
require use of stacks.
.i cannot be complied separately. When .p is compiled its
corresponding .i will also be compiled.
.i can be included in .p and vice-versa.
PROPATH
Stores list of comma separated directories where progress programs are
stored.
DLC
Specifies the pathname of the directory where your PROGRESS system
software is installed.
.lk file
Lock file is created when the session starts and deleted when all the
session expires. It will not be deleted when there is an abnormal
shutdown.
Meta Schema files
These files are a part of databases files and contains all the table
structure, index sequences, triggers, security etc. These files are
hidden by default.
Screen Buffer
It is a terminal buffer. Anything which is displayed on terminal is
first defined in screen buffer.
Record Buffer
Buffer where progress stores data when we write FOR EACH. At the end of
FOR EACH Record Buffer will be deleted. Acts as intermediator between
Database and Screen Buffer.
CRC
Cyclic Redundancy Code can be used for verifying the compatibility of
compiled .r with the existing databases schema. Progress stores CRC and
time stamp. These are stamped in compiled .r at the time of compliing.
Loading data
Load data from .d
Load data with CIM(Common Interface Module)
FOREIGN KEY
FK is an index(non-unique) which will be referring to a primary key of
any table.
SEEK
Returns the offset of the file pointer in an text file. You define a
procedure variable to hold the offset value and later position the file
to that offset.
To determine whether an output stream is closed, use the SEEK function.
SEEK() returns ? when the stream is closed.
RECID
Returns the unique internal identifier of the database record (RECID)
currently associated with the record buffer you name.
The value of a record's RECID does not change over the life of the
record, unless the database is dumped and loaded at which time the
records get new RECIDs. Using a RECID directly is the fastest way to
find a particular record. The RECID data type specifies a field or
variable that can hold a record identification number.
Earlier Progress versions provide RECID as the only way to fetch a
record pointer (supported in this version for backward compatibility).
RECID is limited to a 4-byte record address supported by only a few
DataServers and standard Progress. ROWID provides a variable byte string
that can represent a record address for any type of DataServer.
STREAMS
When you start a procedure, Progress automatically provides that
procedure with input and output streams. The default source for the
input stream is the terminal and the default destination for the output
stream is also the terminal.
INPUT THROUGH
Uses the output from a UNIX program as the input to a PROGRESS
procedure.
OUTPUT THROUGH
Identifies a new output destination as the input to a UNIX process that
PROGRESS starts.
BROWSE
A browse widget is a representation of a query. A query is the list of
database records from one or more tables that match the supplied
selection criteria. A browse is an object that displays data from the
query in rows and columns. A row represents the data of a single record.
A column represents all the values of a particular field. A row and
column intersection, called a cell, represents the value of the field
(column name) in that particular record. A user can scroll up and down
the rows, and left and right through the columns.
ENABLE Statement
Enables input for field-level widgets within a frame.
DISABLE Statement
The DISABLE statement disables input for one or more field-level widgets
within a frame that were previously enabled with the ENABLE statement.
Disabling a widget prevents the user from providing input to the widget,
but does not remove it from the display.
Common .i’s Used:
mfdtitle.i
mfdeclre.i
mfnp.i
mfnp01.i
mfnp05.i
mfnp06.i
mfphead.i
mfphead2.i
mfrtrail.i
mfselprt.i
mfselbpr.i
mfreset.i
mfrpexit.i
mfquoter.i
mfmsg.i
mfmsg01.i
mfmsg02.i
mfmsg04.i
TIME:
00:00:00 – 0
12:00:00 – 43200
24:00:00 – 86400
Primary Data Handling Statements
UPDATE
SET
PROMPT-FOR ASSIGN
ENABLE WAIT-FOR DISABLE
DISPLAY
VIEW
Data Flow
Statement Database Record Screen User
Record Buffer Buffer
ASSIGN
CREATE
DELETE
DISPLAY
ENABLE
FIND
FOR EACH
GET
INSERT
OPEN QUERY
PROMPT-FOR
RELEASE
REPOSITION
SET
UPDATE
PROMPT-FOR - Prompts the user for data and puts into screen buffer.
ASSIGN – Move data from screen to record buffer.
SET - Combination of PROMPT-FOR and ASSIGN.
UPDATE – Combination for DISPLAY, PROMPT-FOR and ASSIGN.
DISPLAY - Move the value into screen buffer and displays it.
INPUT - Refer the value of field in a frame.