home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
DATABASE
/
Q_PRO4B.ZIP
/
QP4DOC.DOC
Wrap
Text File
|
1989-09-01
|
436KB
|
15,711 lines
Q N E I N T E R N A T I O N A L P R E S E N T S
TM
Q - P R O 4 (Shareware)
Version 4.0
Q-PRO 4 is a fourth generation language and database for IBM PC-
DOS, Generic MS-DOS, Novell Netware, and all LANs and networks
that are IBM Netbios compatible.
Written in assembler, the Q-PRO 4 interpreter is amazingly fast.
In fact, screen and file speed are so fast that an ordinary 4.77
Mhz PC with floppy disks makes a dandy application machine.
Application development is typically 5 to 10 times faster than
other databases because of Q-PRO 4's advances features. Some of
them are:
- Advanced fourth generation event driven architecture.
- "Painted" screens.
- Fill in the blanks data entry screens.
- Extremely fast B+ tree multikey indexed file handling.
- Inherently structured high level complete language syntax
with: procedures, table lookup, memory and file arrays,
subroutines, assembly language interface, and data
dictionary.
- Full record and file locking on supported LAN's and
networks.
- No practical limits on File Size, number of files open
simultaneously, record size, or memory variables.
- Optional distribution system and licence.
- Optional translator to language C.
Thousands of commercial copies of Q-PRO 4, Version 4.0, are in
use in the United States and 40 foreign countries (including a
Japanese Language version) since 1986. It has been reviewed in
Data Based Advisor, PC Magazine and others with universal
acclaim.
We have recovered our development and made a modest profit so we
have decided to place it into shareware so more people can try
this extraordinary language.
Release 1.0
Langhorne, Pennsylvania
September 1, 1989
Copyright (C) 1983-1989 QNE International. All rights reserved.
No part of this manual may be reproduced, transmitted, transcribed, stored
in a retrieval system, or translated into any language (natural or
computer), in any form or by any means, except as described in the
following license, without the prior written permission of QNE
International.
You are granted a limited license to use the software described in this
manual. The software may be used or copied only in accordance with the
terms of that license, which is described beginning on the next page.
Information in this manual is subject to change without notice and does not
represent a commitment on the part of QNE International
QNE International may make improvements and/or changes in this manual
and/or in Q-PRO 4 Test Drive and/or in Q-PRO 4 at any time.
QNE International is a registered trademark, and Q-PRO 4 is a trademark of
QNE International.
QNE International
136 Granite Hill Court
Langhorne, PA 19047
(215) 968-5966
T H E Q - P R O 4 P R O D U C T F A M I L Y
=================================================
Version 4.0
-----------
Q-PRO 4 User's Group (QUG)
--------------------------
Join QUG for only $25.00 per year and enjoy the benefits of a bulletin
board for users with hints, techniques, and public domain Q-PRO 4 software.
Q-PRO 4
-------
This is the highly regarded and well reviewed version of the commercially
successful Q-PRO 4, Version 4.0. Full system, manual, and 30 days (up to 2
hours) free telephone support.
Q-PRO 4 Plus
------------
The same as Q-PRO 4 with a six file report generator, dBASE II/III/IV
inport utility, Lotus import/export utility, custom configuration
utilities, and 60 days (up to 3 hours) of free telephone support.
Authors LockUp
--------------
With this set of utilities, the application developer can encrypt and lock
the program code. Purchase of this package includes a non-transferrable,
unlimited distribution licence.
Q2C
---
This product translates the Q-PRO 4 source code to language C. It is then
compiled and linked producing .EXE files. You can embed function calls and
C programs in the source code. Includes a non-transferrable, unlimited
distribution licence.
Q-Query
-------
This is a "post-relational" query system designed for developers and
endusers.
Version 5.0
-----------
Q-PRO 4, Version 5.0 is the gateway to OS2 and UNIX/XENIX. All version 4.0
code is upwards compatible to version 5.0. From there a whole new world of
hardware and operating systems is available.
Version 3.0
-----------
For you unreconstructed 8 bit users, there is even a version that runs very
nicely on CP/M and MP/M-80 (Turbodos too!). Call for information.
Quic Start for the Impatient
3
Q U I C S T A R T for the I M P A T I E N T
=================================================
For those of you who don't read the documentation except as a last resort,
this short guide is dedicated. We also assume that you know exactly what
you are doing!
Things You Must Do
------------------
1. Unpack the software. The software is in a self unpacking format. Simply
log on the target drive and type the name of each furnished .EXE file.
2. * * * * LOAD BTSYS.EXE * * * * by typing BTSYS. If you skip this
step, you won't be able to read or write data files.
The Minimum
-----------
Q-PRO 4 uses a combination of procedural code and "painted" screens. You
write the pro-gram and paint the screen with the Binary Workstation editor.
File handling is multikey indexed sequential, random, or sequential. Most
data files are indexed. Indexed and random files are defined with a File
Item Description (FID) file.
Getting On With It
------------------
Load BW.EXE, the program editor. You use BW to:
- write the programs. It comes up ready to edit your program code.
Functions are initiated by pressing function keys. The menu is shown
at the bottom of the screen.
Pressing F10 will scroll forward the functions associated with each
function key. Pressing F9 scrolls backwards.
- develop the screens. While in BW, press F8 to go to the screen
editor. Type the labels/prompts on the screen the way you want then to
be. Press F1 to bring up a window used to define enterable screens.
- define the FID files.
Putting It Together
===================
Application Overview
--------------------
Generally, you develop an application one program (or screen) at a time.
Programs can freely "chain" each other into and out of memory. Registers,
files and disk I/O buffers remain intact between screens.
Quic Start for the Impatient
4
Program Flow of Control
-----------------------
Q-PRO 4 is "Event driven" so flow of control is completely different than
almost every other language. Control goes back and forth between the
operator and program. This is always under the control of the programmer.
For example, when the user is entering data on the screen, he has control.
When he moves to the next enterable field, usually the programmer has
control.
Developing Programs
------------------
The sequence of developing a program module is usually:
1. Design the screen and its entry fields. The screen data entry fields,
once defined, are the same as defining memory variables, i.e. you can
interrogate their value, move data into and out of them, etc.
One of the fields to be filled out when defining a screen data entry
is "PROCEDURE NAME". If you enter a name here, when the user enters
the field and then goes to the next field by pressing return or an
arrow, the named procedure will be executed.
2. Write the program code. The program code is organized into PROCEDURES
or PROC's. A procedure is initiated with the keyword (not too
surprisingly) PROC followed by a space and the name of the procedure.
PROC names (and all other names) are limited to 10 characters in
length and MUST begin with an alpha character. (NOTE: Q-PRO 4 treats
upper and lower case identically.)
PROCS are terminated with either an END or in the case of a "CALLed"
proc RETURN. When the proc terminates control reverts to the operator
in the enterable screen data field that the programmer puts him in.
Usually this is the next enterable field, but the programmer has full
control of this.
3. Designing the files. Usually the primary data file is very similar to
the fields on the screen. If this is the case, the Quic FID facility
can be utilized very effectively.
4. Learning the language. Look over the included sample programs
starting with SAMPINS.QNE. They are profusely commented and
illustrate some common coding techniques.
Read the Commands Section of the manual to see the breadth of commands
available.
Quic Start for the Impatient
5
Quic Reference Card
===================
IBM PC Terminal Keyboard Definitions
Cursor Left . . . . . . Left Arrow
Cursor Right. . . . . . Right Arrow
Cursor Up . . . . . . . Up Arrow
Cursor Down . . . . . . Down Arrow
Cursor Home . . . . . . Home
Tab . . . . . . . Return key
Back Tab . . . . . . . Shift Tab
Enter Data . . . . . . END
Function 0 . . . . . . ESC
Funct 1-9 . . . . . . F1-F9
Funct 11-20 . . . . . . SF1-SF10
Clear Screen . . . . . Control Home
Clear to End of Line . Control End
Clear to End of Screen Control Pg Down
Insert Character. . . . Insert Key
Delete Character. . . . Delete Key
COMMAND SYNTAX
--------------
Items within braces {} are optional. Items within angle brackets <> denote
a class of item, rather than a literal value. Square brackets [] are
required where shown.
Field Descriptor Values
-----------------------
Space,x any data
X any data, forced to upper case
a alphabetic data(A-Z,a-z,blank)
A alphabetic data forced to upper case
m alphanumeric data (A-Z, a-z, 0-9, blank)
M alphanumeric data forced to upper case (A-Z, a-z, 0-9, blank)
n,N numeric data (0-9 + - .)
i,I integer data (0-9 + -)
d, D digit data (0-9)
Field Functions
---------------
= autoduplicate ? invisible field
Quic Reference Card
Page 6
Data Elements
--------------
Registers" Numeric: #N0 to #N9
String: #S0 to #S9
Boolean: #B0 to #B9
Error: #E Field: #F
Line: #L Keyout: #K
Page: #P
Screen Fields
-------------
$FIELD [<expression>] $OFFSET [<screen data field name>]
File Fields
-----------
&<file field name>[<file #>] &<file field name>[<file #>,<index>]
Literals
--------
String (". . ." or '. . .') Numeric (1,37,5 etc.)
Control character (@<value>)
Variables
---------
B - Boolean or bit (set(1) or reset(0))
I - Integer (-2,147,483,648 to 2,147,483,647)
F - Floating Point (1.7E-308 to 1.7E+308)
N - Numeric (0-9, decimal point, plus sign)
X - String (X indicates any data: alphanumeric, symbols, etc.)
<variable name> <N or X>, <length> {,<dimension>} {,<2nd dimension>}
Keyout Values (#K)
-------------
0 - Typed out 1 - Tabbed out
2 - Backtabbed out 3 - Cursor up
4 - Cursor down 5 - Cursor left
6 - Cursor right 7 - Enter
8 - Home 9 - Any Function key
10 - Break
Quic Reference Card
Page 7
Commands
--------
File Handling
-------------
BACKSPACE <file#>{:<error>}
CLOSE {file# or *}{:<error>}
COPY <file# or *> TO <file# or *> {:<error>}
ERASE <filename>{:<error>}
FCOPY <filename>TO<filename>{:<error>}
FILETYPE <file#>{:<error>}
FREE <file#>{:<error>}
FSEAR <file#>{NOADV}AT<condition> {:<error>}
GET <data or *> FROM <file#> FOR <length>{TRIMMED}{:<error>}
KEY <file#>USING<key#>{:<error>}
LRETRY <retrycount>
MAKE/OPEN
sequential out
<filename>,0,<file#> {:<error>}
sequential in
<filename>,1,<file#>{:<error>}
SDF out
<filename>,4,<file#>{:<error>}
SDF in
<filename>,5,<file#>{:<error>}
Random/Indexed
<filename>USING<FIDname>{INDEX<indexname>},<file#>, {UNLOCKED} {R/O}
{:<error>}
POSN <file#> TO <record or key> {RELATIVE} {USING<key#>} {DESCENDING}
{:<error>}
PUT <data or *> TO <file#>{FOR <length>}{:<error>}
RCLEAR <file#>{:<error>}
READ <file#>{NOADV}{:<error>}
RENAME <oldfilename>,<newfilename> {:<error>}
RESTART <file#>{TO<position>}{:<error>}
RLOCK <file#>{:<error>}
RUNLOCK <file#>{:error}
SECURE <file#>{:<error>}
WRITE <file#>{NOADV}{:<error>}
Error Handling
--------------
ERROR <error message, register, or variable>
ERRTRAP {<line#>}
NCHECK <data>{:<error>}
Quic Reference Card
Page 8
Data Formatting
---------------
EDIT <expression>USING<picture>INTO <data>{:<error>}
CENTER <data> CURRENCY <string> LCASE <data>
LJUST <data> RJUST <data> SIZE <data>INTO<data>{TRIMMED}
UCASE <data> UNEDIT <data>INTO<data>{:<error>}
Arithmetic
----------
ACCURACY <value> ADD <data>TO<data>{GIVING <data>}
CALC <data>=<expression> MUL <data>TIMES<data>{GIVING <data>}
ROUND <expression>BY<expression>INTO <data>
SUB <data>FROM<data>{GIVING <data>}
Logical
-------
RESET <Boolean register or variable> SET <Boolean register or variable>
Control Transfer
----------------
BEGIN {WHILE/UNTIL/IF <condition>}
ELSE {IF<condition>}
ENDBEGIN {WHILE/UNTIL <condition>}
BROFF BRON
CALL <procedure> CALL <table[index]>
CHAIN <filename>{:error}
END
FOR <index>=<expression>TO<expression>BY<expression>
ENDFOR <index>
GOTO <label> GOTO <table[index]>
RETURN
Conditional
-----------
IF<condition>{THEN}<statement>
Screen Control
--------------
CLEAR <field or *> CURSOR <row>,<column>
BUFFER <expression> FILL <character>
PRINT <data>{,<data> . . .} HELP <screen>{,<screen>}{:<error>}
HOME HOMECLEAR HOFF HON
LOCK <field> NEXT <field>
RESUME
UNLOCK <field or *>
Quic Reference Card
Page 9
Data Movement
-------------
CONCAT <data>{[<start>,<length or *>] } {TRIMMED} +<data>{[<start>,<length
or *>]} {TRIMMED} +. . . . INTO <data>{[<start or *>]} {TRIMMED}
MOVE <data> {[<start>,<length or *>]} TO <data> { [<start or *>]} {TRIMMED}
Table Management
----------------
TABLE <table name>
TSEAR <table> AT <key>{,<data>, <data>}{:<error>}
ASEAR <array name> {DOWN} USING <index> AT <condition> {:<error>}
Date Handling
-------------
JDPACK <string> INTO <data> JDUNPACK <data> INTO <string>
GETDATE <data> SETDATE <data>
Operating System Interface
FORMLOAD NOFORMLOAD
SYSTEM LPDETACH
HOST <host system> {:<error>}
RUN <file name> USING <parameter>{NOPAUSE} {NORETURN} {RELOAD} <filename>}
{CONTINUE} {:<error>}
Miscellaneous
-------------
* comment
SYSMODE BTAB <SET or RESET>
LPCHK <SET or RESET>
PRINTSCN {:<error>}
INSTR <substring>{TRIMMED},<string>{TRIMMED},<result>
Debugging
---------
NOTRACE TRACE DEBUG
Assembler Interface
-------------------
DEFSEG {<address>}
EXEC <input string> {,<output string>} {:<error>}
LOAD <filename>,<address>{:<error>}
PEEK <address>, <length>, <data> POKE <address>, <data>
Quic Reference Card
Page 10
SPECIAL PROCEDURES
==================
PROC BREAK PROC ENTER PROC ERROR
PROC KEY<N> PROC LOAD
FUNCTIONS
---------
ASCII Value: $ASC() e to Power: $ETOX()
Scrn.Field No.:$FIELD() Integer Value: $INT()
Top of memory: $MEMEND() Natural Log: $LN()
Screen Offset: $OFFSET()
Quic Reference Card
Page 11
Table of Contents
SINGLE COPY SOFTWARE LICENSE . . . . . . . . . . . . . . . . . . . . . 1
LIMITED LICENSE TO COPY . . . . . . . . . . . . . . . . . . . . . . . . 3
I N T R O D U C I N G Q-PRO 4 T E S T D R I V E . . . . . . . . . 4
Purchasing Q-PRO 4 . . . . . . . . . . . . . . . . . . . . . . . . 5
Q-PRO 4 O V E R V I E W . . . . . . . . . . . . . . . . . . . . . . . 7
Q - P R O 4 T U T O R I A L . . . . . . . . . . . . . . . . . . . . . 10
Installing Q-PRO 4 . . . . . . . . . . . . . . . . . . . . . . . . 11
Example Program . . . . . . . . . . . . . . . . . . . . . . . . . 11
Load Binary WorkStation . . . . . . . . . . . . . . . . . . . 11
STEP 1 - Build the Background . . . . . . . . . . . . . . . . 12
Graphics and Highlighting . . . . . . . . . . . . . . . . . . 13
STEP 2 - Define Fields . . . . . . . . . . . . . . . . . . . 13
Primary Edits . . . . . . . . . . . . . . . . . . . . . . . . 14
STEP 2a - Run the Screen Program . . . . . . . . . . . . . . 16
STEP 3 - Define the Data Files . . . . . . . . . . . . . . . 17
STEP 4 - Coding the Program . . . . . . . . . . . . . . . . 18
Using the Editor . . . . . . . . . . . . . . . . . . . . . . . . . 19
PROC LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
PROC NAMEP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Event Driving . . . . . . . . . . . . . . . . . . . . . . . . . . 22
The Linkage . . . . . . . . . . . . . . . . . . . . . . . . . 23
Adding the Linkage . . . . . . . . . . . . . . . . . . . . . 23
Recording Data . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Finding and Fixing Bugs . . . . . . . . . . . . . . . . . . . . . 24
Hints, Tips & Techniques . . . . . . . . . . . . . . . . . . . . . 29
Sample Programs . . . . . . . . . . . . . . . . . . . . . . . . . 29
Advanced Input Editing . . . . . . . . . . . . . . . . . . . . . . 31
Screen Handling . . . . . . . . . . . . . . . . . . . . . . . . . 33
Screen Graphics . . . . . . . . . . . . . . . . . . . . . . . 33
Screen Offset . . . . . . . . . . . . . . . . . . . . . . . . 34
Structured Programming . . . . . . . . . . . . . . . . . . . . . . 36
Structured Constructs . . . . . . . . . . . . . . . . . . . . 36
Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
All About Registers . . . . . . . . . . . . . . . . . . . . . . . 38
Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Declaring Variables . . . . . . . . . . . . . . . . . . . . . 44
Dimensioned Variables . . . . . . . . . . . . . . . . . . . . 45
LANs and Multiuser . . . . . . . . . . . . . . . . . . . . . . . . 46
Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Record Locking . . . . . . . . . . . . . . . . . . . . . . . 46
Quic Reference Card
Page 12
Record Unlocking . . . . . . . . . . . . . . . . . . . . . . 47
File Locking . . . . . . . . . . . . . . . . . . . . . . . . 47
Accession Number Management . . . . . . . . . . . . . . . . . 48
Restructuring an Indexed File . . . . . . . . . . . . . . . . . . 49
Adding Keys . . . . . . . . . . . . . . . . . . . . . . . . . 49
P R O G R A M M E R'S R E F E R E N C E M A N U A L . . . . . . . 50
Naming Conventions . . . . . . . . . . . . . . . . . . . . . 50
Format Files . . . . . . . . . . . . . . . . . . . . . . . . 50
Building a Format . . . . . . . . . . . . . . . . . . . . . . 50
Build Screens . . . . . . . . . . . . . . . . . . . . . . . . 51
THE PROGRAMMING SYSTEM . . . . . . . . . . . . . . . . . . . . . . 55
Procedures . . . . . . . . . . . . . . . . . . . . . . . . . 55
Screen Data Field Procedures . . . . . . . . . . . . . . . . 55
Data Items . . . . . . . . . . . . . . . . . . . . . . . . . 56
Standard Procedures . . . . . . . . . . . . . . . . . . . . . . . 60
PROC BREAK . . . . . . . . . . . . . . . . . . . . . . . . . 60
PROC ENTER . . . . . . . . . . . . . . . . . . . . . . . . . 60
PROC ERROR . . . . . . . . . . . . . . . . . . . . . . . . . 60
PROC KEY0-20 . . . . . . . . . . . . . . . . . . . . . . . . 61
PROC LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Statement Types . . . . . . . . . . . . . . . . . . . . . . . . . 61
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 63
Screen Offset . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Structured Programming . . . . . . . . . . . . . . . . . . . . . . 64
Tables and Table Handling . . . . . . . . . . . . . . . . . . . . 65
FILES AND FILE HANDLING . . . . . . . . . . . . . . . . . . . . . . . . 70
File Handler . . . . . . . . . . . . . . . . . . . . . . . . 70
File System Interrupts . . . . . . . . . . . . . . . . . . . 70
Loading BTSYS . . . . . . . . . . . . . . . . . . . . . . . . 70
File Types . . . . . . . . . . . . . . . . . . . . . . . . . 71
Multi-key Indexed Sequential Files . . . . . . . . . . . . . . . . 71
File Keys . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Reading and Writing . . . . . . . . . . . . . . . . . . . . . 71
Data File . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Index File . . . . . . . . . . . . . . . . . . . . . . . . . 72
Deleted Records . . . . . . . . . . . . . . . . . . . . . . . 73
File Maintenance . . . . . . . . . . . . . . . . . . . . . . 73
Random Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Sequential (text) Files . . . . . . . . . . . . . . . . . . . . . 73
SDF (Comma Delimited) Files . . . . . . . . . . . . . . . . . . . 74
Indexed and Random File Handling . . . . . . . . . . . . . . . . . 74
Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . 74
Data Dictionary (FID) Files . . . . . . . . . . . . . . . . . 74
PC-DOS and MS-DOS File Considerations . . . . . . . . . . . . 75
File Restructuring . . . . . . . . . . . . . . . . . . . . . 75
File Handling Commands . . . . . . . . . . . . . . . . . . . . . . 76
Quic Reference Card
Page 13
MAKE . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
OPEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
FILETYPE . . . . . . . . . . . . . . . . . . . . . . . . . . 76
CLOSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
SECURE . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
PUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
GET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
KEY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
POSN . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
READ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
WRITE . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
FREE . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
COPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
ERROR HANDLING . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Local Error Traps . . . . . . . . . . . . . . . . . . . . . . . . 80
PROC ERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
ERRTRAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
LANS and MULTIUSER SYSTEMS . . . . . . . . . . . . . . . . . . . . . . 84
Principles . . . . . . . . . . . . . . . . . . . . . . . . . 84
Multiuser Commands . . . . . . . . . . . . . . . . . . . . . . . . 84
MULTIUSER - ERRORS . . . . . . . . . . . . . . . . . . . . . . . . 87
B I N A R Y W O R S T A T I O N . . . . . . . . . . . . . . . . . . . 89
Starting Up . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
The Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . 93
Fid Generator . . . . . . . . . . . . . . . . . . . . . . . . . . 104
FID Files . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Referencing File Data Fields . . . . . . . . . . . . . . . . 109
Q - P R O 4 C O M M A N D S . . . . . . . . . . . . . . . . . . . . . 111
Symbology . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Structure of the Commands . . . . . . . . . . . . . . . . . . 111
Naming Conventions . . . . . . . . . . . . . . . . . . . . . 112
Data Items . . . . . . . . . . . . . . . . . . . . . . . . . 112
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 114
Function Summary . . . . . . . . . . . . . . . . . . . . . . . . . 115
Command Summary . . . . . . . . . . . . . . . . . . . . . . . . . 116
F u n c t i o n s . . . . . . . . . . . . . . . . . . . . . . . . 119
C O M M A N D S . . . . . . . . . . . . . . . . . . . . . . . . . 126
Q - P R O 4 E R R O R M E S S A G E S . . . . . . . . . . . . . . . 233
QMAINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Order Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
License Agreement
0
THIS SOFTWARE IS NOT FOR SALE
-----------------------------
Q-PRO 4 Test Drive is subject to the following license terms and
conditions.
SINGLE COPY SOFTWARE LICENSE
QNE International
----------------------------------
THIS IS A SINGLE COPY SOFTWARE LICENSE granted by Quic-n-Easi Products,
Inc, trading as QNE International, a New Jersey Corporation with its
mailing address at 136 Granite Hill Court, Langhorne, PA 19047. Q-PRO 4
Test Drive is licensed to you as the end user. It is not sold.
Q-PRO 4 Test Drive is copyrighted material. You may use it on a trial
basis provided you do not violate the copyright and if you follow these
simple rules. Use of Q-PRO 4 Test Drive on a regular basis requires
purchase as described later.
You may not make any changes or modifications to Q-PRO Tests DRIVE, and
you may not decompile, disassemble, or otherwise Reverse-engineer it. You
may not rent or lease it to others.
You may make copies of Q-PRO 4 Test Drive only under the terms of the
following section entitled "Limited License to Copy".
This Software is Commercial Computer Software under Federal Government
Acquisition Regulations and agency supplements to them. The Software is
provided to the Federal Government and its agencies only under the
Restricted Bights Provisions of the Federal Acquisition Regulations
applicable to commercial computer software developed at private expense and
not in the public domain. The Use, Duplication, or disclosure by the Gov-
ernment is subject to restrictions as set forth in subdivision (c)(l)(ii)
of the Rights in Technical Data and Computer Software clause at
252.227-7013.
LIMITED WARRANTY. QNE International does not warrant that the functions
contained in the software will meet your requirements or that the oper-
ation of the software will be uninterrupted or error free. The warranty
does not cover any media or documentation which has been subjected to
damage or abuse by you. The software warranty does not cover any copy of
the software which has been altered or changed in any way by you or others.
QNE International is not responsible for problems caused by changes in the
operating characteristics of the computer hardware or operating system
which are made after the delivery of the software.
ANY IMPLIED WARRANTIES INCLUDING ANY WARRANTIES OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE ARE LIMITED TO THE TERM OF THE
EXPRESS WARRANTIES. Some States do not allow limitations on how long an
License Agreement
1
implied warranty lasts, so the above limitation may not apply to you.
QNE International SHALL NOT IN ANY CASE BE LIABLE FOR SPECIAL, INCIDENTAL,
CONSEQUENTIAL,INDIRECT OR OTHER SIMILAR DAMAGES ARISING FROM ANY BREACH OF
THESE WARRANTIES EVEN IF QNE International OR ITS AGENT HAS BEEN ADVISED OF
THE POSSIBILITY OF SUCH DAMAGES. Some states do not allow the exclusion or
limitation of incidental or consequential damages, so the above limitation
or exclusion may not apply to you.
The warranties set forth above are in lieu of all other express end
implied warranties, whether oral, written, or implied, and the remedies set
forth above are your sole and exclusive remedy.
LIMITATION OF LIABILITY. In no case shall QNE International's liability
exceed the license fees paid for the right to use Q-PRO 4 TEST DRIVE or ten
Dollars ($10.00), whichever is greater.
INTEGRATION. This License constitutes the entire agreement and
understandIng between the parties and supersedes any prior agreement or
understanding whether oral or written, relating to the subject of this
License. This Agreement may only be modified by a written agreement signed
by QNE International.
License Agreement
2
LIMITED LICENSE TO COPY
=======================
You are granted a limited license to copy Q-PRO 4 Test Drive only for the
trial use of others subject to the software license described above, and
also the following:
Q-PRO 4 Test Drive must be copied in unmodified form, complete with the
following files:
QNE.EXE The Q-PRO 4 TEST DRIVE program
BW.EXE The Binary Workstation Editor
BWFID.EXE The Binary Workstation FID generator
QNE.DOC The Q-PRO 4 Documentation on disk.
The full and unmodified Q-PRO 4 Test Drive documentation must be included
with the copy.
No fee, charge or other compensation may be accepted or requested by anyone
without express written permission from QNE International.
Q-PRO 4 Test Drive may not be distributed in conjunction with any other
product or service without a specific license to do so from QNE
International.
Q-PRO 4 Test Drive may be distributed only in North America - DISTRIBUTION
OF Q-PRO 4 Test Drive OUTSIDE OF NORTH AMERICA IS STRICTLY FORBIDDEN.
Operators of electronic bulletin board systems (Sysops) may post Q-PRO 4
Test Drive for downloading by their users without written permission only
as long as the above conditions are met. A fee may be charged for access
to the BBS as long as no specific fee is charged for access to the Q-PRO 4
Test Drive files.
Distributors of public domain and user supported software, such as disk
vending services, may distribute copies of Q-PRO 4 Test Drive subject to
the above conditions only after obtaining written permission from QNE
International. Such permission usually is granted; please write for
details.
License Agreement
3
I N T R O D U C I N G Q-PRO 4 T E S T D R I V E
====================================================
Q-PRO 4 Test Drive is the "try before you buy" version of Q-PRO 4. QNE
International created it to allow you to "test drive" Q-PRO 4 before
committing your hard earned dollars. This has benefits for both the users
and the authors.
First of all, though, you must be aware that Q-PRO 4 and Q-PRO 4 Test Drive
ARE NOT free software, NOR are they in the PUBLIC DOMAIN. Both programs
are fully copyrighted works protected to the full extent of US and
international copyright law.
Why allow a program "test drive"? Q-PRO 4 Test Drive is based on a
marketing technique called "shareware" or "user-supported software", which
is a means for the computing community to receive quality software while
directly supporting authors. It is based on the idea that the value and
utility of software is often best assessed by the user on his or her own
system. Only after using a program can one really determine whether it
serves personal applications, needs and tastes.
The benefits to users are fairly obvious: you are allowed to thoroughly
evaluate the software before purchasing it. How many times have you
purchased an expensive piece of software only to find that it doesn't do
what you need?
Software authors benefit by creating a distribution channel of satisfied
users who
recommend and pass along their product. This"pyramid" effect can be a very
effective marketing technique, and is vastly less expensive than
traditional marketing techniques. This is not to say that "test drives"
and more traditional methods like magazine advertising are mutually
exclusive. They may be used together very effectively to target different
segments of the market.
What does this mean to you? While you are granted a limited license to
evaluate the program on a trial basis, regular use of the program requires
purchase. What is a "trial basis"? Kicking the program around over a
weekend to see how it works is certainly using it on a trial basis.
Installing and using the program in a production test environment for two
weeks is trial use. Using the software twice a week for regular work for
three months is not and therefore requires purchase. Using the program
regularly for any regular task, especially if it has replaced other
software, is not trial use. These examples are not intended as definitive
rules, but more as general guidelines.
You are not allowed to modify the software under any conditions. We do,
however, encourage you to create "add-on" support utilities and program to
enhance your and others' enjoyment of the program.
Introduction
4
You may copy the program for the trial use of others subject to the rule
outlined in the previous section "Limited License to Copy". In general,
you may only copy the program in complete and unmodified form, as we
distribute it.
You may not charge any fee for copies of the program without written
permission from QNE International. This applies especially to disk
vendors. Some services mislead customers into thinking they have
purchased the software, rather than just the disk and duplication service.
If you have purchased this product from a disk vendor and feel they were
misleading about what you have purchased, please write us and we will
investigate the matter.
You may not include Q-PRO 4 Test Drive with any other product, whether
hardware or software, without specific license. For example, you may not
include Q-PRO 4 Test Drive on the hard drives of computers you sell, or
include it with copies of software you have developed.
Purchasing Q-PRO 4
==================
After using Q-PRO 4 Test Drive for a while, you need to decide if you want
to continue using it on a regular basis. If not, please feel free to
continue copying it for the trial use of others, or to pass your copy along
to a friend.
Please note that there are two versions of the software, Q-PRO 4 and Q-PRO
4 Test Drive. The TEST DRIVE version may be copied and used for evaluation
as described above. The purchased version of Q-PRO 4, however, may only be
copied for backup purposes. After receiving your purchased copy of Q-PRO 4
you may continue to copy Q-PRO 4 Test Drive for friends; you may not copy
Q-PRO 4.
Why should you purchase Q-PRO 4? To pay for the software which you are
gainfully using, and to support its authors and encourage them to produce
more high quality software. And because regular use of Q-PRO 4 Test Drive
without purchase is a violation of the license
under which you use it.
Introduction
5
When you purchase Q-PRO 4 for $50.00, you will receive the following:
- Perpetual license for you to use the software you have purchased.
- A two disk program set including a serialized Q-PRO 4.
- A 300+ page professionally typeset and printed manual which includes a
tutorial and index.
- 30 days (up to 2 hours) telephone technical support.
When you purchase Q-PRO 4 Plus for $90.00, you will receive, in addition to
the above:
- Utilities to import/export Lotus files, to import dBASE II/III/IV data
files, to custom configure your Q-PRO 4 keyboard any way you want, and
to custom configure Binary WorkStation.
- The Q-PRO 4 non-procedural report generator.
- 60 days (up to 3 hours) of telephone technical support.
To order via credit card, call our business office at (800) 333-0448. Cash
and check purchasers should use the order form in the back of this manual.
Introduction
6
Q-PRO 4 O V E R V I E W
========================
Design Freedom
--------------
Q-PRO 4's design philosophy of Q-PRO 4 is different from almost any other
language or "database manager" that you have ever seen. Our approach makes
the language work for you, not vice versa.
Non Sequitur
------------
All of you have used and been used by BASIC, FORTRAN, or, more likely,
dBASE II or dBASE III (or IV - which is probably why you are reading these
words!). All are sequential languages.
In sequential languages, the program code is running continuously. If
there is to be interaction with the operator through the keyboard/CRT, the
programmer must handle this interaction in excruciating detail under
program control. These languages were either designed before the advent of
CRT's or the authors forgot that in a modern environment, the user of an
application is almost continuously communicating with the application
through the keyboard.
To overcome this design shortcoming, the programmer must write enormous
amounts of code to communicate with the user. More than likely, because of
the ever-present deadlines, the
screen becomes a repetitive question and answer session--a completely
unsatisfactory human interface.
Events Drive Us
---------------
How is Q-PRO 4 different? Q-PRO 4 is an "event" driven language not a
"sequential" language. An event driven language itself detects keystrokes
or the status of a screen input field as an event automatically. This
information is immediately available for program control. The programmer
then determines if and where in the program to transfer control. Now you
can concentrate on the application, not the management of the environment.
Q-PRO 4 senses events at several levels. The most fundamental is automatic
sensing of a keystroke which is numeric when it should have been alpha,
etc. At the next level, it may sense a screen field that must be filled
when it has not been. At the next level, at the programmers option, Q-PRO
4 branches to a segment of the program code.
It's Magic
----------
How is this magic done? The Q-PRO 4 entry screen is a set of
fill-in-the-blanks fields which, at the option of the programmer, may or
may not be enterable by the operator. Normally, the screen is set up as a
Overview
7
true fill-in-the-blanks type which closely resembles the form the user is
accustomed to. The programmer completes a short form on the screen which
defines the field. This definition sets the attributes of the field; such
as its name, length, alpha only, numeric only, justification, may enter,
must enter, etc.
If the operator types a numeric in an alpha only field, Q-PRO 4 detects it,
halts entry and displays an error message. The keyboard is disabled except
for the ESCAPE key. The bad character will not be displayed. Pressing the
ESCAPE key will turn control back to the operator. In this manner, Q-PRO 4
forces correct entry according to field definition without program
intervention.
The operator moves from entry field to entry field on the screen either by
filling up the field or by pressing the RETURN key. The RETURN key itself
may be detected as an event. If the field is properly entered, and a
program segment is specified for the field, the program segment, called a
procedure, will be executed.
Now the application is entirely under the control of the programmer. The
programmer may use any of the over 100 Q-PRO 4 commands to error check the
field, search for and display a record from a file or any other tricky
stuff that programmers are so fond of.
Programmable Function Keys
--------------------------
This same capability allows Q-PRO 4 to detect 21 function keys, the enter
key and other editing keys. The programmer can do whatever his heart
desires when one of these keys is pressed by the operator. For example,
F10 could terminate the application, F9 could display a help screen, etc.
Overview
8
Another benefit of this approach is that, by use of screen field names or
by symbolic notation, the screen fields may be examined for consistency.
And, calculations may be performed on the screen.
Modern Commands
---------------
All Q-PRO 4's commands are English-like and logically consistent in
structure. They always start with a verb, and are followed by an operand
and optionally by a modifier. Extended commands will have additional
operands and additional modifiers.
Databases Are Poor Relations
----------------------------
Many so-called databases are entirely relational. Q-PRO 4 applications may
be set up relationally, hierarchically, or any other strange way that suits
the programmer and the application. We do not presume to know how your
databases should be set up, but we do know that not all databases in an
application are related! For example, in a typical order entry
application, the product database is rarely related to the sales person
database.
They may or may not be related on a transaction. The point is, of course,
that you, the applications designer, are the only one who knows how the
various databases work together. Q-PRO 4's function is to give you the
freedom to do it your way quickly and with the least possible systems and
programming overhead.
Overview
9
Q - P R O 4 T U T O R I A L
=============================
Q-PRO 4 Fundamentals
--------------------
Q-PRO 4 has three segments, the screens, the File Items Descriptor (or FID)
and the program code. The Binary WorkStation editor is used to create the
entire application. Actually, Binary WorkStation has three editors: one
for program code, one for screens, and one for FIDs.
Program Code
------------
The program code is broken into segments called procedures or PROCs. The
program code editor of Binary WorkStation has the normal text editor
capabilities you would expect of any text editor. In addition, it has
special features specifically for Q-PRO 4 programming. Some of these
features include: a syntax checker, a macro code generator, and a file
items descriptor (FID) generator. Binary WorkStation is also a very good
editor for text files.
When Binary WorkStation is first loaded the program code editor is
executed.
Screens
--------
Screens are created in a what-you-see-is-what-you-get (WYSIWYG) mode with
the screen editor portion of Binary WorkStation.
You "paint" the background for the screen window. This is the labels or
operator prompts, colors and line graphics. The labels are created by
positioning the cursor where you want them and typing the text. The lines
are drawn by changing to the graphics mode. Then they are drawn with the
cursor left and right keys. The intersections are placed with the function
keys.
You define a data entry area or screen data field by pressing a function
key to display the screen data field of the screen editor. On this screen
you specify the characteristics of the field and its primary edits such as
width, type (alpha, numeric,etc.), may enter, must enter, may tab, must
tab, etc.
As you will see, creating a dramatic, attractive screen for the user is a
sheer delight.
Tutorial
10
Installing Q-PRO 4
==================
If you have not already done so, it is time to unpack and install Q-PRO 4.
Simply unarc the Q-PRO4.ARC file in the directory you are going to work in.
Binary WorkStation has extensive help screens. You can refer to them from
any subdirectory where you happen to be if you use the DOS variable BWHLP.
Use this format in autoexec.bat: set bwhlp=<d>:<sub> (where <d> = drive and
<sub> = subdirectory where Binary WorkStation is).
Check for READ.ME
-----------------
The latest information about Binary WorkStation is on the Binary
WorkStation diskette. It is a plain ASCII file. Please take a look at it.
Example Program
===============
About This Chapter
------------------
In this chapter, we will develop a small Q-PRO 4 application. Although
this application is simple, it is illustrative of the techniques used in
many applications. Additional material on technique is in the Hints, Tips
& Techniques chapter and in the sample programs.
Steps in Building a Q-PRO 4 Program
-----------------------------------
Step
1. Build the background
2. Define the data entry fields
3. Define the data files
4. Code the program
5. Run the program
Usually we will take the steps in order, but there will be variations for
clarity and flow.
Load Binary WorkStation
-----------------------
Change directory to the directory that Q-PRO 4 is on. Load Binary
WorkStation and tell it the program file you will be using by typing BW
CUST.QNE (Note the space between BW and CUST.QNE) and then press RETURN.
The options screen will display. Press RETURN. You will be in the program
Tutorial
11
code editor portion of Binary WorkStation. This is a blank screen that we
will use later to write the procedural program code portion of the program.
/------------------------------\
|STEP 1 - Build the Background |
\------------------------------/
Press F8 to invoke the screen editor and display the screen. A blank
screen will display. Visualize the screen as a clean page to draw your
form on.
About Backgrounds
-----------------
The background is our term for the constant material on the screen.
This material is variously referred to as "prompts", "labels",
"operator information", . . .
In Q-PRO 4, the background most often emulates the pre-printed portion
of a printed form.
Move the cursor on the screen using your system cursor control keys and
type the text until your screen looks like the one following. Remember,
with Binary WorkStation, you have insert character and line, delete
character and line, etc. The composition of the screen is "free-form" so
feel free to arrange it for the best effect on your screen. Leave some
room in the bottom third of the screen for additions to be made later.
You should generally follow this layout:
/-------------------------------------------------------------------------\
| |
| |
| ENTER NEW CUSTOMERS |
| |
| |
| Name: |
| |
| Street and Number: |
| |
| City: State: ZIP: |
| |
| |
| |
| |
| |
| |
| |
| ESC - To Exit to System |
| |
Tutorial
12
| |
\-------------------------------------------------------------------------/
Graphics and Highlighting
=========================
You can enhance the readability and make a more dramatic presentation on
the screen by using line graphics and highlighting. Highlighting and
business graphics depend on the computer or terminal you are using. Not
all support these features.
Business Graphics
-----------------
To put business graphics on the window:
1. Press FUNCT 0 (Funct 10 on the IBM-PC) to put Binary WorkStation
in the graphics mode.
2. Use the cursor controls to draw horizontal and vertical lines and
the function keys to print the corners and intersections. See
the Binary WorkStation section for more details.
Highlighting
------------
Highlighting takes one character position on the screen. You must make
allowance for this when you use highlighting. To highlight:
1. Place the cursor to the left of the background field that you
want to highlight and press F3, the highlight on key.
2. Move the cursor to the right of the field to be highlighted.
Press the highlight off key, F4.
The text between the highlight on character and the highlight off character
will be highlighted. On some machines, such as the IBM-PC, the machine
will not know that the highlight exists until you go back to the menu by
pressing ESCAPE and then re-display the screen by pressing menu F8.
/------------------------------\
|STEP 2 - Define Fields |
\------------------------------/
Q-PRO 4 Data Entry Fields
-------------------------
One of Q-PRO 4's strongest features is its use of data entry fields.
Overall, they emulate the blanks to be filled in on a preprinted form.
Tutorial
13
To Enter or Not
---------------
As you will see, defining them is simplicity itself; there is no coding and
the fields are easily moveable. Screen data fields may or may not be
enterable by the operator. Or, they may be created enterable and then made
nonenterable!
Primary Edits
-------------
At the time the fields are defined, primary edits are also defined:
alpha/numeric only, may enter, must enter, must fill, etc. Again, there is
no program code and the primary edits may be changed at any time.
Field Definition
----------------
Move the cursor to the right of the colon(:) following CUSTOMER NUMBER.
Press F1. The form below will be displayed. As you see, it is arranged in
columns. You define the field by describing it in each column. Here is
how you do it:
Column Your Entry Meaning
------ ---------- -------------------------------------------------
Field name NAME From now on, Q-PRO 4 will use the identifier NAME
to refer to the contents of this screen data
field. In other words, NAME is now a variable in
your program. See the Naming Conventions Section
in the Q-PRO 4 Reference Manual for a full explan-
ation of naming conventions. Press the TAB key.
Len. 30 This specifies that up to thirty characters will
be allowed in the NAME screen data field. As we
progress, you will see how the screen data field
definition will narrow the operator's choices.
Press the TAB key twice to skip to Type.
Row <tab> This is the row coordinate. It is already filled
in for you. Pressing tab skips over it.
Col <tab> The column coordinate is filled in for you.
Type <tab> The Type descriptor is a two character field. The
first character forces the operator to put in the
correct type of data. As we will allow anything
here just press TAB. Refer to the Quick Reference
Card for the meaning of all the field descriptor
codes. The second character may be blank, equal
sign (=) for autoduplication, or question mark (?)
for an invisible field
Tutorial
14
Just L This field specifies the justification. The L
will cause data entered in the screen data field
to be left justified.
Fill Char <tab> Frequently numeric fields are right justified and
use a zero (0) as a leading character. You may
specify any leading character. Do not use a
number sign (#) until you read about it in the
Programmer's Reference Manual.
May Ent. Y Since we are going to allow entry, put a "Y" here.
Must Ent. Y We want to force the user to put something here.
Must Fill N The user does not have to completely fill the
field.
Must Tab N We are not going to require the user to press tab
to leave the field.
Procedure
Name <tab> At the moment we are not going to write a
procedure for this field.
* * * You are now finished defining the field NAME * * *
Press ENTER to return to the background screen. The previously typed
screen is displayed again. The NAME screen data entry field looks like
this:
NAME : ################
The number signs (###) indicate the presence of a defined screen data field
and its length. We will refer to these defined fields as screen data
fields.
Use the same procedure for all the other fields on the screen using the
field specifications below.
Screen Field Fill May Must Must Must Proceed
Label Name Len Row Col Type Just Char. Ent Ent Fill Tab Name
------ |----------------------------------------------------------------
NAME | NAME 30 L Y N N N
STREET | STREET 30 L N N N N
Tutorial
15
CITY | CITY 20 L N N N N
STATE | STATE 2 A L Y N Y N
ZIP | ZIP 5 D L Y Y Y Y
Note: when a field format definition for every field has been entered,
this segment of the program is complete. Press F8 to return to the coding
section.
Press Control and U at the same time. This dialog screen will display:
/-------------------------------------------------------------------\
| |
| Save this file? [Y] Save in Q-PRO 4 format? [Y] |
| |
| File name [CUST.QNE ] |
\-------------------------------------------------------------------/
* * * MAKE SURE THAT the first two questions are answered - Y. ****
Press enter.
/---------------------------------\
| STEP 2a - Run the Screen Program |
\---------------------------------/
1. Press ENTER. Press F8. You will be moved to the program code editor.
2. Hold the CTRL key down and press U. Press ENTER when the dialog
screen displays.
3. Hold the CTRL key down and press Q. When the dialog screen is
displayed, press RETURN to run your program. It will be loaded by the
runtime interpreter (QNE.EXE), and execution will begin. The data
entry screen that you have built will be displayed ready for data
entry.
Entering Data
-------------
Begin typing data using the CURSOR RIGHT key or the ENTER key to go forward
from data entry field to data entry field. Use the SHIFT TAB key or the
CURSOR LEFT key to go backwards from field to field. If the data you key
does not agree with the field specification, then an error message will be
displayed. To resume keying, press ESC.
Changing Data
-------------
To change the data in a field, press the ENTER key to go forward or the
Shift TAB key to go backward until you get to the correct field. Either
Tutorial
16
type over the previous data, or use the CLEAR TO END OF LINE (CONTROL END)
key to erase the rest of the data in that field. You may also use the
INSERT/DELETE character keys. Then type the correct data.
Once you have entered all the data for a customer, press END. The screen
will clear for additional entries.
When you have finished, press ESC to return to Binary WorkStation.
*** NOTE: no data that has been typed on the screen will actually be
written on a data file because the data files and data file
handling have not yet been programmed.
/-----------------------------------\
| STEP 3 - Define the Data Files |
\-----------------------------------/
FID Generator
-------------
The data in a data file is arranged into fields which have names. The File
Item Description Generator, is used to create the file, called a FID file,
which contains the names of the fields in the data file. The FID file is
also used for creating and opening data files. FID is a menu selection
from Binary WorkStation.
Select the FID generator by holding down the CNTL key and pressing V. At
the bottom of the screen, this line will display:
FID Name or Number [ ]
In the blank provided for FID Name or Number, type CUST.FID. The FID
definition screen will display.
Current File [CUST.FID ]
Item name Len. Type Description Reps
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
.
.
.
.
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ]
Tutorial
17
[ ] [ ] [ ] [ ] [ ]
Creating the FID File
---------------------
We will create a FID file using Quic FID. This feature lets you create the
FID to match the screen with no tedious typing. We are assuming that the
name of the application file you used in the previous sections was
CUST.QNE.
Follow these steps:
-------------------
1. Hold down the shift key and press F2.
2 Enter the name of our format file: (CUST.QNE)
3. Press F4 (Update FID file) to save the FID file on disk.
4. Press SHIFT F10 (Go to Binary WorkStation program code editor).
Indexed or Random
-----------------
The FID determines what type of file will be created when it is used by
Q-PRO 4 to create a file. If the FID is defined with a key (or keys), the
data file will be indexed. If no keys, the data file will be random.
Keys in Indexed Data Files
--------------------------
The key is another term for the sequence of the indexed data file. In the
customer file, the name of the customer is the key. When you enter
customers, no matter what sequence that you enter them, the logical order
will be alphabetic by customer. For a more detailed discussion, see the
section on FIDS in the FID Generator section of the Binary WorkStation
Reference Chapter.
/-----------------------------\
| STEP 4 - Coding the Program |
\-----------------------------/
Language Structure
==================
Event Driving
-------------
In a previous section we pointed out that Q-PRO 4 is event driven. An
event may be the operator pressing TAB to leave a screen data field or
pressing a function key. The application designer decides if this event
will cause transfer to the command section of the program file. The
command section consists of procedures.
Tutorial
18
Procedures
----------
The procedure, or PROC, is a series of Q-PRO 4 commands. It may be
specific to a screen data field or function key or more global like a
subroutine. When control is transferred to it, the procedure executes its
commands and, at the application designer's option, returns control to the
screen. Thus, the application designer always has control. Procedures
have names to identify them.
Linkage
-------
The PROCs are linked to the screen data field by the entry on the screen
data field definition line for Proc Name (field procedure name), wherein a
PROC name is entered. When the operator has gotten over the primary
hurdles, MUST ENTER, MUST FILL, etc. and presses TAB, the PROC named in
Proc Name will be executed. This is how Q-PRO 4 knows what procedure to
execute for this event or the linkage from the keyboard/screen to the
commands.
Using the Editor
----------------
Overview
--------
Binary WorkStation is a complete text editor. Like most text editors, it
has full facilities for entering, deleting, modifying and moving text.
In general, all you need do is type in the code. The following is a
thumbnail description of the key facilities of Binary WorkStation:
Modes
-----
There are two overall modes, INSERT ON and INSERT OFF. When insert is ON,
each keystroke will add a character or insert one where the cursor is.
When insert is OFF if there is a character where the cursor is, it will be
struck over.
Line Wrap
---------
As opposed to word processing editors, there is no line wrap. You can keep
typing to the allowable width of the line, 256 characters. Use the ENTER
key to terminate the line. For a more complete explanation refer to the
Binary WorkStation section in this manual.
Bottom Line Menu
----------------
Binary Workstation uses a bottom line menu. That is the bottom line of the
screen lists the functions that will be executed when the respective
Tutorial
19
function key is pressed. A new set of functions is displayed when F10 is
pressed and the previous set is displayed when F9 is pressed. Any function
may be executed, regardless of what is displayed, by pressing its
associated key. For example CNTL Q runs the program.
PROC LOAD
---------
PROC LOAD is the procedure that is always executed first. It is used to
initialize conditions for the program, open files, etc.
Coding PROC LOAD
----------------
In this example, PROC LOAD will open the data file. If it cannot open the
data file then it will assume that the data file is not there and create
it. In later sections we will make PROC LOAD a little smarter.
Type the lines show below which are boldfaced.
PROC LOAD
Procedure executed at the time the program loads.
OPEN "CUST.DAT" USING "CUST.FID" , 1:NO_FILE
Open a file named CUST.DAT. Use the data dictionary or FID,
CUST.FID. From now on we will refer to this file by the number
1. If successful, execute the next sequential command. On
error(i.e. could not open the file, possibly because it has not
been created yet.) go to NO_FILE. You may specify drives and/or
paths in the file name, e.g. "/Q-PRO 4/CUST.DAT".
END
The data file was opened successfully. The END statement gives
control to the operator in the first enterable field.
:NO _FILE MAKE "CUST.DAT" USING "CUST.FID",1:BAD
Create CUST.DAT. Structure it in accordance with the
specifications in the data dictionary CUST.FID. Assign it file
number 1. When created, go to the next sequential statement. If
it cannot be created, GOTO BAD and report the problem.
END
On successful MAKE, turn over control to the operator.
:BAD ERROR "UNABLE TO CREATE FILE"
The ERROR command displays the message in quotes on line 24 of
Tutorial
20
the screen. When the operator presses any key, control goes to
the next sequential statement.
SYSTEM
Although this statement will normally return you to the operating
system, when you run the program from Binary WorkStation, your
program will be reloaded ready for editing.
END
End of procedure. Turn over control to the operator.
Your proc should look like this:
PROC LOAD
FORMLOAD
OPEN "CUST.DAT" USING "CUST.FID",1:NO
END
:NO MAKE "CUST.DAT" USING "CUST.FID",1:BAD
END
:BAD ERROR "UNABLE TO CREATE FILE"
SYSTEM
END
Labels
------
Labels, in Q-PRO 4, are simply places to jump to on various conditions.
They may be numeric or alphanumeric. If they are alphanumeric, they follow
the standard naming conventions discussed in the reference section.
Alphanumeric labels must have a colon (:) as the first character.
PROC NAMEP
----------
Function of the PROC
--------------------
When the user entirely fills the NAME field or presses TAB this PROC will
execute. It searches the database established in PROC LOAD and displays a
customer record if there is a record on the file that exactly matches the
name that is entered in the NAME FIELD.
Type only those lines which are boldfaced in the following procedure.
PROC NAMEP
Defines the PROCedure NAMEP.
POSN 1 TO NAME
This statement positions the datafile to the contents of the
Tutorial
21
screen data field, NAME.
READ 1:NO_MATCH
Read the record. If there is an exact match between the file
data field and the screen data field, load the file buffer with
the record and execute the next command. If there is not an
exact match, go to NO_MATCH.
For the purposes of retrieving a record from a file, an Exact
match is understood to be a match, character by character, for
both fields.
COPY 1 TO *
Copy all fields on the data file that have the same name as
fields on the screen to the screen. The 1 is the file number and
the asterisk (*) is used to represent the screen. This is one of
the ways a data dictionary can work for you. By simply selecting
matching, or non-matching names, you can easily control what data
is copied from what to what. Of course, you can specify the
movement a field at a time if you wish.
NEXT
Gives the operator control in the next enterable field, STREET.
NOTE: Other Q-PRO 4 statements that give control back to the
operator are END, and RESUME.
:NO_MATCH END
If there is no matching record on the database terminate the
PROC. This gives control to the user in the next enterable
field, STREET.
Your PROC should look like this:
PROC NAMEP
POSN 1 TO NAME
READ 1:NO_MATCH
COPY 1 TO *
NEXT
:NO_MATCH
END
Event Driving
-------------
The event which sets off looking for a particular name on file, i.e.
executing PROC NAME, is the operator leaving the screen data field, NAME.
Normally the operator presses the TAB key.
Tutorial
22
The Linkage
-----------
We need to establish the linkage between the event, i.e. tabbing out of
screen data field NAME and executing PROC NAME. The linkage is established
as part of the field definition of the screen data field, NAME. We will
set this up now.
Adding the Linkage
------------------
From the program code editor, press SHIFT F8 to load the screens editor.
The screen format that you've been working on will display. Place the
cursor on the #####'s after Name and press F1. The Field Definition Screen
will display.
Move the cursor to the right of the field NAME:. Place it on the number
signs (###), and press F1. The FIELD FORMAT DEFINITION for the screen data
field NAME will be displayed.
Tab to the right under Proc Name. Type NAMEP. This is the linkage to the
interpreter. When the operator presses TAB in the screen data field NAME,
Q-PRO 4 sees NAMEP as the screen field procedure name and it looks for a
procedure in the program code named NAMEP to execute some instructions. If
there is no procedure named NAMEP, an error will be reported. You can't
fool Q-PRO 4!
Press ESC twice to return to the program code editor.
Recording Data
--------------
PROC ENTER
----------
This proc is executed when the designated ENTER key is pressed. Most
often, it is used when the data on screen is complete and the user wishes
to record it.
PROC ENTER
This is the procedure invoked when the ENTER key is pressed.
COPY * TO 1
Copy all the screen data fields to the file data fields of the same
name.
WRITE 1 NOADV : BAD_WRITE
Write the record, goto BAD_WRITE on error. The NOADV keeps the file
from advancing to the next record which saves time. It is important
to note here what gets written when this command is executed. In the
current example, the contents of the screen will be recorded on disk.
Tutorial
23
Because the key to the file is NAME, if you have entered a new name
then a new record will be created. If it is a name that is already on
file, then that record will be updated to match the screen.
END
The screen will clear. (This is automatic when the ENTER command
reaches the END statement.) Control is turned over to the operator in
the CUSTNO field.
:BAD_WRITE ERROR "ERROR IN WRITING RECORD"
Display the error message "ERROR IN WRITING RECORD" on line 24. Turn
over control to the operator until the ESC key is pressed. When ESC
is pressed, the next command will execute.
SYSTEM
Return to the operating system.
END
Here, the END is not really needed, but putting it in is good
procedure.
Your PROC should look like this:
PROC ENTER
COPY * TO 1
WRITE 1:BAD_WRITE
END
:BAD_WRITE ERROR "ERROR IN WRITING RECORD"
SYSTEM
END
Running the Program
-------------------
Press CNTL U to update the program. When the dialog screen displays, press
ENTER. Press CNTL Q. When the dialog screen displays, press ENTER.
Entering Data
-------------
Enter a name in the Customer field. If the customer is already on the
database, it will be retrieved from the file and displayed. You can enter
it as is or correct it and enter it.
ESC will return you to Binary WorkStation procedural code editor.
Finding and Fixing Bugs
-----------------------
Returning to Binary Workstation
Tutorial
24
-------------------------------
Press ESC, which will bring you back to Binary WorkStation's program code
editor.
Correcting Screen data fields
----------------------------
To change a screen data field, redisplay the field and change it by placing
the cursor anywhere on the number signs and press F1. The field definition
screen will be displayed with the previous entries.
You may change any of them by moving the cursor with the TAB key and making
the change. Press ENTER to return to the data entry screen.
Syntax Checker
--------------
With the Binary WorkStation loaded, press CNTL W. Your program will be
checked for correct syntax.
If any errors are found, the syntax checker will stop at the first one.
Use the editing keys INSERT CHARACTER, DELETE CHARACTER, INSERT LINE, and
DELETE LINE, etc to correct the error.
Press CNTL W again. Continue to syntax check and correct until no more
syntax errors are detected.
Line Numbers
------------
Binary WorkStation does not use line numbers to organize itself. The line
numbers are normally not even displayed. They are used as an aid to
debugging. When an error is reported by the interpreter, it will refer to
a line number. You can display the line numbers with Binary Workstation to
find the offending line of code.
Labels
------
Numeric and alphanumeric labels are merely labels to jump to. However,
remember that a label can be jumped to even if it is not within the
procedure that references it.
Adding Programmable Function Keys
--------------------------------
General Description
-------------------
Q-PRO 4 recognizes 21 programmable function keys, 0 to 20. Each key is
associated with a specific PROC, PROC KEY0-20. The PROC associated with
the key executes immediately. For example, on the IBM PC, pressing
function key, F1 executes the proc KEY1; PROC KEY11 is invoked with Shift
Tutorial
25
F1.
Functionality
-------------
The proc can do anything you wish it to do. Some of the more common uses
are: advancing and backspacing a single record in a file, deleting
records, special searches, and chaining to other screens.
Pre-defined Function Key
------------------------
PROC KEY0 is pre-defined with the following code:
CLOSE
SYSTEM
END
It is invoked with the ESC key. You need not define it if closing the
files and going to the operating system are what you want it to do.
Otherwise program this key as any other.
Examples
--------
We suggest that you add the examples below to your program to enhance its
functionality.
First let's write a simple subroutine that will save us some time later.
This subroutine reads and displays a record.
PROC KEY_READ
READ 1:EF
Advance the file pointer one record. If there is an error,
presumably an End of File, goto EF.
COPY 1 TO *
Copy the fields with the same names in the data file as on the
screen to the screen.
RETURN
Return to the main program at the next instruction after the
calling statement.
:EF ERROR "No more records"
RETURN
Example: Display Next Record
PROC KEY1
Tutorial
26
CALL KEY_READ
END
This example takes advantage of the characteristics of an indexed
file. The READ command will advance the file one logical record in
the logical sequence or key.
Example: Display Previous Record
PROC KEY2
BACKSPACE 1:EF
BACKSPACE 1:EF
When a record is read, the record pointer is pointing to the next
record. Therefore to backspace preparing to read the previous
record, you must backspace twice. We have used the end of file
routine from PROC KEY1 which it won't mind.
CALL KEY_READ
END
Example: Delete the Currently Displayed Record
PROC KEY11
POSN 1 TO NAME USING 1
Position the file to the contents of NAME in the primary key. We
want to insure that in all circumstances the record to be deleted
actually exists.
CALL KEY_READ
If the record does not exist, then the READ statement in KEY_READ
will cause the file to go to end of file.
FREE 1
The record currently in the buffer, i.e. the one just read, will
be marked deleted. This logically removes the record from the
database.
END
Partial Key Searching
---------------------
Capabilities
------------
One of the more powerful features of Q-PRO 4 is partial key searching.
This feature allows you to get the "nearest" match for a key search.
Now you can look up a customer name if you only know the first letter of
the name. For those of us who have occasional memory lapses, this is the
Tutorial
27
greatest. If you can't remember without seeing the whole record whether it
is Smith, Smithson, or Smyth.
As an example, in our customer program, with partial key searching you just
type "Sm" and press a function key. The record for Smith will be
displayed. Using the next and previous function keys lets you browse the
data.
Example: Partial Key Searching
PROC KEY3
POSN 1 TO NAME RELATIVE
The RELATIVE modifier tells Q-PRO 4 to search for an exact match
for the contents of the screen data field, NAME, or the nearest
next higher match. Therefore an entry of Sm will bring up the
first of the series.
CALL KEY_READ
END
Example: Position to Beginning of File
PROC KEY7
POSN 1 TO "" RELATIVE
Positioning the file to a null (double quotes, single or double,
with no space between them) RELATIVE positions it to the first
record of the file.
Tutorial
28
Hints, Tips & Techniques
=========================
Inherent Structure
------------------
Because Q-PRO 4's PROC's are inherently structured, there is not much to do
to organize your programs. However, you might find it helpful to group
various type of procs such as function key procs, subroutines, etc.
together with an appropriate section heading. If you use an asterisk to
preface the heading, Q-PRO 4 will think it is a comment. An example of
this technique:
* * * * * * * * Field Procedures * * * * * * * * * * *
PROC NAMEP
POSN 1 TO NAME
READ 1:NO_MATCH
COPY 1 TO *
NEXT
:NO_MATCH END
* * * * * * * * Function Key Procedures * * * * * * * * *
PROC KEY1
CALL KEY_READ
END
PROC KEY2
BACKSPACE 1:EF
BACKSPACE 1:EF
CALL KEY_READ
END
PROC KEY11
POSN 1 TO NAME USING 1
CALL KEY_READ
FREE 1
END
Sample Programs
---------------
Using the Sample Programs
-------------------------
The sample programs comprise a demonstration invoicing system including the
programs and some sample data. The programs are designed to demonstrate
Tutorial
29
some overall technique of programming with Q-PRO 4. As demonstrations,
they are not necessarily the best code for they were developed to
demonstrate certain functions. We recommend that you run them and look at
the code.
You may create your own data or use the sample data provided. SAMPINS.DAT
and SAMPINS.FID must be on the same directory as the program files. All
other data and the FID files may be on any directory as long as all reside
in the same directory.
SAMPINS.QNE You must run this program first. It sets up the application
control file. In this program you use a one record random
file to specify the system parameters such as:
o Password (and its encryption)
o Company name and address
o Operating system
o Host
o Path for data files and FID files
If the HOST and the operating system are not set correctly, then
things will not work right.
SAMPMAKE.QNE This program is chained to from SAMPINS.QNE. Use it to
create new data files. If you create data files, the sample
files furnished will be deleted. It illustrates:
o Safely creating data files
o Operator-program dialog
o Use of application control file parameters
SAMPMENU.QNE This is the main menu for the program. It illustrates:
o How to use the application control file for determining
the HOST, operating system and where the data and FID files
are.
o How to get and use a password from the user.
o How to determine if the password has already been given so
it will not be asked for again.
o Chaining to other programs.
SAMPCUST.QNE This program maintains the customer database. From it you
can add a new customer, change a customer or delete a
customer. It illustrates:
o Determining if a file is already open before attempting to
open it.
o Scrolling forward and backward in a data file by either of
two keys.
Tutorial
30
o Duplicating repetitive data without rekeying.
SAMPROD.QNE This program maintains the product data base. Use it to
add, delete or change products. It illustrates:
o Determining if a file is already open before attempting to
open it.
o Scrolling forward and backward in a data file by either of
two keys.
SAMPEN.QNE This program is the first of two programs that write an
invoice. It is used to put in the bill head information.
It illustrates:
o Use of the application control file to assign invoice
numbers.
o Use of PROC BREAK.
o Using multiple screens to enter data to one file.
SAMPEN1.QNE This is the second program for writing an invoice. It
creates the line items of the invoice. It illustrates:
o Screen scrolling
o Printing from Q-PRO 4 (as opposed to the report generator)
o Multiple records for a screen
Advanced Input Editing
----------------------
Capabilities
------------
The only limit on the ways you can edit data as it is input is your
imagination. Some of the more common methods are:
o Range checks
o Table lookup
o Comparison to other fields
o File lookup
Screen Data Field Edit Example:
Range check of the screen data field, ZIP.
PROC RANGE
IF ZIP GE 10000 AND ZIP LE 90000 END
End the procedure if the Zip code is in the range 10000 to
90000. (GE = greater than or equal to, LE = less than or equal
to.)
ERROR "ZIP outside Range."
Put a message on line 24 for the operator.
Tutorial
31
CLEAR $FIELD[#F]
Clear the current screen data field. The function,
$FIELD[<expression>], refers to the screen data field whose
offset is calculated in the <expression>. A screen data field's
offset is the number of fields from the first screen data field
(whose offset is zero) counting from left to right, top to
bottom. One of the valid arguments in the expression is #F, the
current screen data field offset.
RESUME
Give control back to the operator in the current field.
Screen Data Field Edit Example:
Table look up of the verification of the screen data field, State
PROC TABLE_LOOK
TSEAR OK_STATES AT STATE:NO_ST
Search the table OK_STATES using the contents of the field,
STATE. If there is a match, goto the next command. If there is
no match, goto NO_ST.
END
Found a match, end proc.
:NO_ST ERROR "Don't use this state. "
Display instructions on line 24 of the CRT.
RESUME
TABLE OK_STATES
"PA"
"CA"
"DE"
END
This table specifies only these three states.
Screen Data Field Edit Example:
Comparisons between fields.
PROC COMPARE
IF STATE = "PA" AND ZIP LT 50000 GOTO ST_ERR
If the contents of the screen data field, STATE, is "PA" and the
contents of the screen data field, ZIP, is less than 50000, goto
the label ST_ERR
Screen Data Field Edit Example:
File verification of the field, ZIP.
PROC FILE_CHK
Tutorial
32
POSN 1 TO ZIP USING 2
Change the file key of file 1 to the second key, ZIP. (You will
see how to change file structures to put in additional keys in a
later section.) Position file 1 to the contents of the screen
data field, ZIP.
READ 1:NO_ZIP
Read file 1. If there is an exact match, execute the next
sequential command. If there is no exact match, goto NO_ZIP.
KEY 1 USING 1
Set the key back to the primary key.
END
:NO_ZIP ERROR "This ZIP CODE is not authorized"
CLEAR $FIELD[#F]
KEY 1 USING 1
RESUME
Screen Handling
---------------
Screen Graphics
---------------
For certain systems (as noted in the quick reference card paste-ins), block
or business graphics are available for enhancing the screen presentation.
Scrolling the Binary WorkStation menu in the screen editor mode allows
turning graphics mode on. While in the graphics mode the function keys
function as shown below:
CURSOR LEFT, RIGHT HORIZONTAL SEGMENT
CURSOR UP, DOWN VERTICAL SEGMENT
FUNCT 9 T RIGHT
FUNCT 8 T LEFT
FUNCT 7 T DOWN
FUNCT 6 T UP
FUNCT 5 CENTER CROSS
FUNCT 4 LOWER RIGHT CORNER
FUNCT 3 LOWER LEFT CORNER
FUNCT 2 UPPER RIGHT CORNER
FUNCT 1 UPPER LEFT CORNER
FUNCT 10 TOGGLE GRAPHICS MODE ON/OFF
Screen Data Fields - Editing Rows and Columns
---------------------------------------------
Row/Column coordinates are usually skipped after entering the FIELD NAME.
Tutorial
33
When you skip these fields, Binary WorkStation calculates the coordinates
for you.
The coordinates may be "forced" by entering the actual coordinates. This
is useful for moving a variable field to another place on the screen to
quickly customize a display.
Correcting Screen Data Fields
-----------------------------
To change a screen data field, redisplay the field and change it by placing
the cursor anywhere on the number signs and press F1. The field definition
screen will be displayed with the previous entries.
You may change any of them by moving the cursor with the TAB key and making
the change. Press ENTER to return to the data entry screen.
Screen Offset
-------------
The screen offset allows the programmer to address the screen data fields
as offsets from the first screen data field. Thus, the programmer may
symbolically select fields on the screen according to the program logic or
table look-up.
The offset value for each screen data field is shown on the program
listing. It is no more than the number of fields from the first screen
data field counting from left to right, top to bottom. With this logic,
the first screen data field at the upper left has an offset of 0. The one
next to it on the same line has an offset of 1, etc.
The field is addressed by the function $FIELD. $FIELD allows handling of
fields on the screen by offset value without worrying about the name of the
field. The combination of loops, registers and tables provides
extraordinary screen handling capability.
Example:
MOVE $FIELD[6] TO $FIELD[7]
This moves the sixth field on the screen (counting from the top left
field on the screen and going from left to right, top to bottom,
starting with field zero) to the seventh field.
Example: scrolling upwards on the screen.
Using the following screen format:
Field 0 ########### Field 1 ###########
Field 2 ########### Field 3 ###########
FOR #N0 = 0 TO 1
Tutorial
34
Begins a FOR loop from 0 to 1
MOVE $FIELD[#N0+2] TO $FIELD[#N0]
Moves FIELD 2 (#N0 plus 2) to FIELD 0. Then moves FIELD 3 to
FIELD 1.
ENDFOR #N0
END
Note that in the contents of the brackets following the $FIELD
will be evaluated as an expression. This expression must
evaluate to an integer. The following (assuming that the
contents of the numeric register are integers) are all valid:
$FIELD[(#N1 * #N2) + 10]
$FIELD[#N1 + #N2 - 20]
$FIELD[$OFFSET(SCNFIELD) + 5]
#F - The Screen Field Offset Register
-------------------------------------
The register #F always contains the offset of the current screen data
field. It uses are numerous. For example, to call a help screen for a
particular screen field, you can use this instruction:
IF #F EQ 8 HELP "FIELD"
#F provides powerful screen handling when combined with $FIELD. For
example, to clear the current field and the next three fields, use
this code:
FOR #N1 = 0 TO 2
CLEAR $FIELD[#F + #N1]
ENDFOR #N1
Screen Data Fields Using the Same Procedure
-------------------------------------------
Many screen data fields may use a common procedure. As an example of the
use of this technique, suppose you want to add a column of three fields and
want the correct total always to be displayed on the fourth line even if
the user backtabs and changes the number. The obvious is to go through a
long series of steps to subtract out the previous number, maintain the
values in an array or something else very tedious.
The four fields are:
ADD1 ##########
ADD2 ##########
ADD3 ##########
RESULT ##########
Tutorial
35
Make RESULT non-enterable and use this PROC for the fields ADD1, ADD2, and
ADD3:
PROC ADDP
CLEAR RESULT
MOVE $OFFSET(ADD1) TO #N2
* The function $OFFSET gives the offset of the field ADD1.
FOR #N1 = 0 TO 2
ADD $FIELD[#N2 + #N1] TO RESULT
ENDFOR #N1
With this routine, it makes no difference which field or in which
order the data is entered, the result will be correct.
Structured Programming
----------------------
Structured Constructs
---------------------
Q-PRO 4 has an excellent set of structured constructs. This set is
initiated with the command, BEGIN. BEGIN is modified by IF, WHILE, or
UNTIL followed by a condition. The BEGIN construct will be entered under
these conditions:
BEGIN IF <condition>
Enter and execute all commands between the BEGIN and ENDBEGIN if the
<condition> is true. If the <condition> is not true, skip over the
construct. (See also ELSE and ELSE IF.)
BEGIN WHILE<condition>
Enter the construct and repeatedly execute the commands within it as
long as the <condition> is true.
BEGIN UNTIL<condition>
Enter the construct and repeatedly execute the commands within it
until the <condition> becomes true.7
The BEGIN construct is terminated by ENDBEGIN. Between the BEGIN and the
ENDBEGIN are the commands to be executed if the BEGIN construct is entered.
Examples:
BEGIN IF A > B
CALL SUB1
CALL SUB2
ENDBEGIN
Tutorial
36
BEGIN WHILE A < 10
CALL TEST_SUB
ADD 1 TO A
ENDBEGIN
The subroutine TEST_SUB will be repeatedly called until the
variable A reaches the value of 10
MOVE 0 TO A
BEGIN UNTIL A=10
CALL TEST_SUB
ADD 1 TO A
ENDBEGIN
The subroutine TEST_SUB will repeatedly be called until the variable A
reaches the value of 10.
The BEGIN IF construct may also include ELSE and/or ELSE IF prior to the
ENDBEGIN.
Example:
BEGIN IF A=B
CALL SUBA
ELSE IF A=C
CALL SUBB
ELSE
CALL SUBC
ENDBEGIN
If A=B, call subroutine A, if A=C call subroutine B; if it equals
neither, call subroutine C.
Debugging
---------
Q-PRO 4 has a wealth of debugging tools that range from simply reloading
the program and BW on an error to a full runtime debugger.
ERROR Command
-------------
An ERROR command in the program code will halt execution and display the
specified error message on line 24 of the CRT. When the program encounters
the ERROR command, it will stop, display the specified error message and
wait for operator action. For debugging, a message with the ERROR command
can be used to identify locations in the code, etc. Messages can be
literals in quotes, a register, or a variable.
DEBUG Command
-------------
The DEBUG command loads the runtime debugger. It has a host of
capabilities that include looking at any field, changing memory, changing
Tutorial
37
the value of variables, and looking at the values of file fields. For more
detail on the use of DEBUG, refer to the Commands section.
TRACE Command
-------------
The TRACE command will put the program in single step mode. When TRACE is
encountered, the program will execute one command at a time, displaying the
command to be executed on line 24. Pressing the ESCAPE key will execute
the displayed command. This will continue until the command NOTRACE is
encountered or RETURN is pressed.
If the "D" key is pressed during TRACE, the online debugger will be loaded
after the command is executed.
All About Registers
-------------------
General
-------
Registers are temporary working areas maintained by the system which
resemble fields except that they are not displayed on the screen. The
contents of all data registers remain intact when you CHAIN to another
application file.
There are three types of data registers. Each type has ten usable
registers. Registers are cleared when Q-PRO 4 is first loaded. The
current value of the register remains when one program CHAINs to another.
String Registers
----------------
String registers are used as temporary storage for data. For example, they
can be used to build an output record for the printer or intermediate
storage for input data prior to moving it to a field or output buffer.
They may be used as variables in any command in lieu of a field or literal.
Also, string registers are used to transfer variables between program
chains.
Length 255 Characters
Names #S0 to #S9. (the lower case "s" can be used)
Clearing MOVE "" or '' to the register
Example: MOVE "" TO #S0
or MOVE '' TO #S0
Rules for the Use of String Registers
-------------------------------------
1. Data can be concatenated onto an existing string in a register or it
Tutorial
38
can be moved on top of existing data, but data cannot be moved to an
arbitrary position within a register that has been cleared. To move data
into the register at random, first fill it with blanks.
2. A string register may not be moved into a numeric register unless the
string register contains valid numeric data.
Note: A MOVE command with the destination being a data register
clears the register of any data previously contained and
puts the new data in the register.
Numeric Registers
-----------------
Numeric registers are used the same as string registers, but limited to
numeric data.
Length 20 Digits
Name #N0 to #N9
Clearing Move a zero (0) into the register
Rules for the Use of Numeric Registers
--------------------------------------
1. A string or string register can be moved into a numeric register only
if the data is all numeric, [0-9 - + .] (Note: decimal points move with
numeric data.)
2. Numeric registers can always be moved to a string register or field.
3. No substring operations are allowed in numeric registers.
Bit or Boolean Registers
------------------------
Each Boolean register is a flag that can be interrogated by the program to
see if it is on or off. Program logic upon interrogating this flag will
determine an action. In other words they direct logical branches in a
program.
Length Each boolean register is a single bit
Name #B0 to #B9
Setting SET #B0
Clearing RESET #B0
Examples:
IF #B0 SET LOCK FIELD
If bit register is set (on) lock the field named FIELD.
IF #B0 SET CALL SUB_ROUT1
If bit register is set (on) call subroutine SUB_ROUT1.
System Registers
----------------
Tutorial
39
The system has several registers that it maintains. They are:
#E This register will contain the error codes returned from file
operations, that is, the direct codes returned by the operating system
instead of the Q-PRO 4 high level codes. For example, end of media
would be returned to #E. The possible contents of this register are
listed in the computers system manual. This is a read only register.
#F The current field on the screen that the cursor is in. Fields are
numbered starting with zero from top to bottom, and moving from left
to right. Its number will be the same as the offset in the format
file listing. This is a read only register.
#K The key-out register. A read only register that contains the numeric
code describing how the operator exited the last field (causing the
current proc to be executed). Values for #K are:
1 - tabbed out
2 - backtabbed out
3 - cursor up
4 - cursor down, newline
5 - cursor left
6 - cursor right
7 - enter
8 - home
9 - any function key
10 - break
#L The line counter. Incremented each time a WRITE 0 is issued. It is
reset to 0 when the command RESTART 0 is issued.
#P The page counter. Incremented each time a RESTART 0 is issued.
Tables
------
One of the most powerful features of Q-PRO 4 is the use of tables. These
tables may be used simply to validate data or, in a more sophisticated way,
they may be used to dynamically load registers for complex data handling.
The form of the table search verb, TSEAR, is:
TSEAR <table name> AT <data item 1>{,<data item 2>, <data item 3>,. .
.}{:error}
Where:
table name A table in the program which was declared by the statement
AT Where to look for a match
Tutorial
40
data item 1 Where to put the second element of the line in the table
data item 2 Where to put the third element of the line in the table
{:error} Branch to this label if there is no match
Example:
TSEAR EXTABLE AT #N1,#S1,#N2,#N3:10010
In this example, the table looks like this
TABLE EXTABLE
1, "CUSTNAME", 15, 12
2, "STATE", 2, 10
3, "ZIP", 5, 10
END
The command TSEAR will look in numeric register one (#N1) for a match with
the first column of the table, 1, 2, or 3. If a match is made, it will
take the second element of the row in which a match was made and place it
in string register one (#S1), and the third element in numeric register two
(#N2). The fourth element will go into numeric register three (#N3).
If #N1 contains a 1, then this command loads #S1 with CUSTNAME, #N2 with
15, and #N3 with 12.
If #N1 contains neither 1, 2, or 3, the error branch will be taken.
Loading a Table with External Data
----------------------------------
The elements of a table are not limited to the literals that were shown
above. A table element can be any appropriate data item such as a file
data field, register, etc. Examples of such use are for payroll tax
tables, due dates, etc.
To illustrate this use, let us look at a payroll tax table. We will to
load a memory array from a file array with the state names which will be
the arguments of the table. Then we will load the state tax tables into a
memory array and thence to the elements of a table.
In this case, there are three state tax tables to be loaded from three
records on the file. Each record has the following data layout:
RECORD FIELD CONTENTS
STATE State Name
Tutorial
41
TAX(0) First element of tax table
TAX(1) Second element of tax table
TAX(2) Third element of tax table
TAX(3) Fourth element of tax table
There are two memory arrays, STATE with three elements, and TAX with 12
elements. Below is the code to read the file, load the memory arrays and
load the table.
PROC LOAD
* Define arrays, open file and load arrays.
VRBL STATE, X,2,3
* STATE is now defined as a string, two characters, and three elements.
VRBL TAX, N,6,4
* TAX is now defined as numeric, 6 characters, and four elements.
OPEN "TAXFILE.DAT" USING "TAXFILE.FID",1:100
FOR #N1 EQ 0 TO 2
READ 1:END_FILE
MOVE &STATE[1,#N1] TO STATE[#N1]
FOR #N2 = 0 TO 3
MOVE &TAX[1,#N2] TO TAX[#N2 +(#N1 * 4)]
ENDFOR #N2
ENDFOR #N1
END
TABLE TAX_TABLE
STATE[0], TAX[0], TAX[1], TAX[2], TAX[3]
STATE[1], TAX[4], TAX[5], TAX[6], TAX[7]
STATE[2], TAX[8], TAX[9], TAX[10], TAX[11]
END
To calculate the taxes for a state use TSEAR to get the proper state from
the screen (a field named ST) and load numeric registers to calculate as
shown below:
TSEAR TAX_TABLE AT ST, #N1, #N2, #N3, #N4:NO_STATE
END
Notes on Tables
1. You must insure that elements match. That is if the argument is a
number, then you must match it with a number. Similarly, if the result is
a string, put it into a string data item.
2. If you are dealing with a string argument, remember that spaces are
valid parts of a string. To strip a string of trailing spaces use this
Tutorial
42
code:
MOVE STRING TO #S0 TRIMMED
#S0 will contain the data from STRING with trailing spaces cut off.
Variables
---------
Introduction
------------
One of the neat things about being in data processing is the esoteric
vocabulary that we have to confound and confuse the uninitiated. One of
these terms is "variables". It is undoubtedly one of the words that we
love the most because of the confusion we can sow.
Definition
----------
Let's define the word and remove the confusion. The word variable comes
from the Latin various, meaning changing. Of the many definitions
available in the dictionary, the closest to the data processing meaning is
that of the variable in mathematics, something which has no fixed value as
opposed to a constant value.
However, in data processing, with our talent for jargon, we use variable as
a blanket term for a place in the computer memory where some data is stored
that we will change periodically. Accordingly, when we refer to a
variable, we are really talking about the contents of some location in
memory.
Usage
-----
Variables are convenient places to stash and retrieve data whose values may
change from time to time. Once a variable is given a name, the value it
contains may be used by simply using its name. The value of a variable is
always its most recent. In other words, whatever was most recently put
into the variable is what is there now. Previous values are discarded.
In Q-PRO 4, variables are exactly like screen data fields except that they
do not display. In a more complex form they can be dimensioned. (Refer to
Dimensioned Variables.)
For example, data that is on a file may be read in and stored in variables
for processing. After and/or during procesCing, the variables may`Bα
changed to reflect the results of the processing.
Other uses of variables include tables of data, or buckets to store values
Tutorial
43
temporarily. They me which field or in which
order the data is entered, the result will be correct.
Structured Programming
----------------------
Structured Constructs
---------------------
Q-PRO 4 has an excellent set of structured constructs. This set is
initiated with the command, BEGIN. BEGIN is modified by IF, WHILE, or
UNTIL followed by a condition. The BEGIN construct will be entered under
these conditions:
BEGIN IF <condition>
Enter and execute all commands between the BEGIN and ENDBEGIN if the
<condition> is true. If the <condition> is not true, skip over the
construct. (See also ELSE and ELSE IF.)
BEGIN WHILE<condition>
Enter the construct and repeatedly execute the commands within it as
long as the <condition> is true.
BEGIN UNTIL<condition>
Enter the construct and repeatedly execute the commands within it
until the <condition> becomes true.7
The BEGIN construct is terminated by ENDBEGIN. Between the BEGIN and the
ENDBEGIN are the commands to be executed if the BEGIN construct is entered.
Examples:
BEGIN IF A > B
CALL SUB1
CALL SUB2
ENDBEGIN
Tutorial
36
BEGIN WHILE A < 10
CALL TEST_SUB
ADD 1 TO A
ENDBEGIN
The subroutine TEST_SUB will be repeatedly called until the
variable A reaches the value of 10
MOVE 0 TO A
BEGIN UNTIL A=10
CALL TEST_SUB
ADD 1 TO A
ENDBEGIN
The subroutine TEST_SUB will repeatedly be called until the variable A
reaches the value of 10.
The BEGIN IF construct may also include ELSE and/or ELSE IF prior to the
ENDBEGIN.
Example:
BEGIN IF A=B
CALL SUBA
ELSE IF A=C
CALL SUBB
ELSE
CALL SUBC
ENDBEGIN
If A=B, call subroutine A, if A=C call subroutine B; if it equals
neither, call subroutine C.
Debugging
---------
Q-PRO 4 has a wealth of debugging tools that range from simply reloading
the program and BW on an error to a full runtime debugger.
ERROR Command
-------------
An ERROR command in the program code will halt execution and display the
specified error message on line 24 of the CRT. When the program encounters
the ERROR command, it will stop, display the specified error message and
wait for operator action. For debugging, a message with the ERROR command
can be used to identify locations in the code, etc. Messages can be
literals in quotes, a register, or a variable.
DEBUG Command
-------------
The DEBUG command loads the runtime debugger. It has a host of
capabilities that include looking at any field, changing memory, changing
Tutorial
37
the value of variables, and looking at the values of file fields. For more
detail on the use of DEBUG, refer to the Commands section.
TRACE Command
-------------
The TRACE command will put the program in single step mode. When TRACE is
encountered, the program will execute one command at a time, displaying the
command to be executed on line 24. Pressing the ESCAPE key will execute
the displayed command. This will continue until the command NOTRACE is
encountered or RETURN is pressed.
If the "D" key is pressed during TRACE, the online debugger will be loaded
after the command is executed.
All About Registers
-------------------
General
-------
Registers are temporary working areas maintained by the system which
resemble fields except that they are not displayed on the screen. The
contents of all data registers remain intact when you CHAIN to another
application file.
There are three types of data registers. Each type has ten usable
registers. Registers are cleared when Q-PRO 4 is first loaded. The
current value of the register remains when one program CHAINs to another.
String Registers
----------------
String registers are used as temporary storage for data. For example, they
can be used to build an output record for the printer or intermediate
storage for input data prior to moving it to a field or output buffer.
They may be used as variables in any command in lieu of a field or literal.
Also, string registers are used to transfer variables between program
chains.
Length 255 Characters
Names #S0 to #S9. (the lower case "s" can be used)
Clearing MOVE "" or '' to the register
Example: MOVE "" TO #S0
or MOVE '' TO #S0
Rules for the Use of String Registers
-------------------------------------
1. Data can be concatenated onto an existing string in a register or it
Tutorial
38
can be moved on top of existing data, but data cannot be moved to an
arbitrary position within a register that has been cleared. To move data
into the register at random, first fill it with blanks.
2. A string register may not be moved into a numeric register unless the
string register contains valid numeric data.
Note: A MOVE command with the destination being a data register
clears the register of any data previously contained and
puts the new data in the register.
Numeric Registers
-----------------
Numeric registers are used the same as string registers, but limited to
numeric data.
Length 20 Digits
Name #N0 to #N9
Clearing Move a zero (0) into the register
Rules for the Use of Numeric Registers
--------------------------------------
1. A string or string register can be moved into a numeric register only
if the data is all numeric, [0-9 - + .] (Note: decimal points move with
numeric data.)
2. Numeric registers can always be moved to a string register or field.
3. No substring operations are allowed in numeric registers.
Bit or Boolean Registers
------------------------
Each Boolean register is a flag that can be interrogated by the program to
see if it is on or off. Program logic upon interrogating this flag will
determine an action. In other words they direct logical branches in a
program.
Length Each boolean register is a single bit
Name #B0 to #B9
Setting SET #B0
Clearing RESET #B0
Examples:
IF #B0 SET LOCK FIELD
If bit register is set (on) lock the field named FIELD.
IF #B0 SET CALL SUB_ROUT1
If bit register is set (on) call subroutine SUB_ROUT1.
System Registers
----------------
Tutorial
39
The system has several registers that it maintains. They are:
#E This register will contain the error codes returned from file
operations, that is, the direct codes returned by the operating system
instead of the Q-PRO 4 high level codes. For example, end of media
would be returned to #E. The possible contents of this register are
listed in the compu Tutorial
47
Multiuser Function Keys
PROC READ_LOCK
Since everybody wants to do this, we will write a subroutine they can
all use.
READ 1 NOADV:EF
Read the record but don't advance, preparatory to trying to lock
it.
RLOCK 1:USED
Lock the record in the buffer. If it is already locked, goto
USED.
COPY 1 TO *
RETURN
Go back to the calling program at the next sequential command.
:EF ERROR "No more records "
END
PROC KEY1
CALL READ_LOCK
END
PROC KEY2
BACKSPACE 1:EF
Since we are using NOADV, we need only BACKSPACE once.
CALL READ_LOCK
END
PROC KEY11
POSN 1 TO NAME USING 1
CALL READ_LOCK
FREE 1
END
PROC KEY3
POSN 1 TO NAME RELATIVE
RLOCK 1:USED
READ 1:EF
COPY 1 TO *
END
Accession Number Management
---------------------------
One of the better methods of transaction number management stores and
maintains all the application system access numbers in a single application
control file. Usually, the file is a one record random file that is
quickly accessible and updatable. It contains such accession numbers as
next available customer number, next available order number, next available
invoice number, etc. The trick of managing the accession numbers is the
timing of when the number is updated. For example, the customer number is
updated when a new customer record is written. If it is updated at any
other time, numbers may be used and never assigned.
Tutorial
48
Another technique is maintaining them in a record in the working indexed
file with a unique and particular key that the programmer knows is for the
accession number file. For example, a file with the key $$***$$ is
unlikely to ever be reached by the user. This is a good method for small
applications. It is a problem for applications with many users because of
the large amount of file crunching always going on.
The least desirable method, we look at the last record written and add one
to its accession number. This method is not suitable for LANs and
multiuser applications.
Restructuring an Indexed File
-----------------------------
Adding Keys
-----------
You cannot change the structure of a data file by simply changing the
associated FID file. While the FID file knows about the change, no one has
told the data file. It takes a small Q-PRO 4 program to do this.
The process is very simple, we make a new FID file with the structure we
want. Then we create a new data file with the new FID and copy each old
record, one by one to the new file.
New FID File
Copy the old FID file, OLD.FID to a new file, NEW.FID. Load Binary
WorkStation. Select the FID generator mode and load NEW.FID.
Press F5 to insert a field. Enter a new field, CUSTNO, that is 10
characters long and numeric.
Press F4 to update the FID. Press Shift F10 to return to the editor.
The program
PROC RESTRUC
OPEN "OLD.DAT" USING "OLD.FID",1:100
MAKE "NEW.DAT" USING "NEW.FID",2:200
:L READ 1:EOF
COPY 1 TO 2
GOTO L
:EOF CLOSE
FCOPY "NEW.DAT", "OLD.DAT"
FCOPY "NEW.IDX", "OLD.IDX"
ERASE "NEW.DAT"
ERASE "NEW.IDX"
END
Tutorial
49
P R O G R A M M E R'S R E F E R E N C E M A N U A L
========================================================
Naming Conventions
-------------------
All Q-PRO 4 names follow the conventions shown below. These conventions
apply to screen field names, file field names, variables, and labels.
1. The first character of any name must be an alphabetic character. The
balance may be either alpha or numeric.
2. The name may be up to 10 characters long.
3. Underline characters (_) may be embedded in the name for clarity and
they are counted in the 10 character length.
Examples:
FIELD_NAME CUST_FILE NEW_CUS_NA
Keyboard
--------
Q-PRO 4 uses many of the functions of the keyboard as configured to the
particular computer and operating system. For example, in this manual we
frequently refer to the "ENTER" key. This key is different on various
computers. For the IBM PC, it is standardly the END key. With the
configuration utility, SETUP, you may change these keys to meet your own
requirements.
Format Files
------------
The format, command, or program file is the primary component of a Q-PRO 4
application program. It is created by the programmer. This file contains
the invariant (background) information, field definitions, and programming
statements necessary for a Q-PRO 4 application. The format is created with
Binary WorkStation (BW), and executed by the runtime interpreter (QNE).
Building a Format
-----------------
Binary WorkStation is used for writing the programs. It is entered by
typing BW when at the system prompt. From BW, the user may select an
existing file to edit or create a new one.
Press return to begin editing. The bottom line of the screen shows the
functions available. Pressing F10 or F9 will scroll the function
selections. For more details on the BW editor, see the Binary WorkStation
Programmer's Reference Manual
Page 50
section.
Build Screens
-------------
Select F8 Screen to edit of the background (unalterable) portion of the
screen. To create the background, place the cursor at the location on the
screen where you want the background text and type the desired text. All
the cursor control keys, the INSERT/DELETE character and line keys, and the
TAB key are active and usable for creating and editing the background.
Screen Data Field Definition
----------------------------
Place the cursor where you want an entry field and press F1. The screen
definition window will display. When the field definition process is
complete for a field, press RETURN. Previously defined screen data fields
which are denoted by strings of the pound-sign character (#) on the screen.
Although, we call these scream data fields, as you will see later, they may
or may not be enterable by the operator.
These are the items that are entered to define a screen data field:
Field No. This is the OFFSET of the field as determined by Q-PRO 4.
It is the sequential number of the field counting from top
to bottom, left to right. The offset is a most convenient
method of managing screen fields.
Field name The content of this field is a name of up to 10 alphanumeric
characters which follow the Q-PRO 4 naming conventions. The
name must be unique on the current screen but may be reused
on other screens. This name may be used as a variable by
the application program. The name need not correspond to
anything, although some correspondence is useful for
clarity.
To delete a pre-existing field, clear this name area (using
the CLEAR SCREEN key), and then press ENTER.
Len defines the number of character positions to be occupied by
the field on the screen. A length of 0 is invalid. If you
use care, fields may be overlapped for special applications.
However, be cautious, as confusion at data entry time may
occur.
Row The row number occupied by the screen data field. (Zero is
the topmost row.) This field is calculated automatically by
FB. Normally you should skip this field by pressing TAB.
However, you may relocate the field to a different row of
the screen by altering the value that Q-PRO has already put
in.
Programmer's Reference Manual
Page 51
Col is the starting column number of the screen data field.
Like the R value, this entry is calculated by BW. It may be
changed if you desire to change the column location of the
screen data field. The left-most column is zero.
Type The field type descriptor is two characters. The first
character describes the field attribute; such as numeric
only, alpha only, etc. The second character specifies
auto-duplication or an invisible field.
First Character
---------------
Blank (or x) Any data is allowed in this field.
X Any data is allowed, but alphabetic data will
be forced to upper case.
a Only alphabetic data is allowed. (A-Z, a-z)
A Only alphabetic data is allowed. When
entered they will be forced to upper case.
(A-Z, a-z)
m Only alphanumeric data is allowed. (A-Z,
a-z, 0- 9)
M Only alphanumeric data is allowed. When
entered, any alphabetic data will be forced
to upper case. (A-Z, a-z, 0- 9)
N Only numeric data, its associated sign and
decimal point is allowed. (0-9 + - .)
I Only numeric data and its associated sign are
allowed (integers only). (0-9 + -)
D Only numbers are allowed. No signs or
decimal point are allowed. (0-9)
When data is typed into the field by the operator, each keystroke
is validated. It must be within the requirements specified by
the descriptor character for the current entry field. If it is
not, an error message will be displayed on line 24 of the CRT and
none of the keys (except ESCAPE) on the keyboard will respond.
To clear the message, press ESCAPE which will clear the message
and allow resumption of keying. The previous contents of line 24
will be restored. Note that if a screen presentation is desired
in which a single entry area is to contain a mixture of types
(i.e., three digits, followed by two alphas), multiple screen
data fields may be located alongside each other so that they
present the appearance of being one field to the operator.
Second Character
----------------
Blank No additional functions will be performed at
Programmer's Reference Manual
Page 52
the keystroke level. The field will be
cleared when ENTER is pressed.
= "auto- duplication" field. This means that
the field is not automatically cleared when
ENTER is pressed, and the contents of the
field will remain after ENTER is pressed.
When entering data, the operator may
duplicate the previous value by pressing TAB.
Alternatively, new data may be typed in the
field. On the first keystroke of the newly
typed data, all character positions from the
current cursor position to the end of the
field are cleared before the new character is
placed in the field.
? The field will not be visible. This is
useful for passwords.
Just There are four options for justification of the screen field. If
nothing is specified, then the default is left. NOTE: All
fields are automatically left justified when data is being
entered. The appropriate re-justification is performed as the
operator exits the field.
L Normally, screen fields are left justified. If nothing
is entered this will be the case. However, you may
enter an L if you desire.
R Right justifies the screen field.
C Centers the data in the screen field.
N No justification of any kind.
Fill Char Use this selection to force the fill of unentered space in the
screen field. Most often this specification is left blank.
However, frequently a zero is used along with right justification
to produce a left zero filled screen field.
If a number sign (#) is specified as a fill character, blanks
will be displayed on the screen. However, when the field is
programmatically referenced (e.g., written to a file), the
leading or trailing spaces, as the case may be, are stripped from
the field, leaving a variable length result. This is useful when
building files to interface with other programming systems.
CAUTION: If you are using indexed or random Q-PRO 4 files, DO
NOT use the "#".
Almost any fill character is valid. However, for numeric data to
be used in computations, the only valid fill characters are blank
(used for left justified numeric data), and 0 (used for right
Programmer's Reference Manual
Page 53
justified data).
The default is a blank.
May Ent. Y Indicates that the operator may enter data in this field.
N Prevents the operator from entering data in this field.
This is useful for message fields, total fields, or other
computed or derived data items.
The default value is "Y".
Must Ent. Y Indicates that if the operator reaches this field, then some
data must be entered.
N Indicates that the operator need not enter data here.
The default value is "N".
Must Fill Y Indicates that the operator must enter the field and must
fill the field.
N Indicates that the operator need not fill the field.
The default is "N".
Must Tab Y Indicates that the operator must press TAB or some other
cursor control key to exit the field.
N Indicates that the operator will leave the field if TAB is
pressed or the field is filled.
The default is "N."
Procedure
name This entry may contain the name of a procedure in the program
code or it may be left blank. If a procedure is named, the name
must follow the Q-PRO 4 naming conventions. The procedure will
be executed each time the operator exits this screen data field.
This procedure may do extended validity checks and calculations,
I/O to a file, or anything else you can think of.
Programmer's Reference Manual
Page 54
THE PROGRAMMING SYSTEM
======================
Procedures
----------
Q-PRO 4 programs are composed of commands organized into procedures. Each
procedure is executed in at least one of three ways:
1. As a procedure associated with a screen data field.
2. As a standard system procedure.
3. As a procedure called from another procedure.
Screen Data Field Procedures
----------------------------
The procedure name must conform to the Q-PRO 4 naming conventions
previously described. The sequence in which procedures occur in a Q-PRO 4
program is not significant. Therefore, the programmer is free to define
some set of procedure-naming and placement standards that best suits him.
One suggested programming standard is to name field procedures the same as
their associated screen data fields, followed with a "P" (i.e., a screen
data field named CUSTNO would be linked to a procedure named CUSTNOP).
A screen data field procedure is executed when the screen data field is
exited by the operator (except for a back tab when no data has been
entered). Procedures normally end by giving control back to the operator
and may redirect the cursor to any screen data field.
Other types of procedures are discussed later in this chapter.
A procedure is defined by a PROC statement, as shown below.
PROC CUSTNOP
Within the procedure are (normally) executable statements, of the form
{label:} statement {:error}
label The label portion of the statement is optional. If present, it
follows the standard name conventions. It optionally may be
followed by a colon (:). The label may be a number or an
alphanumeric label. If it is an alphanumeric label, it must be
prefaced by a colon (:). The label is used for control transfer
(GOTO) and error trapping statements. NO EMBEDDED SPACES ARE
ALLOWED.
statement The statement is a Q-PRO 4 command or construct.
error The error branch (a label to go to on error) is valid only on
certain types of statements. If given, it must be preceded by a
colon.
Programmer's Reference Manual
Page 55
Data Items
----------
A programming language is not of much use without data to manipulate. In
this manual, we will refer to the following six types of data items:
1. Data Registers
2. Special Registers
3. Screen data fields
4. Literals
5. Variables
6. File data fields
1. Data Registers
--------------
There are two types of data registers, string and numeric. There are
10 of each type of register, designated as:
#N0-#N9 Numeric registers. Numeric registers may contain an integer
or real number of up to 20 digits. This value may be
manipulated, written to a file, examined, or overwritten in
any way.
#S0-#S9 String registers. String registers may contain a string
(i.e., any data, alphanumeric, numeric, etc.) of up to 255
characters. These registers may be manipulated, with the
MOVE, INSTR, CONCAT and other commands which provide
mechanisms for extracting substrings, performing
concatenation of strings, etc. String registers are NEVER
padded with blanks. They terminate with a null unless the
programmer inserts blanks.
Data registers also may be accessed by an indexing expression, which
must evaluate to a number between 0 and 9 (i.e., #S[#N0+2]). (Refer
to EXPRESSIONS in this chapter.)
2. Special Registers
-----------------
#B0-#B9 The Boolean or flag registers. They may be SET or RESET,
and are used to mark the occurrence of special events within
an application.
#F A read-only numeric register which contains the current
screen field number (as shown on the format file listing).
Since fields can be referenced indirectly through $FIELD
(see Functions, below), this means that generalized code can
be written to handle several like fields using $FIELD[#F]
instead of the field names themselves.
Programmer's Reference Manual
Page 56
#L The line counter register. It is incremented every time a
line is written to the list device with a WRITE 0 statement.
When a RESTART 0 statement is executed (producing a form
feed on the printer), #L is cleared (or set to an optional
number of line feeds following the form feed).
#P The page number register is incremented every time a RESTART
0 statement is executed. Refer to the Commands section for
more details on RESTART and WRITE.
To start a report, set both registers to 0, and the normal
course of output to the printer will maintain the registers
after that. To sense the need for a new page, a line of
code similar to the following should be executed after every
print line: IF #L=PAGELENGTH THEN CALL HEADING
To output the page number to a report, the following
sequence might be used:
RESTART 0
PUT "PAGE " TO 0
PUT #P TO 0
WRITE 0
Of course, using the report generator is even easier.
#E The error register. The contents of this register are the
error codes as returned from file operations. These are the
direct codes returned by the operating system instead of the
Q-PRO 4 high level codes. The possible contents of this
register are listed in the appropriate system manuals as
being returned from a specific system call.
#K The keyout register has a numeric code telling what control
key caused control to be given to the program. The values
for this register are as follows:
0 - typed out
1 - tabbed out
2 - backtabbed out
3 - cursor up
4 - cursor down, newline
5 - cursor left
6 - cursor right
7 - enter
8 - home
9 - any function key
10 - break
Programmer's Reference Manual
Page 57
3. Screen Data Fields
------------------
Screen data fields are defined by the programmer. They may be
manipulated in any way. As their value changes, that change is always
reflected on the screen. Fields may be accessed directly by their
names or indirectly through the $FIELD function.
FOR #N0=0 TO 3
MOVE $FIELD[#N0+1] TO $FIELD[#N0]
ENDFOR #N0
CLEAR $FIELD[#N0]
4. Literals
--------
Literals (constant values) may be numeric or string or control
character. Literals may be used in any computation or manipulation
(including direct output to files), except that they may not be stored
into.
String Literals String literals must be delimited with either
single (') or double (") quotes which must be
paired. Strings may not be delimited by mixed
single and double quotes (i.e., 'THIS IS
ILLEGAL"), although a string delimited by one type
of quote may contain the other type (e.g., 'And I
quote, "Four score and seven"').
String literal examples:
"THIS IS A STRING LITERAL"
'This is a string literal with single quotes'
Numeric Literals Numeric literals are numbers. They may include
the decimal point (.) and be preceded by a minus
(-) sign. They may not include any non-numeric
characters such as a comma (,) or a dollar sign
($). Numeric literals are not delimited with
quotes.
Numeric literal examples:
19746
289567
Control Character Literals A control character is a decimal literal or
any numeric data item preceded by an at (@)
sign. The binary equivalent of the decimal
value will be treated as a string literal of
Programmer's Reference Manual
Page 58
1 character. This feature is most frequently
used for controlling printers with special
features such as expanded print, vertical
tabbing, etc., or in sending special control
commands to the screen.
Control character literal examples:
@44
@#N0
To put an OKIDATA into bold print mode, you
could use this sequence:
PUT @29 TO 0
5. Variables
---------
Variables are data items, maintained in memory, which can be used in
computations or to build strings. They may be accessed in the same
manner as screen data fields. In general they behave in the same
manner as screen data fields (i.e., may take on a value, may be
extracted from a file, may be incremented or decremented, etc.).
Variables are defined by the programmer in VRBL statements, which are
normally executed at format load time in PROC LOAD. They may take on
single values (in which case, they are referenced directly by name),
or multiple values (in which case, we call them ARRAYS, and reference
them by an indexing expression which names the specific element of the
array we desire to access). Variables may be used anywhere or in any
expression in place of fields, literals, or registers. The maximum
array size is 65,000 elements (memory permitting).
6. File Data Fields
----------------
Fields in data records may be accessed in two ways--either by their
relative positions within the record, or by their names. The second
way is more to be desired, and is accomplished by associating a FID
(field item descriptor) file with a data file at MAKE or OPEN time.
These FID files are nothing more than a list of fields and their
locations within a record. Using this approach, the programmer never
has to worry where a field is within a record, even if a record format
has changed since it was last used.
FID files are built with the FID option of Binary Workstation
described in the chapter on BW. When a data file has been opened
using a FID file, then fields within the record may be accessed using
the following general syntax:
Programmer's Reference Manual
Page 59
&name[file number{,array element number}]
The ampersand (&) in front of the field name tells Q-PRO 4 that this
is a file field name. The name tells the system where on the record
the data is located. The number tells the system which file is to be
used (since different files may have the same field names). The
optional index selects one element from a field array when
appropriate.
Example:
&CUSTNAME[1] This denotes the field CUSTNAME from file 1.
Standard Procedures
-------------------
Any procedure may be linked to a screen field by naming that procedure in
the field definition phase of the format building process. There are
certain procedures which, although left up to the programmer to define,
have special significance to the Q-PRO 4 system. Not defining these
procedures, however, does not necessarily result in an error. Standard
procedures are not usually linked to screen data fields.
PROC BREAK
----------
Executed when:
1. A BREAK key has been defined (standardly control C) through SETUP,
and;
2. Breaks are enabled (default is BRON) with the command BRON, and;
3. The system is NOT currently accepting input from the operator (e.g. is
printing a report, searching a file, etc.), and;
4. The defined BREAK key is pressed.
A RETURN from PROC BREAK goes to the statement after the calling
statement. When Q-PRO 4 loads, it initializes as BRON.
PROC ENTER
----------
Executed when the operator presses the DESIGNATED ENTER (standardly the
return key on the IBM PC) key, signifying "data entry complete." This pro-
cedure might be used to update a file record, chain to another format, etc.
It also clears all operator enterable screen data fields.
PROC ERROR
Programmer's Reference Manual
Page 60
----------
Used as the first level of error trapping provided to the programmer. For
a full discussion of errors and error handling, refer to Chapter 4.
PROC KEY0-20
------------
Used to link application code to function key sequences. That is, pressing
function key 0 (ESC on the IBM PC) causes PROC KEY0 to be executed
immediately if in field entry mode and not executing (printing, search,
etc.); pressing function key 1 causes procedure KEY1 to be executed
immediately, etc. If a procedure is not declared for a function key
(except key 0), and that key is pressed, an error message is displayed on
the screen. The error may be recovered from by pressing the ESCAPE key.
If procedure KEY0 is not defined and ESC is pressed, Q-PRO 4 will execute a
SYSTEM command, which closes any open files and returns to the system.
This is the only function key with a "default value."
PROC LOAD
---------
Automatically executed the first time a format is loaded into memory. It
is typically used to open data files, set initial register contents, etc.
Statement Types
---------------
There is a wide variety of statement types in Q-PRO 4. Some, such as those
that deal with file handling and error trapping, are dealt with in their
own respective chapters. All are fully defined in the System Commands
chapter. The following is a list of the various statement types, and the
statements which fall into each category:
File Handling
-------------
ERASE, OPEN, MAKE, CLOSE, PUT, GET, READ, WRITE, COPY, FREE, RESTART, POSN,
SECURE, BACKSPACE, FILETYPE, RENAME, FSEAR, FCBADDR, KEY, FCOPY, RCLEAR
Error Handling
--------------
ERRTRAP, ERROR, NCHECK
Arithmetic
----------
ADD, SUB, MUL, DIV, ROUND, CALC, ^, MATHLIB, NOMATHLIB
Logical
-------
SET, RESET
Programmer's Reference Manual
Page 61
Control Transfer
----------------
GOTO, CALL, RETURN, CHAIN, END, FOR, ENDFOR, BRON, BROFF
Conditional
-----------
IF, ON, BEGIN, ENDBEGIN, WHILE, UNTIL, ELSE
Screen Control
--------------
CLEAR, HOME, HOMECLEAR, NEXT, RESUME, LOCK, UNLOCK, BELL, BUFFER, CURSOR,
PRINT, HON, HOFF, FILL
Data Formatting
---------------
EDIT, UNEDIT, RJUST, LJUST, CENTER, CURRENCY, UCASE, INSTR
Data Movement
-------------
MOVE, CONCAT, ASEAR
Table Management
----------------
TSEAR
Operating System Interface
--------------------------
RUN, SYSTEM, FORMLOAD, NOFORMLOAD
Debugging
---------
TRACE, NOTRACE, DEBUG, FORMLOAD, NOFORMLOAD
Machine Language Interface
--------------------------
MEMEND, LOAD, EXEC, PEEK, POKE, DEFSEG, $MEMEND()
Multiuser Management
--------------------
RLOCK, RUNLOCK, HOST, LPDETACH, LRETRY
Miscellaneous
* (COMMENT), PRINTSCN, SIZE, HELP, JDPACK, JDUNPACK, SETDATE, GETDATE
Functions
---------
Programmer's Reference Manual
Page 62
$ASC(), $ETOX(), $FIELD(), $INT(), $LN(), $MEMEND(), $OFFSET()
Expressions
-----------
Expressions are used by Q-PRO 4 as part of commands as calculations instead
of literal numbers. For example, a particular element in an array which is
desired at a given time is 5 or ARRAY[5]; at another time, it may be 6,
etc. This element may be calculated in an expression such that it is
dynamically set instead of explicitly set by ARRAY[expression]. The
expression is any set of numeric data items such as:
ARRAY[#N1+(#N2 * #N3)]
ARRAY[ARRAY[#N3]]
Screen Offset
-------------
The SCREEN OFFSET allows the programmer to address the fields on the screen
as offsets from the first variable field. The first screen data field on
the screen, starting from top to bottom, right to left, is numbered zero
(0). The rest follow sequentially. Thus, the programmer may dynamically
select fields on the screen according to the program logic or a table
look-up. Either a literal or an expression may be used to address the
field with the function $FIELD [numeric register, literal, or arithmetic
expression].
Example:
MOVE $FIELD[5] TO $FIELD[6]
Moves the sixth field on the screen, (counting from the top left field
on the screen and going from left to right, top to bottom, starting
with field zero) to the seventh field.
The use of $FIELD allows handling of fields on the screen by position
on the screen without worrying about the name of the field. Thus, the
combination of loops, registers and tables gives extraordinary screen
handling capability. #F can be used in this command.
Example: scrolling fields through the screen., using the screen format
below:
Field 0 ############### Field 1 ##############
Field 2 ############### Field 3 ##############
The program code:
Programmer's Reference Manual
Page 63
FOR #N0 = 0 TO 2
* Begins a FOR loop from 0 to 2.
MOVE $FIELD[#N0+1] TO $FIELD[#N0]
* Moves FIELD 1 (#N0 plus 1) to FIELD 0.
* Then moves FIELD 2 to FIELD 1. Then moves FIELD 3 to FIELD 2.
ENDFOR #N0
END
Note that in the contents of the brackets following the $FIELD will be
evaluated as an expression. This expression must evaluate to an
integer. The following are all valid:
$FIELD[(#N1 * #N2) + 10]
$FIELD[#N1 + #N2 - 20]
$FIELD[SCNFIELD + 5]
$FIELD[#F]
Structured Programming
----------------------
BEGIN and ENDBEGIN
------------------
BEGIN denotes the beginning of the structured construct. BEGINs may be
nested and may have any of the following modifiers.
BEGIN
BEGIN WHILE . . .
BEGIN UNTIL . . .
BEGIN IF . . .
ENDBEGIN denotes the end of the structured construct. It can have any of
the following modifiers
ENDBEGIN
ENDBEGIN WHILE . . .
ENDBEGIN UNTIL . . .
Examples:
BEGIN WHILE A GT 0
SUB &VALUE(100) FROM A
READ 100
ENDBEGIN
BEGIN UNTIL A EQ 10
ADD 1 TO A
ENDBEGIN
BEGIN IF A NEQ 0
Programmer's Reference Manual
Page 64
ADD 1 TO A
ENDBEGIN
BEGIN
SUB 1 FROM A
ENDBEGIN WHILE A LT 100
ELSE and ELSE IF
----------------
An ELSE or ELSE IF is always associated with a BEGIN IF. A BEGIN may have
any number of IF statements associated with it.
Example:
BEGIN IF #N1 GT 100
SUB 1 FROM #N2
ELSE IF #N1 LT 100
ADD 1 TO #N2
ENDBEGIN
Tables and Table Handling
-------------------------
One unique concept of Q-PRO 4 is that of the table as an addressable
entity.
A table is a data structure which can be applied to defining default
values, verifying keyed-in values, replacing abbreviations with full text,
setting up field lengths within records, and many other uses. It appears
as a one or two dimensional matrix, as the following sample table
declarations illustrate:
TABLE FIRST
"ABCD"
"DEF"
END
TABLE SECOND
1, "PA"
2, "NJ"
3, "NY"
END
A table is conceptually regarded as having some number of rows (the first
dimension) and some number of items within each row (the second dimension).
A row may have as few as one item, or as many as will fit on a line. Items
MUST be separated by a comma (,).
The first element in a table row is called the "key" or "argument" for that
row, and is usually a numeric or string literal. This key is used with the
Programmer's Reference Manual
Page 65
TSEAR statement to locate a particular row within a table.
Table Lookup and Data Verification
----------------------------------
Let us suppose that a format screen has a screen data field named STATE,
into which the operator will key the usual two-character state
identification, but in which we desire to programmatically place the full
name of the state, after verifying that the state is one of a valid list of
states. Further suppose that the following table had been declared:
TABLE TSTATES
"PA", "PENNSYLVANIA"
"DE", "DELAWARE"
"FL", "FLORIDA"
"GA", "GEORGIA"
"NJ", "NEW JERSEY"
"CA", "CALIFORNIA"
END
Having this table, we can then verify the entry of a valid state in the
field called STATE with the following TSEAR statement:
TSEAR TSTATES AT STATE :100
This says the following:
o Within the table called TSTATES, find a row whose key is equal to the
current value of the field STATE.
o If a match is found, then go to the next statement. If no match is
found, go label 100.
This use of the TSEAR statement gives us the ability to verify that the
state keyed in was one of a valid list of states.
Table Lookup, Verification and Replacement
------------------------------------------
Going a step further with the example and table above, we can do both the
validation and abbreviation replacement with TSEAR as follows:
TSEAR TSTATES AT STATE,NSTATE :100
The same search for a match between STATE and a row key within TSTATES will
occur. However, when a match is found, the field NSTATE will take on the
value of the next data item in the matched row after the key (here, the
Programmer's Reference Manual
Page 66
full name of the state). If a whole set of information was tied to a
particular state, for example, the beginning and ending ZIP codes, we could
put all that data into the table and let TSEAR pull it out when the state
is verified.
Table Verification and Chaining
-------------------------------
Another use for tables is the verification of menu selections and
subsequent CHAINing to the proper program segment. For example, suppose we
have an application menu as shown below:
PAYROLL SYSTEM MENU
1- ENTER EMPLOYEE DATA
2- ENTER TIME CARDS
3- PRINT CHECKS
4- PRINT REGISTER
5- CHANGE TAX DATA
6- EXIT SYSTEM
ENTER SELECTION [#]
where # denotes a field defined with the name INPUT. In one statement
(using tables), a selection could be automatically verified, and the
appropriate program selected for chaining. The instructions to do this
are:
PROC ENTER
* LOOK UP SELECTION AND GET THE PROGRAM NAME IF FOUND
TSEAR SELECTABLE AT INPUT,#S0 :100
* IF PROGRAM NAME IS NULL, THEN WE ARE DONE
IF #S0 EQ "" THEN SYSTEM
* ELSE LOAD NEW APPLICATION PROGRAM
CHAIN #S0
100 * THE GIVEN SELECTION IS INVALID
ERROR "INVALID CHOICE, PLEASE REENTER"
END
* THIS IS THE SELECTION TABLE
Programmer's Reference Manual
Page 67
TABLE SELECTABLE
1, "ENTEREMP"
2, "ENTERTC"
3, "PRINTCH"
4, "PRINTREG"
5, "CHANGETAX"
END
Note that if more selections are added, only the screen and the table need
change. This concept can readily be expanded to include the description
line, as well as the file name within the table, so that only the table
need be changed as the range of selections expands.
Tables as Label Arrays
----------------------
An alternative use for tables is as a procedure or label array. In this
use, a table name and index may be used instead of a procedure in a CALL
statement, or instead of a label in a GOTO statement.
Tables used in this manner are normally not used with the TSEAR command,
since lines within the table consist not of keys optionally followed by
data, but of single items which are either procedure names (for indexed
calls) or labels (for indexed GOTOs).
One use of the indexed CALL or GOTO feature might be responding to a menu
selection (possibly even using the example above), as follows:
PROC ENTER
* FIRST VALIDATE THE INPUT
IF INPUT = 1 AND INPUT =4 GOTO GOTBL[INPUT1]
ERROR "INVALID SELECTION"
END
* TABLE CONTAINING LIST OF LABELS
TABLE GOTBL
100
200
300
END
Tables as Procedure Arrays
--------------------------
Another use might be in processing a data file record, whose first field is
a record type, as follows:
PROC DOREC
* RECORD TYPE IS IN &RECTYPE[1]
READ 2:EOF
* CALL PROCESSOR FOR THIS TYPE
Programmer's Reference Manual
Page 68
CALL PROCTBL[&RECTYPE[1]]
RETURN
END
* TABLE OF ROUTINES FOR DIFFERENT RECORD TYPES
TABLE PROCTBL
ADDREC
DELREC
CHANGEREC
END
Index values for CALL and GOTO tables start with 0 for the first item, 1
for the second, etc.
Programmer's Reference Manual
Page 69
FILES AND FILE HANDLING
=======================
File Handler
------------
Q-PRO 4, Version 4.0, uses a sophisticated, state-of-the-art B+ tree,
multikey file handler. This file handler is the file BTSYS.EXE, which is
terminate and stay resident. You must load BTSYS or no file handling will
occur. It must be loaded before anything else in the Q-PRO 4 and Q-N-E
system.
File System Interrupts
----------------------
BTSYS uses interrupts 80h, 81h, and 82h. Other terminate and stay resident
programs also grab whatever they want. As there may be conflict, BTSYS's
interrupts are configurable by establishing a DOS system variable, QNEFSI.
For example, to change the interrupts to 8Ah, 8Bh, and 8Ch. before BTSYS is
loaded, from AUTOEXEC.BAT or from the command line SET QNESFI = 8A.
Loading BTSYS
-------------
From the system prompt, type: BTSYS <cr>
or
BTSYS QNE <program name> <cr>
(This unloads BTSYS when the program is finished.)
From a .BAT file:
BTSYS
or
BTSYS QNE <program name>
(This unloads BTSYS when the program is finished.)
Unloading BTSYS
---------------
From the command line, type: BTSYS /U <cr>
Files and File Handling
Page 70
File Limitations
----------------
Q-PRO 4 has few limitations on files. These are shown below:
Characteristic Limit
Maximum Field Size 255 characters
Maximum Record Size 65K (memory allowing)
Maximum File Size 2 Gbytes
Maximum Files Open at One Time 255 (memory allowing)
File Types
----------
Q-PRO 4 supports four types of files:
o random
o multi-key index sequential
o sequential
o sequential with comma delimited fields (SDF files)
Common data file handling statements are used for each type of file. As a
programming convenience, access to the system print device is performed
with file-like statements.
Multi-key Indexed Sequential Files
----------------------------------
File Keys
---------
Each file may have up to 9 keys or sort sequences. All keys are updated
when the record is written. The primary key may not be duplicated.
Rewriting a record with the same primary key will have the effect of
updating the current record; it will NOT create a new record. You may
change keys at any time but you must remember that the file position will
not be changed.
Records in indexed files are accessed by an alphanumeric key, not by a
record number. The key consists of up to 128 alphanumeric characters. It
may be multi-field and the fields need not be adjacent.
Reading and Writing
-------------------
Indexed files may be read any key order or in physical order. When writing
a record, the controlling key is the PRIMARY. In other words, even if you
are using a secondary key, the file handler will create the record
positioning information correctly.
Files and File Handling
Page 71
When reading an indexed file, it is important to remember that the keys are
LEFT JUSTIFIED ASCII CHARACTERS. In this sense, numbers are considered
characters not numbers. When positioning to a record, the file handler
compares the record key and the search key from left to right looking for a
match.
Physical Order
--------------
In addition to the 9 keys, the file may be read, positioned, and backspaced
in physical order (the order in which it was created) by setting it in key
0. A numeric expression must be used for the record number in the position
command. The BACKSPACE command will back up the file one physical record.
All other commands that affect indexed files will work normally, that is to
say, if a record is written, it will be written as an indexed record.
If a deleted record is read, then trappable error number 34, Deleted record
read. The record will be loaded into the record buffer. (You can take
advantage of this characteristic to recover deleted records.)
Data File
---------
An indexed file set consists of two files, the data file which is an ASCII
file, and an index file. Within the file each record is allocated an 8
byte internal control field. If any character, except blank (decimal 32)
is in the first 8 bytes, the record is inactive. Each record is terminated
with a carriage return/line feed. The minimum record length is 10 bytes.
Index File
----------
There is one index file no matter how many indices are active. The index
file retains all data, even if it is flagged as inactive. Therefore, the
index file may get quite large. Running the utility QMAINT with the PACK
option will compress the index file.
As data records are added to the indexed file, keys are added and the nodes
of the index file will split, leaving voids that will be used as the file
is updated.
The size of the index file is a function of the number of keys, number of
records in the data file, and the size of the keys. The size of the key
should be kept as small as possible since the actual key is the secondary
key with the primary key appended.
Although a B+ tree index never needs to be balanced, occasionally it should
be packed to reclaim disk space. The state of the index, packed or not,
does not materially affect the speed of adding, deleting, or retrieving
records.
In a single user mode, key nodes are buffered. Setting BUFFERS = 40 in
PC-DOS or MS-DOS is highly recommended.
Files and File Handling
Page 72
Deleted Records
---------------
Inactive or deleted records are removed automatically by the file handler
if there is frequent corresponding record addition. The user may remove
them with a simple Q-PRO 4 routine to copy the old file with the deleted
records to a new file.
File Maintenance
----------------
The program, QMAINT, has facilities for:
o VERIFYing, or validating, the index file against the data file.
o PACKing, or compressing the index file.
o RECOVERing a damaged index file. The data file is pure ASCII and
can be repaired with any ASCII file handling techniques. The
RECOVER option creates a new index file from the data file. The
implications are, among others:
1. You can delete the index file altogether and still rebuild
it.
2. You need only store the data files for backup.
Random Files
------------
Structure
---------
Random files are identical in structure to indexed files, except there is
no index file. Records may be read or written in order or directly
accessed by record number within the file (0 is the record number of the
first record). The file's record size may be any length.
Maintenance
-----------
The user is responsible for determining all aspects of a random file's
maintenance. Records are not deleted; the user must keep track of records
that he no longer wants to use.
Sequential (text) Files
-----------------------
Sequential files are in standard ASCII format, and are compatible with most
standard text files (for example, those produced by editors or word
processors). Records in these files may be of varying length. Records are
Files and File Handling
Page 73
separated with a carriage return/line feed sequence. Sequential files may
be opened only for output, or only for input, and are accessed in
sequential record order only.
SDF (Comma Delimited) Files
---------------------------
SDF files are identical to sequential files; except that in an SDF file
record, all data fields are delimited by quotes and separated by commas.
Q-PRO 4 will always delimit fields by quotes, but can process records
written by other systems which may not put quotes around numeric fields.
Indexed and Random File Handling
--------------------------------
Fundamentals
------------
All file operations are based on the concept of a file buffer in memory.
The buffer is established with the MAKE or OPEN statement, and removed with
the CLOSE statement. Data coming into or out from a Q-PRO 4 program first
passes through a file buffer.
A file buffer may be thought of as a string of data. This string may be
accessed in a symbolic, high-level manner (using file field names), or in a
specific, low-level manner (using the relative location of data fields
within the string).
In the course of opening or creating a file, the programmer assigns it a
number from 1 to 255. Thereafter, the file is referenced by its assigned
number.
Data Dictionary (FID) Files
---------------------------
The most convenient method to access fields in a data file record buffer is
by name. To do so, the programmer must first build a FID (file item
descriptor, or data dictionary) file using the FID file generator. The FID
file is, in essence, a list of field names and their locations within the
record. To store data in the record, or to extract the data, the
programmer need only reference the file data field by name, just like a
screen data field, variable, or register. Not only is this simple to
program, but also the program becomes almost completely independent of the
record format. This means that when the record format changes, only the
file changes (not the program)!
A "data dictionary" facility means that there is a means of documenting
file contents and layout. This is the FID generator which is discussed in
detail in its own section. This high level means of accessing file data is
only available for random and indexed files.
Files and File Handling
Page 74
A single data dictionary file may be used for multiple data files.
CAUTION: Each data file requires its own index file. Note: A data file
must have at 10 characters of data.
PC-DOS and MS-DOS File Considerations
-------------------------------------
For reasons known only to MicroSoft and the mighty blue giant, IBM, their
operating systems, MS-DOS and PC-DOS, allow only up to 20 open files
(handles) to be used by any one process. This 20 file limitation is set
only if FILES is set to 20 in CONFIG.SYS. The operating system hogs five
handles for itself leaving 15 for the process. We take one for QNE.EXE
which leaves 14 for data files and their associated index files. Each data
file takes one handle and each index takes one handle.
Obviously, for useful applications, more than seven indexed data files are
a necessity. So we have found a way to get around the system limits. As
the file system uses files it will eventually run out of file handles. It
will then close the least recently used file that is not locked or has no
records locked, and then it will open or reopen the target file. For
example, when you use an eighth data file, the file handler will close one
of the other seven data files and open the eighth data file. If you have
many open files in an application, you pay the consequences of the
shortsightedness of the masters of software with a lengthened time to open
the files when loading the program. Additionally, there may be a
noticeable delay when accessing a file because another file may have to be
physically closed and the file being accessed re-opened. This file
handling is transparent to the application designer as the files stay open
logically.
In the future if the maintainers of DOS, in their wisdom should awaken to
the real world, the file system will automatically adjust and open more
files before it has go into the virtual file handle mode.
File Restructuring
------------------
Q-PRO 4 indexed and random files can be restructured, that is new fields
added or deleted and/or keys added, changed or removed by writing a simple
Q-PRO 4 program. The principle is to read the old file with its data
dictionary and write a new one using the new data dictionary. The new file
will be in the new structure. The code fragment below illustrates the
technique.
PROC RESTRUCT
* Open the old data file and create a new one to copy to.
OPEN "OLD_DAT.DAT" USING "OLD_DAT.FID",1:10
MAKE "NEW_DAT.DAT" USING "NEW_DAT.FID",2:20
* Read old file and copy/write it to the new until end of file.
:L READ 1:EN
Files and File Handling
Page 75
COPY 1 TO 2
WRITE 2:30
GOTO L
:EN END
File Handling Commands
----------------------
The following paragraphs discuss in detail the Q-PRO 4 statements dealing
with file handling. Each function is further broken down by file type,
with an explanation of the implications of each statement for each file
type.
The full syntax is described in the Q-PRO 4 Commands Chapter.
MAKE
----
This statement creates a file (after first deleting it if it already
exists) and leaves the file open for later processing. The syntax of the
MAKE statement has four variations, depending on the file type involved.
OPEN
----
The function of this statement is similar to that of MAKE, except that it
refers to a file already in existence on disk. Therefore, an attempt to
open a non-existent file will result in an error. DO NOT use OPEN to
determine if a file is already open, use the FILETYPE command.
FILETYPE
--------
This command has two functions:
1. It returns information about currently open files.
2. It determines if a file is open or closed.
CLOSE
-----
This statement tells Q-PRO 4 that a data file is no longer required for
processing. Although all files will be closed automatically when Q-PRO 4
returns to the operating system, good programming practices suggest that
files should always be explicitly closed when no longer needed.
SECURE
------
This command has the same effect on an indexed file as CLOSE, in that it
forces the immediate update of internal file information required by Q-PRO
4. However, the file is still left open after the SECURE operation for
further processing. This information is potentially changed after every
WRITE or FREE operation.
Files and File Handling
Page 76
Warning: Turning off the computer without CLOSEing or SECUREing the
data files will always corrupt them. Worse, the operating system will
not update the directory and data will be lost.
PUT
---
PUT is most often used to print directly from Q-PRO 4 and writing
sequential and SDF files. It is not normally used when dealing with files
using the FID file option, although it can be.
The PUT statement places a data item into a file or printer buffer for
later output with the WRITE statement. (PUT to a sequential file does
immediate output.)
GET
---
GET is not usually used with indexed and random files using FIDs, although
it can be.
The GET statement retrieves data from a file buffer and stores it into a
register or field. GET is essentially the opposite operation from PUT in
this respect. Be careful when GETting from random or indexed files to
avoid overflowing the record buffer.
KEY
---
The KEY command changes the file key reference of a multikeyed indexed
file. When the file is created or opened, the default file key is one (1).
When the key is changed, all file movements: POSN, READ, BACKSPACE, etc.
will be understood to be in the current key sequence and at the current
file position.
POSN
----
This statement positions the data file to a specific record for reading or
writing (random/indexed files only).
POSN RELATIVE
-------------
For indexed files, if the desired key does not exist and the keyword
RELATIVE is not given, a READ command to the file will give an end-of-file
error. If the keyword RELATIVE is given, then the file is left positioned
at the nearest key higher in value than the key originally specified (if
such a key exists).
POSN USING
----------
Files and File Handling
Page 77
A variation of the POSN command allows positioning and changing the data
file key at the same time. Obviously, this variant is only used with
indexed files.
READ
----
The READ command loads a data buffer with the currently positioned record
(random or indexed files), or advances to the start of the next record
(sequential).
WRITE
-----
The WRITE command outputs a data record to a file (random/indexed), or
outputs a carriage return/line feed sequence to a file (sequential).
RESTART
-------
This command resets the file buffer pointer to any position within the data
buffer (does not apply to sequential files). This is especially of use in
an environment where records are read, displayed, and updated using GETS
and PUTS, whether fields occur in sequential order within the record or
not.
FREE
----
The FREE statement marks a record in an indexed file as deleted. To delete
a record, it must be first loaded into the file's data buffer using a READ.
To insure the presence of the correct record, the usual procedure to delete
an indexed file record is the command sequence: POSN, READ, FREE.
BACKSPACE
---------
This statement moves the file backwards one record from the current
position. It is only used for random or indexed sequential files. An
end-of-file error is generated if there are no records in the file, or if
the file is already positioned at the first record.
COPY
----
COPY is used only with data files that have FIDs. It is used for rapid
transfer of data from a file to the screen, from the screen to a file, or
from a file to another file.
FCOPY
-----
FCOPY copies a file to a file. No wild cards are allowed.
Files and File Handling
Page 78
FSEAR
-----
FSEAR searches a data file on a record-by-record basis for the satisfaction
of any logical condition.
Files and File Handling
Page 79
ERROR HANDLING
==============
General
-------
There are two basic types of errors that may occur within a Q-PRO 4
program:
o Those that are handled automatically within the system. Examples of
automatic errors are: syntax error (always fatal), or an invalid
character typed in a field (recoverable by the operator). Since these
errors are always handled in the same manner by the system (and are
inaccessible to the format program), the reader is referred to the
Error Section for a list of these errors.
o Those that optionally may be handled by the user program. Errors
which can be handled by the program are termed "trappable" errors.
Error trapping is hierarchical in nature. There is a hierarchy of
error trapping is shown below.
1. Local Error Traps. A local error trap is designated by the colon
(:) and a line number or label at the end of the command. If a
local error trap is designated, it overrides any other error
traps.
2. ERRTRAP. If there is no local error trap ERRTRAP will execute
(if present). Note that ERRTRAP has precedence and overrides
PROC ERROR.
3. PROC ERROR. If there is no local error trap, or ERRTRAP control
of the program will go to PROC ERROR.
If no error trapping is specified, a trappable error will be handled as a
fatal error.
Local Error Traps
-----------------
Nature of a Local Trap
----------------------
Certain statements (generally file-oriented statements and TSEAR) may
designate line numbers or labels to act as error traps for that statement
only. These "local traps" override the presence of an ERRTRAP or PROC
ERROR (described below). Functionally the local error trap is analogous to
"ON ERROR GOTO XXX" .
Error Handling
80
Registers
---------
In contrast to the more global types of error trapping (PROC ERROR and
ERRTRAP), however, the contents of #N0 and #S0 are unchanged in an error
condition. In most circumstances this results in no loss of flexibility,
since the type of error trapped is usually predictable, depending on the
statement executed. In the following example, a local error trap is
associated with a read statement to detect an end-of-file condition.
PROC READREC
* Input the next record
READ 5 :1001
* Load the data field
CALL LOADREC
END
*We go here at file end
1001 CLOSE 5
ERROR "END OF DATA ENCOUNTERED"
CHAIN "MENU"
END
PROC ERROR
----------
When PROC ERROR Is Invoked
--------------------------
The standard procedure ERROR receives control when a trappable error occurs
and there is no local error trap or ERRTRAP.
At the time of the error, the error number (as listed in Appendix A) will
be placed in numeric register 0 (#N0), the system level error will be
placed in the system error register (#E) and the error message will be
placed in string register 0 (#S0).
In general the system error register (#E) is more valuable for the low
level information needed for debugging.
Example of Use
--------------
The following is an example of an ERROR procedure. In this example, the
procedure checks for a "file unavailable" error (presumably caused by
trying to open a non-existent file) and, if so, displays an error message
and returns to the operating system. Otherwise, the system generated error
message is displayed and the statement that caused the error is re-executed
if PROC ERROR is terminated with RETURN or END. A GOTO in PROC ERROR will
cause stack overflow problems and, presumably, a call to us for help.
Error Handling
81
Example of PROC ERROR
PROC ERROR
* No file error?
IF #N0 EQ 13 THEN GOTO 1
* Some other error - just display it
ERROR #S0
END
* Display NO FILE error
1 ERROR "CAN'T FIND DATA FILE"
SYSTEM
END
ERRTRAP
-------
The ERRTRAP facility is used in the same manner as a local error trap,
except that it may be used to redirect error trapping to different segments
of code. Each field procedure, for example, could have its own error trap
routine. Note: error traps set by ERRTRAP override the existence of PROC
ERROR.
ERRTRAP uses the same registers as PROC ERROR.
The following is an example of a procedure with its own error trap.
PROC FOPEN
* Set error trap
ERRTRAP 10
OPEN "DATAFILE",1,1
MOVE "FILE OPEN" TO STATUS
* Done, clear the error trap
ERRTRAP
NEXT CUSTNO
* Error, look for no file error
10 IF #N0 EQ 13 THEN GOTO 11
* Some other error - display it
ERROR #S0
END
* File not there, create it
* Clear the error trap first
11 ERRTRAP
MAKE "DATAFILE",1,1
MOVE "FILE CREATED" TO STATUS
END
Note that the ERRTRAP line number previously designated as an ERRTRAP is
disabled by another ERRTRAP statement that has no line number.
Error Handling
82
System Error Register - #E
--------------------------
In all three of the above techniques for handling errors, the error number
register (#E) may be examined. This register contains the specific error
code returned by the operating system in response to a file operation
request (as opposed to #N0, which returns a Q-PRO 4 level error code).
Error Handling
83
LANS and MULTIUSER SYSTEMS
--------------------------
General
-------
The multiuser or local area network (LAN) poses many complex problems for
the application developer. For the most part, the documentation furnished
with the operating system is either sparse or confusing, or both. Q-PRO 4
must work within the constraints of the operating system no matter how
illogical its design may be. This chapter attempts to explain the
functioning of the Q-PRO 4 commands and how the operating system handles
them.
The Q-PRO 4 shareware version is a LAN, Multiuser version. The multiuser
runtime will always run on a matching single user operating system. For
example PC-DOS programs will run with a PC-LAN runtime.
Principles
----------
The system works on a principle of "mutual exclusion" at the statement
level. This means that, under program control, a record may be locked so
that one user will not be changing a record when another user is searching
for a record. Similarly, the programmer has control over the way files are
opened, LOCKED, UNLOCKED, and/or READ ONLY.
This is achieved by system calls and is transportable from operating system
to operating system. This locking process is always under the programmer's
control and is transparent to users. Q- PRO 4 will try one time to get a
data record lock and a setable number of times (set with LRETRY) to get a
header record lock before reporting an error (failure to get a lock) if the
record is already locked to the programmer. It is up to the programmer to
decide what to do when a lock is attempted and the record is already
locked. It is a must, however, that programs attempt to lock a record
before doing a read for update or a record deletion.
Multiuser Commands
------------------
The following Q-PRO 4 commands are specifically for multiuser operating
system control. See the commands section for syntax and examples.
HOST
----
The HOST is set with the HOST statement in the program code, typically in
PROC LOAD. HOST sets the type of multiuser system the application is
running under. NO files may be open when this command is executed. If
LAN's
Page 84
MULTIUSER data files are to be shared, the host value must be set to a
multiuser value (that is, not SINGLE) or ALL the files may be corrupted if
updated. Once set, the selected HOST remains until running under another
HOST is selected or the application returns to the multiuser operating
system.
RLOCK
-----
RLOCK is ignored if the system is not in multiuser mode. If the system is
in multiuser mode, it will lock the record on which the file is currently
positioned (regardless of what record, if any, is currently in the data
buffer). If the application has previously locked a record in the same
file, the lock is released before attempting a new lock, even if the
attempt at the new lock is unsuccessful.
An error will occur if the record is locked by another application, an
adjacent record in the same sector is locked, or if the file is busy. The
error returned is a file exclusion failure, error code 25. The programmer
may choose to have the application try the lock again or try to lock some
other record. Any other error should be treated as a fatal error.
Note that the protocol of locking a position in a file before trying to do
something with the record at that position is entirely at the option of the
application programmer. Nothing in multiuser operating systems, at the
current level of technology, prevents an application from reading a record
locked by someone else, if so desired.
RLOCK locks the record position being pointed to in the file buffer. It
unlocks a previous lock if there is one.
RUNLOCK
-------
RUNLOCK unlocks a record that has been locked by the RLOCK command.
LRETRY
------
The LRETRY command sets the number of times a lock is attempted. This
value may be increased to help avoid timeouts on waiting for the header.
Be careful when you use this command for you must give the system enough
time to react.
OPEN and MAKE
-------------
OPEN and MAKE have two optional keywords after the file number, UNLOCKED
and R/O (read/only). By default, a file is opened as read/write and locked.
These keywords can be in any order and need not appear together. If a file
is not opened in the unlocked mode, then only one application can open the
file. (Note: some systems do not support files in locked mode.) Any other
application attempting to use the same file will get the error, 'file
unavailable' (error code 6).
LAN's
Page 85
In almost all applications, but especially applications where unavailable
files may occur, to be safe, MAKE all the files during application
installation before any other application starts. With this technique, if
error code 6 is returned, the programmer will know it was because the file
was locked (not because the file was not there). This error also may occur
if a MAKE is attempted on a file that is locked by another user. If files
are being opened in unlocked mode (shared), a file exclusion lock may occur
if the file is already opened by another user and is busy (see notes on
file busy).
READ
----
The READ command can return two additional errors in multiuser mode:
1. The first is a file exclusion failure, error code 25 (file was busy).
This does not necessarily mean that the record trying to be read is
locked. Instead, it means that the file was busy processing a request
for another application. The read may be tried again.
2. The second additional error is a file sync failure, error code 26. A
sync error may occur under the following two circumstances (or
variants thereof):
o the application positions to a record, but before the record is
locked and read another application deletes the record.
o The application does a read without NOADV, intending to go to the
next record. If that record is then deleted by some other
application before it is read, a sync error can also occur.
WRITE
-----
The only additional error in multiuser mode is a file exclusion failure.
This can happen if the record being written is locked by some other
application. When a record is inserted into the index file, the record
linkages of connecting records must be updated. If any of these are locked
by someone else, the WRITE will fail. This is important to remember
because it can cause what is called a "deadly embrace." Deadly embrace
occurs when both applications have a record locked that will cause the
other to fail the write. Unless one application unlocks the record, they
will both continue to fail the write.
FREE
----
The FREE command is similar to the WRITE command in that a record can not
be deleted if one of the records affected is locked. This will cause a
file exclusion failure, as in WRITE. The error "key not found" (error code
32) is returned if the record to be freed was deleted by some other
application after the READ but before the FREE.
LAN's
Page 86
BACKSPACE
---------
BACKSPACE will return a file busy error (exclusion failure) or a file sync
error, for the same reasons as in read.
FSEAR, POSN, and SECURE
-----------------------
The commands FSEAR, POSN and SECURE also may return a file exclusion
failure (error code 25). During any ISAM file I/O, the header record of
the indexed file is locked so that only one application is moving through
or updating the index file tree structure. If an insert takes a very long
time because there are many duplicates or the file is grossly out of
balance, the other applications will time out waiting for the header and
get the file exclusion failure. This time out is set by LRETRY.
LPDETACH
--------
LPDETACH closes the spool file.
MULTIUSER - ERRORS
------------------
#E - The ERROR REGISTER
-----------------------
#E is a read-only register called the error register. The contents of this
register are the error codes as returned from file operations. That is,
the direct codes returned by the operating system instead of the Q-PRO 4
high level error codes. The possible contents of this register are listed
in the operating system manuals.
MULTIUSER ERROR CODES
---------------------
FILE EXCLUSION LOCK FAILED
Trappable as error 25. System tried LRETRY times to lock record 0 of an
indexed file (required for most file operations) and could not get the
lock.
FILE SYNCH. FAILURE
Trappable as error 26. Files are said to be out of synch when one process
reads a record with apparently valid index links, which is then discovered
to have been deleted by some other process.
BAD HOST STATEMENT
Trappable as error 27. A host statement was executed which either did not
LAN's
Page 87
have a recognizable name, or at a time when all files were not closed.
FILE READ-ONLY
Trappable as error 28. Pretty obvious what this one means.
For multiuser user, be sure you configure your operating system to allow
three locks per file, file and record. (You need only 2 files, if you will
not do record-locking in your application).
LAN's
Page 88
B I N A R Y W O R S T A T I O N
=================================
Introduction
============
Complete Development System
---------------------------
Binary Workstation (BW) is a complete development management system. BW is
intuitive in use and extremely flexible. There is no master menu and you
probably will never miss it! Indeed, after a cursory look at the
documentation and a few minutes using BW, you will probably consign the
documentation to gather dust wherever you toss unused documentation.
Multiple Files
--------------
Binary WorkStation can store several of your source files in memory at the
same time. You can switch from module to module with a press of a key.
You can edit each individually and even copy parts from on to another.
Syntax Checker
--------------
At the press of a key, your entire program will be checked for syntax
errors saving you hours of debugging.
Operating System Shell
----------------------
While you are in BW you can run any other program and then return to the
same line of code.
Multiple Editors
----------------
Text Editor
----------
Binary Workstation is a fully featured text editor for editing Q-PRO 4
programs or ASCII files. You can import/export Q-PRO 4 program files or
ASCII files also.
FID Editor
----------
The File Item Descriptor (FID) editor is used to create and edit the file
descriptions.
Screen Editor
-------------
Used to "paint" screens, you paint the background color, specify the window
Binary WorkStation Editor
Page 89
size and location, specify the active field color, specify the screen data
entry field colors, and define the screen data entry fields.
Miscellaneous Features
----------------------
Other outstanding features of BW are: Alt key macros, History log file, On
Screen Clock and Backup file option.
Starting Up
-----------
Setting Up DOS for BW
---------------------
Binary WorkStation has an options file. In fact, it can have an options
file for every subdirectory you use it in. Or it can have one options file
that is in a directory specified by the DOS variable, <BI>BW. We recommend
that, at first, you use the DOS variable.
Binary WorkStation has extensive help screens. You can refer to them from
any subdirectory where you happen to be if you use the DOS variable BWHELP.
Also, so you can use it anywhere, the subdirectory with Binary WorkStation
in it should be on the path.
Setting the options
-------------------
From the command line, type: BW<ret>
The options screen will be displayed. If an option file exists in the
current directory or on the path, the previously selected options are
displayed.
Use the TAB key to move from field to field. Pressing ENTER will save the
options and bring up the editing screen.
Current File [ ] Enter the path and name of the file to be
edited. When you leave this screen, the
named file will be displayed.
Vertical Scroll Lines [16] Number of lines to scroll when Page Up/Page
Down are executed.
Backup File [N] A backup file of the file you are editing
will be maintained if you enter a "Y"
Clock [Y] If Y is selected, the time will be displayed
in the lower right corner of the screen.
Binary WorkStation Editor
Page 90
Q-PRO 4 File [Y] If "Y" the editor will assume Q-PRO file
format. If "N" it will assume a standard
ASCII file. You need not set this flag, BW
can figure out which one it has when the file
to be edited is loaded.
Directory Pattern [ ] This pattern will govern the files to be
displayed when the FILES option is selected
when in the editor.
FID Path [ ] If you are going to use the FID editor
feature, you enter the path for the defined
FIDs.
FID Names Up to 20 may be specified.
History Log File [N] If "Y", a log file, HISTLOG.BW will be kept
of all functions, save, etc. with function
and date/time.<
Text Lines (min 500) [ ] Sets the maximum number of lines of text
allowed in a file. Us it to make more room
for multiple files.
Printer: Char. Per Line [80] Sets the number of characters per line.
Default is 80.
Lines Per Page [55] Sets the number of lines to print on hard
copy. Default is 55.
DOS variables
-------------
If you set the DOS variable BW with the DOS SET command in AUTOEXEC.BAT
this way:
SET BW=<editor directory>
only one option file will be used for all directories.
If you set the DOS variable BWHELP with the DOS SET command in
AUTOEXEC.BAT this way:
SET BWHELP=\<editor directory>
then the help screens will be displayed from any directory you are
working in
Uses for the Option File
Binary WorkStation Editor
Page 91
------------------------
If you are developing multiple applications, it is suggested that BW be in
its own directory on the DOS path. Then each application may have its own
subdirectory and options set.
Binary WorkStation Editor
Page 92
The Text Editor
===============
Running from the Command Line
-----------------------------
From the command line type: BW <file name><ret>
If an options file exists on the logged directory or on the path, the
options screen will be displayed momentarily. Then you will be moved to
the program code editor.
Overview
--------
The text editor has two editing modes, INSERT character and TYPEOVER
character. The status is displayed on the upper right and the Insert key
toggles the mode.
ESC Key
-------
The ESC key acts as a "cancel" key. For example, if you have brought up a
dialog screen, pressing ESC will bring you back.
All other functions are executed either by pressing function keys or a
control characters. The current function that will be activated by the
function key is displayed at the bottom of the screen as a menu line. A
typical editor screen is shown below:
Status Line The top line is the status line. From left to right the
fields are:
library.qne The name of the file currently being edited.
Line= The line number that the cursor is currently on.
Col= The current column of the cursor.
Total Lines= Total lines in the program. This reserves space for your
program files. Clearly, the smaller the programs, the less
total lines you should specify and the more programs you can
have in memory simultaneously.
Insert= This is a general mode setting switch. It will be ON in the
INSERT character mode or OFF in the DELETE character mode.
Toggle the mode by pressing the Insert key. Several
functions work differently depending on whether INSERT mode
is ON or OFF.
Binary WorkStation Editor
Page 93
Function Insert ON Insert OFF
-------- ---------- -----------
TAB Moves the text at the cursor
position 4 spaces to the right.
Return Inserts a carriage return Moves the cursor to the
line feed at the cursor beginning of the next line.
position.
Any key Inserts the character at Overwrites the character
the cursor position at the current character
position.
10:16am The system time
Menu Line
---------
Bottom Line - The bottom line is the menu line. Because the menu line can
display only eight functions, the menu line itself is changed by pressing
F10 to scroll the menu forward, F9 to scroll the menu backward.
From the main BW screen, dialogue screens and specification screens are
summoned for various functions such as text search and FID display and
generation.
There are four main menu lines:
Line F1 F2 F3 F4 F5 F6 F7 F8
0 Top Bottom Pg Up Pg Dn Insert Delete Fields Screen
1 Load Update Unload Save/x Swap Exit FIDs Exec
2 Search Sr/Rep Again ASCII Print Eject Syntax Regs
3 FIDgen Files Merge Optns Insert Delete Word Help!
4 SetMrk MovBlk CopyBlk DelBlk Line#s Un-Del Goto Help!
This is what will happen with each selection:
The accelerator key is shown in <>
Top Move the cursor to the beginning of the file. <HOME key>
Bottom Move the cursor to the bottom of the file. <END key>
Pg Up Move the page up by the number of lines specified in Vertical
Scroll in the Editor Options screen. <PgUp key>
Pg Dn Move the page down by the number of lines specified in Vertical
Scroll in the Editor Options screen. <PgDn key>
Binary WorkStation Editor
Page 94
Insert Insert a line at the current cursor position. <Control C>
Delete Delete a line at the current cursor position. <Control D>
Fields Displays the screen data field specifications. <Control F>
Screen Brings up the window definition screen ready for editing. See
the Screen Editor chapter for more detail. <Shift-F8>
Load Load a file into the editor. You may Load up to eight files into
memory as long as you have the memory. BW has an overhead of
approximately 20K per file loaded. The dialogue screen below
will be displayed. <Control L>
The files currently loaded in RAM will be displayed.
Load File:file1.qne
The most recently loaded file's name will be displayed. To load
another file, type the name and press enter.
Update Updates the currently loaded file to disk. The dialogue screen
show below is displayed: <Control U>
Save this file [Y]
BW assumes that you want to save a file so it defaults to Y.
Save in Q-PRO 4 format? [Y]
Enter Y if you want to save this file in Q-PRO 4 format, i.e.,
with screens. If you want to save it in ASCII format, press N.
File name [ ]
Type the name of the file that you want to save.
Unload A dialog screen displays a list of all files Loaded.
Entering a Y in the box will keep the file loaded. Entering an N
will unload the file. You may keep or discard as many files as
you want.
Unloading a file does not save it. If you have edited a file and
want to keep the results, update it before unloading it.
The cursor will be in the Unload? column. Enter a Y in the
appropriate box to remove the file from memory.
Save/X Saves all the files that are currently loaded in memory and exits
BW. The same dialogue screen as in SAVE will be displayed for
Binary WorkStation Editor
Page 95
each file. <Shift-F4>
Swap Swap unloads the current program file from the screen and loads
the next one in sequence. BW keeps track of where you are in
each file and returns you to that line when the program is
swapped in. <Control O>
Exit Leave BW. <Control X>
FIDs Displays a dialogue screen to select the fid to be displayed.
Only FIDs that have been defined in Editor Options will be
displayed. For more information, see the FID Generator section.
<Control P>
Execute Brings up a dialogue screen to select a program to run. It
defaults to the program currently loaded.
You may execute any executable program, e.g. DIR,FORMAT,
etc. If you are executing QNE, BW will automatically put a
$ in front of the file name to turn off the QNE banner.
After execution it will ask you to hit any key to return to
BW and display the text file that was in memory. The
dialogue box shown below will be displayed: <Control Q>
The most recently executed command line will be displayed.
Enter a new one to run a different program. You may edit
the line with insert/delete keys. The dollar sign ($) tells
the Q-PRO 4 interpreter to suppress its banner.
Notes on Execute:
-----------------
This option will execute the program on disk. Therefore, if you
are executing the program just edited and in memory, you must
update the program currently loaded to insure that what you have
edited is executed. You will get a warning.
For proper return from the executed Q-PRO 4 program, do not use
FORMLOAD.
Search Displays a dialogue screen for setting the search criteria.
<Control S>
The fields are used as follows
Search for [ ] The exact string to be searched for. BW
will search for this string throughout
the entire file.
Ignore case [Y] This instructs BW whether the search is
Binary WorkStation Editor
Page 96
case sensitive or not. The default is
Y.
Quote Character [~] Use this character for when you are
looking for a quote "". Although the
default is tilde, you may use any
character.
Sr/Rep Displays a dialogue screen for setting the search and replace
criteria. <Control T>
Search for [ ] The exact string to be searched for. BW
will search for this string throughout
the entire file.
Replace with [ ] Replace the any string that matches the
search criteria with the string in shown
here.
Ask before replace? [Y] Stop and ask before replacing the string
with the new value.
Ignore case [Y] This instructs BW whether the search is
case sensitive or not. The default is
Y.
Quote Character [~] Use this character for when you are
looking for a quote "". Although the
default is tilde, you may use any
character.
Again Perform the search again. <Control A>
ASCII Display a chart of the ASCII values of decimal characters.
Print Print the program file. <Shift-F5>
Eject Send a form feed to the list device.
Syntax Invokes the fearsome syntax checker. It goes through your code
from the current cursor position to the end looking for syntax
errors. Upon finding one, it will stop on that line, give an
error message, and highlight that line. <Control W>
Regs Displays all registers that are used. <Control R>
FIDGen Invokes the FID generator. See the FID Generator section for
more details. <Control V>
Binary WorkStation Editor
Page 97
Files Displays a directory of files that meet the directory pattern set
in the Editor Option Screen.
Merge Merge an external file with the characteristics in a dialogue
screen at the current cursor location. <Shift-F9>
Fill in these fields as discussed below:
Merge File: The name, including drive and directory, of the
file.
Include Program Text? [ ] Enter Y or N. If Y, the text of
the ASCII file or the program text
from a Q-PRO 4 file will be
inserted.
Include Screen? [ ] Enter Y or N. If Y, the screen of the Q-PRO
4 file will be inserted.
Optns Display the Editor Options Screen
Word Move the cursor from one word to another.
Help! Display help screen.
Set Mrk Define blocks for block operations. Set the beginning of the
block by placing the cursor at the location to be marked and
press the Set Mark key. Mark the end similarly. <Alt-F1>
Blocks are assumed to be complete lines. No partial lines are
allowed.
To mark a single line, place the cursor at the beginning of the
line and press the key twice.
Move Blk Move the marked block to the current cursor location. Move Block
will not move a block from one loaded program to another after a
SWAP. <Alt-F2>
Cpy Blk Replicate the marked block at the current cursor location.
You can copy a block as many times as you wish. You may also
copy the block from one file to another after a SWAP. <Alt-F3>
Del Blk Delete the marked block. You may delete blocks from one file to
another. <Alt-F4>
Line #s This function toggles the display of paragraph numbers on the
left border of the screen. <Shift-F7>
Binary WorkStation Editor
Page 98
Un-Del This function puts the most recently deleted line at the current
cursor position. When using the delete line function, up to 100
lines are stored that may be undeleted. <Shift-F6>
Goto Jumps the cursor to a line number in a Q-PRO 4 program file or an
ACSII file. <Control G>
Help! Display help screen.
Other Key Functions
-------------------
Standard keys
-------------
These keys perform the usual functions:
INS DEL UP DOWN LEFT RIGHT
PgUp PgDn HOME END BACKSPACE ENTER
TAB BACKTAB
Accelerator Keys
----------------
The accelerator keys execute the functions directly. The accelerators are
executed by pressing the Ctrl key and the letter at the same time. They
are:
Control Key Function
A Search Again
B Go to the beginning of the Line
E Go to the end of the Line
F Fields
G Goto a line number
L Load another file in RAM
N Unload a file in RAM
O Swap the displayed file for another
P Display FID
Q Execute
R Display registers in use
S Search
T Search/Replace
U Update the file in RAM onto disk
V Invoke the FID Generator
W Invoke syntax checker
X Exit from BW
Shifted Key Function
Binary WorkStation Editor
Page 99
F3 Flip bottom line of display
F4 Update/Exit
F5 Print
F6 Undelete
F7 Display Line Numbers
F8 Go to screen editor
F9 Merge another file
ALT Key Function
F1 Set Mark
F2 Move marked block
F3 Copy marked block
F4 Delete marked block
Other Keys
----------
Other standard keys have expanded functions. They are:
Home Move to the beginning of file.
End Move to the end of file.
Backspace This is a destructive backspace. If you delete an entire
line, the next line will be moved up.
Del Deletes the character at the current character location. If
the cursor is at the end of a line, text from the next line
will be appended to the current line.
Screen Editor
=============
Screen Definition
-----------------
The definitions of the screens are kept in the program file. The screen
mode has its own menu line that works slightly differently than the program
edit menu line. It scrolls forward only by pressing F10. The next menu
line to be displayed is always displayed.
The Insert and Delete keys remain functional as insert character and delete
character.
Building a Screen
-----------------
All Q-PRO 4 screens are built in the "What-you-see-is-what-you-get"
(WYSIWYG) mode.
Binary WorkStation Editor
Page 100
Screen Constants
----------------
For constants (or labels or fixed fields or background, whatever you use
for terminology) on the screen, just move the cursor where you want the
constants and type them.
Screen Data Entry Fields
------------------------
For data entry fields, invoke the EDIT FLD option on the menu as discussed
below.
The menu lines are:
Binary WorkStation Editor
Page 101
F1 F2 F3 F4 F5 F6 F7 F8
Edit Fld Next Fld HLT On HLT Off Insert Delete Field Edit
Screen FIDS Reps Import Insert Delete! Help Edit
Graphics
Edit Fld Displays the field definition window:
See the Programmer's Reference section for a detailed
discussion of field characteristics. Only the field that
the cursor is currently on is editable. Enter re-displays
the screen.
Field Name The name of the screen data field.
Len The length of the screen data field, 1 to 255
characters.
Row The row where the screen data field is located. This
row is put in automatically by Binary WorkStation but
you may change it to move the screen data field.
Col The column where the screen data field is located.
This row is put in automatically by Binary WorkStation
but you may change it to move the screen data field.
Type This is a two character field. The first character is
the attribute and the second is blank=no edit,
?=invisible field, or = for autoduplicate.
Just This is the field justification. You can use L for
left justified, R for right justified, C for center or
N for none.
Fill Char This specifies the character to be used to left fill
the screen data field. It is typically a zero (0) for
left zero fill.
May Ent A "Y" here allows the user to enter data in the field.
You could have a field for program remarks only. Here
the field would be N which would not let the user enter
data.
Must Ent If "Y", the user must enter at least one character in
the field.
Must Fill If "Y", the user must not only enter data in the field,
but must full it completely.
Binary WorkStation Editor
Page 102
Must Tab If Y, the user must press the TAB key to exit the
field. If it is N, the user may press TAB to exit the
field or be moved to the next field automatically when
the field is filed.
Proc Name The name of the procedure to execute when the user
exits the field.
Hlt On Turns on the highlighting at the point where the cursor is
located. On the IBM PC, the default highlighting is reduced
intensity. Highlighting requires a character position on
the screen. With the full distribution version of Q-PRO 4,
you can modify the highlighting to your own satisfaction.
Hlt Off Returns the highlighting to standard.
Edit Leave the screen editor.
FIDs On this screen will be displayed any FID file that you
designated on the option screen. You may select one of the
pre-designated FIDs by entering its number.
Reps Display a dialogue screen. Enter a number of reps while
positioned on a previously defined field will reproduce the
defined field the number of reps time, vertically. BW will
generate names for the fields.
Import This will format the current file into a Q-PRO 4 Help Screen
or Q-PRO 4 Background Screen format. It takes the first 24
lines in the program file and moves them to the screen.
HELP! Displays a help window.
Graphics Mode Turn Graphics mode on. Graphics are drawn on the screen
with the cursor keys and the function keys.
Next Fld Moves cursor to next defined screen data field.
HLT On Turns highlights on at the current cursor location.
Highlight for PC-DOS is REDUCED INTENSITY. You MUST leave a
position for the highlight.
HLT Off Turns highlights off at the current cursor position.
Insert Insert a line at the current cursor position.
Delete Delete a line at the current cursor position.
Fields Display the specification for all defined screen data
Binary WorkStation Editor
Page 103
fields.
Fid Generator
=============
The FID System
--------------
The Binary Workstation File Item Descriptor Generator (FID) is used to
build and maintain descriptions of file records (called FID files). It
provides a program-independent means of maintaining data file formats.
With FID, changes to file formats may be made without regard to any
programs which reference these files, since all references to file fields
is done on a symbolic (field name) basis.
Other features of the FID system are:
o unlimited number of fields in a record.
o optional overlapping of file data field (called realignment).
This allows varying record formats within a data file.
o replicated fields within a record. This allows fields to be
referenced within Q-PRO 4 as if they were arrays.
o automatic documentation of record formats.
FID Files
---------
Restrictions
------------
The information about record layouts is contained in a file separate from
the data file, called a "FID" file. A FID file may have any name, and
reside on any drive or directory.
Commands to associate data files with FID files at open or creation time
are described in the Programmer's Reference Manual.
FID Dialog Screen
-----------------
First the FID dialogue screen is displayed. If any .FIDs are on the FID
path, as defined in the options screen, they will be shown on this screen.
If the FID file you want to edit is shown on the list on the top of the
screen, enter its number and press enter. Otherwise, type the FID file
name and press enter. This screen will display:
Main FID Screen
Binary WorkStation Editor
Page 104
Editing
You can move the cursor freely within the screen displayed to change
currently displayed data or enter new data.
Item Name In this column you specify the name of the FID field. This
name must follow the standard naming conventions.
Len. This is the length of the FID field. It can be 1 to 255
characters in length.
Type The FID field type is either alphanumeric (X) or numeric
(N).
Description You may enter here any description that helps document the
field.
Reps The number of times this field is repeated in the file.
Using this feature allows you to have file arrays. You may
dimension the array from 1 to 64K.
An element in the array is called out in your program in
this format:
$FID_name[file #, element]
file # The file number that uses this FID.
element An integer literal or an expression that
evaluates to an integer. Note: The
element numbers start at 0.
Examples:
$FED_TAX[1,0] The first element in file 1,
field FED_TAX.
$FED_TAX[1, (#n0-1)] The #n0-1th element in
file 1, field FED_TAX
F1 - Page Up Scroll the FID down a page (if it is long enough).
F2 - Page Down Scroll the FID up a page.
F3 - Load FID file Moves the cursor to the top line awaiting a FID file
name. After you type the name and press enter, the FID
file (assuming it exists) will be loaded.
F4 - Update FID file This selection allows a file description to be
Binary WorkStation Editor
Page 105
stored as a FID file on disk. If the FID file
previously existed (if there is already a file by
the same name on the disk), then that file will be
renamed to name.BFD. This is so that any
previously existing data file might be regenerated
using the old .BFD FID file as the original
description, and the new FID file as the desired
description.
If a .BFD file is already found to exist, then FID
assumes that this is an old version yet to be used
for regeneration and no new .BFD file is
generated. Any file with the same name as the
current FID file is deleted.
F5 - Insert Field Pressing this key opens up a line for inserting a new
FID field definition.
F6 - Delete Field Pressing this key deletes the FID field definition at
the current cursor location.
F7 - Define Keys This selection will brings up a window, shown below, at
the bottom of the screen to define the file key.
This screen defines what fields make up each key.
Fields need not be adjacent. Keys must be specified
in sequence, i.e., 1, 2, 3, etc. If NO keys are
specified, the file will be RANDOM.
When the screen is first displayed, key number 1 will
be displayed. Put in the keys by FID file name using
the TAB to go from field to field.
In each space enter the name of the FID file field that
comprises the key. Note: A file with no keys is a
random file. See the programmer's reference manual for
more information on random files.
Notes on keys
-------------
Definitions
-----------
A key is an ASCII string consisting of one or more
fields that need not be adjacent. A file may have up
to 9 keys. Key 1 is, by convention, the <BI>primary
key. All other keys are referred to as <BI>secondary
keys.
Binary WorkStation Editor
Page 106
Primary Keys are UNIQUE. There are NO duplicates. In
other words, there is one and only one record with this
key.
Secondary Keys may be duplicated. You may have many
records with the same secondary key.
Use -- A file can be positioned to a specific record if
the value of the record's primary key is known. It can
be positioned to the first record of a set that has the
same secondary key.
Character Alignment -- Because the keys are ASCII
strings, you must be careful of the alignment of the
fields and, particularly with numeric keys, leading
characters.
Generally, alphanumeric fields used as keys will be
left justified.
If you want the records to be in sequence with numeric
keys, they must be right justified. Remember, left
zero (0) fill is not the same as left blank fill.
F8 - Align Fields with other Fields
Brings up this screen:
Field name Offset Aligned with
[ ] [ ] [ ]
[ ] [ ] [ ]
.
.
.
[ ] [ ] [ ]
Aligned with This field contains the name of a previous field within
this record with the same starting character position
as the current field. If left blank, then the current
field takes the next available character position. If
not blank, then it must contain the name of such a
field. All later field definitions will be located
after this field.
Using this facility, data files may effectively have
more than one record format, either by redefining the
entire record, or by leaving the first section of the
record common to all formats. For example, if we
Binary WorkStation Editor
Page 107
wished to store invoices and invoice payments within
the same file, we could have the following (simplified)
sequence of fields:
NAME LEN LOCATION DESCRIPTION
---- --- -------- ------------
INVNUM 6 1 Invoice #
TYPE 2 7 Blank if invoice, else payment number
SHIPPER 20 9 Shipper name
PRODNO 4 29 Product number
QUAN 4 33 # of items shipped
PRICE 7 37 Price each
(This much defines an invoice. Now for the fields which redefine the same
record space for a payment entry).
CHECK 6 9 Check # (aligned with SHIPPER).
MONTH 2 15 Month of check date.
DAY 2 17 Day of check date.
YEAR 2 19 Year of check date.
AMT 7 21 Month of check.
In referencing this as file 1, if &TYPE[1] was non-zero, then the record
represents a payment; that is, &CHECK[1], &MONTH[1], &DAY[1], and &AMT[1]
represent valid data. If &TYPE[1] is zero, then we should only deal with
&SHIPPER[1], &PRODNO[1], &QUAN[1], and &PRICE[1], since this is an invoice
record.
Refer to sample programs and FIDS for examples of the use of aligned
fields.
F9 - Merge FID file This selection allows merging into the currently
displayed FID file another FID file. You can use it to
make a FID for multiple screens by using the Quick FID
option an then the merge. Pressing F9 will move the
cursor to the top of the FID screen with this message:
MERGE FILE ___________________
Enter the name of the FID file to be merged and press
ENTER.
Sh-F10 - Quit Exit the FID generator.
Sh-F1 - Print Print the FID definition.
Sh-F2 - Quick FID This selection creates a FID file from an application
file. All the screen data fields and their definitions
will be in the created FID file. The default key will
Binary WorkStation Editor
Page 108
be the first screen data field on the screen.
Once the name is entered and the FID file updated from
the main menu, any previously generated FID with the
same file name will be over written with the new FID.
You may modify the created FID in the same manner as
any other.
X - Return to Main Menu
Returns to the main menu screen.
Referencing File Data Fields
----------------------------
Referencing By Name
-------------------
Fields in records described by FID files may be referenced by name like any
other data item (variables, screen fields, registers, etc.). The syntax of
a FID field reference is as follows:
&name [file# {,array element}]
&name file field name
file # the file number referenced.
array element the number of the file field repetition, beginning
with 0 (zero).
Remarks
-------
Since FID fields may have the same name in different files, or as
screen fields or variables, the "&" denotes that a FID field is being
referenced. The file number may be any arithmetic expression
resulting in the desired number.
Examples:
&LASTNAME[1] The field LASTNAME from file 1
&LASTNAME[#N2] The field LASTNAME from the file whose file
number is in #N2.
The index is used only for FID field arrays, that is, FID fields that
are defined with more than one repetition. The index denotes which
item in the FID field array is desired. The first FID field in the
array has an element number of zero. Indices may range from 0 to the
number of elements minus 1. If no index is given for a replicated
item, 1 is assumed.
Examples:
Binary WorkStation Editor
Page 109
&NUMBER(1,3) The fourth element in the file array NUMBER.
&NUMBER(#N1, #N2) The element number contained in #N2 in file
number #N1.
Binary WorkStation Editor
Page 110
Q - PRO 4 Commands
Q - P R O 4 C O M M A N D S
=============================
Symbology
=========
Several symbols have been chosen as delimiters of portions of the commands.
They are:
Curly Braces ({}) Enclose an optional phrase as explained in the
text. The vertical lines are never part of the
command.
Angle Brackets (<>) Enclose phrases that are generic symbols. The
angle brackets are never part of the command.
Square Brackets ([ ]) Used in various contexts as actual parts of a
command.
Parentheses (( )) Used interchangeably with square brackets and in
expressions in various contexts as parts of a
command.
Structure of the Commands
-------------------------
A command is made up of the following elements:
Label (Optional) A numeric line number or an alphanumeric label. An
alphabetic label is denoted by a leading colon (:).
Statement The executable statement, broken into:
VERB - The main command
OPERANDS - Data items
MODIFIERS - Additional operations for the
verb
Error Line number or label to branch to on error.
Example:
:FIND_IT TSEAR TABLE AT #N1, #S1: NO_GOT
Where:
:FIND_IT is the label
TSEAR is the verb
#N1, #S1 are data items
TABLE is a modifier
AT is a modifier
separator for error branch
Commands
Page 111
Q - PRO 4 Commands
NO_GOT label to branch to
Naming Conventions
------------------
Names within Q-PRO 4 follow the conventions listed below. These
conventions apply to screen field names, file field names, variables, and
labels.
1. The first character of any name must be an alphabetic character.
2. The name may be up to 10 alphanumeric characters long.
3. Underline characters (_) may be embedded in the name for clarity
and they are counted in the 10 character length.
Examples:
FIELD_NAME CUST_FILE DATA ITEMS
Data Items
----------
There are six different classifications of data items as shown below. Each
classification is of one or more types: string, numeric, and Boolean. In
the table below, these types are represented as shown:
N is Numeric (0-9, decimal point, sign)
S is String (all alphanumerics)
B is Boolean or bit (a bit set or reset)
DATA ITEM TYPE
1. Data registers N, S
2. Special Registers N, B
3. Screen data fields N, S
4. Literals N, S
5. Variables N, S
6. File data fields N, S
1. Data Registers
------------------
#N0-#N9 Numeric registers Numeric registers may only contain
numeric data (0-9 decimal point and a
leading minus sign).
#S0-#S9 String registers String registers may contain a string of
up to 255 characters.
Commands
Page 112
Q - PRO 4 Commands
2. Special Registers
---------------------
#B0-#B9 The Boolean or flag registers.
#E The error register.
#F A read-only numeric register which contains the current
screen field number.
#K The keyout register. The values for this register are
as follows:
Value Meaning
--- -------
0 typed out
1 tabbed out
2 backtabbed out
3 cursor up
4 cursor down, newline
5 cursor left
6 cursor right
7 enter
8 home
9 any function key
10 break
#L The line counter register.
#P The page number register.
3. Screen Data Fields
----------------------
Screen fields are defined by the programmer. They may be manipulated in
any way.
4. Literals
-----------
Literals (constant values) may be numeric, string or control character .
String literal examples: "THIS IS A STRING LITERAL"
'A string literal with single quotes'
Numeric literal examples: 19746 289567
Control character literal examples: @44 @158 @(#N0 + 5)
5. Variables
------------
Variables are data items, maintained in memory. They may take on single
values (in which case they are referenced directly by name), or multiple
values (in which case we call them ARRAYS, and reference them with an
indexing expression which names the specific element of the array we desire
Commands
Page 113
Q - PRO 4 Commands
to access).
6. File Data Fields
-------------------
Fields in data records may be accessed in two ways, either by their
relative positions within the record, or by their names. The second way is
accomplished by associating a FID (field item descriptor) file with a data
file. Syntax:
&FIELD NAME [<FILE NUMBER> {, <INDEX>}
The ampersand (&) in front of the field name tells Q-PRO 4 that this is a
file field name. The <FIELD NAME> tells the system where on the record the
data is located. The <FILE NUMBER> tells the system which file is to be
used (since different files may have the same field names). The optional
index selects one element from a field array when appropriate. Example:
&CUSTNAME[1,2]
Expressions
-----------
An expression is a set of numeric data items joined by mathematical
operators which Q-PRO 4 will evaluate into a number. Many of the Q-PRO 4
commands may use expressions. This allows the programmer to let the
program calculate complex relationships.
For example, a particular element in an array is desired at a given time is
5 or ARRAY[5], and at another time, it may be 6, etc. This element may be
calculated in an expression such that it is dynamically set instead of
explicitly set by ARRAY[expression]. The expression is any set of numeric
data items such as:
#N1 + (#N2 * 3)
ARRAY[#N1 + 2]
ARRAY[#N1+(#N2 * #N3)]
ARRAY[ARRAY[#N3]]
Examples: MOVE ARRAY1[#N1 + #N2 + 3] TO ARRAY2[#N1-#N2]
ADD ARRAY1[#N1 + (#N2 + 3)] TO $FIELD[#F + #N1]
Commands
Page 114
Q - PRO 4 Commands
Function Summary
================
$ASC(data item) Returns the decimal for the ASCII data item
$ETOX(data item) Returns e raised to the data item power
$FIELD(data item) Returns the screen data field value given an offset
$INT(data item) Returns the integer
$LN(data item) Returns the natural log
$MEMEND() Returns the top of memory
$OFFSET(fieldname) Returns the offset of the named field
Commands
Page 115
Q - PRO 4 Commands
Command Summary
===============
ACCURACY Sets the number of decimal places of accuracy.
ADD Adds two numeric data items together.
ASEAR Searches a memory array.
BACKSPACE Backspaces the file one record.
BEGIN Denotes the beginning of the structured construct.
BELL Causes the audible alarm to sound.
BUFFER Changes the size of the keyboard keying buffer.
BROFF Disables PROC BREAK (if any).
BRON Enables PROC BREAK (if any).
CALC Calculates the value of an expression.
CALL Calls a subroutine.
CENTER Centers data in a string data item.
CHAIN Loads and executes another Q-PRO 4 program.
CLEAR Clears a data entry field.
CLOSE Closes a data file.
CONCAT Concatenates a set of string data items into one string data
item.
CURSOR Positions the cursor independently of the displayed form and
its fields.
CURRENCY Changes the currency symbol used in EDIT.
DEBUG For program debugging.
DEFSEG For 16 bit versions for PEEK, POKE and DEBUG.
DIV Divides one data item by another.
EDIT Formats numeric data items according to a picture of the
desired result.
ELSE Alternate branch for a structured function.
END Marks the end of a procedure or table.
ENDBEGIN Denotes the end of a structured function.
ENDFOR Terminate a FOR loop.
ERASE Removes a file from a diskette.
ERROR Displays error message on the bottom of the screen.
ERRTRAP Sets a label as an error branch, or clears such a label if
an error branch was previously set.
EXEC Runs a machine code routine.
FCOPY Copies a file.
FILETYPE Returns information about an open file.
FILL Makes field fill in unlocked screen fields any character
desired.
FOR Marks the beginning of a loop.
FORMLOAD Returns control to FB on fatal error or returning to system.
FREE Deletes a record from an indexed file.
FSEAR Searches a data file on a record-by-record basis for of any
Commands
Page 116
Q - PRO 4 Commands
logical condition.
GET Moves a data field from a file buffer.
GETDATE Loads the current system date.
GOTO Immediate jump to label or line number.
HELP Displays help screens created by the programmer.
HOFF Turns highlights off at the cursor position.
HON Turns the screen highlight on at cursor position.
HOME Homes the cursor.
HOMECLEAR Homes the cursor and clears all enterable fields.
HOST Establishes the host operating system.
IF Conditionally executes program statements.
INSTR Searches a string for a substring.
JDPACK Calculates a Julian date and moves it into a data item.
JDUNPACK Converts the previously created Julian date in a data item
to a calendar date.
LJUST Left justifies data.
KEY Changes the file current KEY.
LOAD Loads a machine code file into memory.
LOCK Makes an enterable screen data field not enterable.
LPDETACH Detaches the process from the system printer.
LRETRY Sets the retry count for header locking on LANs.
MAKE Creates a data file.
MEMEND Sets the high address in memory for QNE can use, normally
for use of machine language programs
MOVE Transfers data between data items.
MUL Multiplies two data items.
NCHECK Verifies that a string data item contains valid numeric
data.
NEXT Moves the cursor to a specified screen field.
NOFORMLOAD Resets indicator set by the FORMLOAD command.
NOTRACE Turns off TRACE mode.
OPEN Locates file on disk and readies it for I/O operations.
PEEK Loads data into a string from memory.
POKE Moves a string of data into memory.
POSN Positions a random or indexed file to a record.
PRINT Prints directly to the screen.
PRINTSCN Dumps the screen to the list device.
PROC Denotes the start of a procedure.
PUT Transfers data to a file buffer or printer.
RCLEAR Clears the record buffer, resets the pointer.
READ Used to access data records within a file.
RENAME Changes the name of a file.
RESET Clears a Boolean flag register.
RESTART Resets the file buffer or performs a form feed.
RESUME Return control to the operator for data entry.
RETURN Returns control to a CALL PROC.
Commands
Page 117
Q - PRO 4 Commands
RJUST Right justifies data.
RLOCK Locks the currently positioned record in the file.
ROUND Rounds a numeric quantity to some significant number of
digits.
RUN Executes another program directly from Q-PRO 4.
RUNLOCK Unlocks the currently locked record in the file.
SECURE Forces the update of an indexed file.
SET Sets a Boolean flag register.
SETDATE Sets the system date.
SIZE Computes the length of a string data item.
SUB Subtracts one data item from another.
SYSMODE General system command to change characteristic of backtab
and printer detection errors.
SYSTEM Gives control back to the operating system.
TABLE Denotes the start of a data table.
TRACE Places Q-PRO 4 in a single step debugging mode.
TSEAR Initiates the search of a table.
UCASE Forces a string data item to upper case.
UNEDIT Removes editing characters from a string field.
UNLOCK Unlocks a previously locked field.
VRBL Establishes in-memory variables.
WRITE Outputs a data record to a file.
Commands
Page 118
Q - PRO 4 Commands
F u n c t i o n s
=================
$ASC
----
The function $ASC returns the decimal value of the ASCII data item.
Syntax: $ASC(<ASCII data item>)
ASCII data item A literal in quotes, a string register or string
variable.
Examples: $ASC("3") returns 51
$ASC("A") returns 65
Commands
Page 119
Q - PRO 4 Commands
$ETOX
-----
The $ETOX function returns the value of the natural constant e raised to
the expression power. On 8 bit systems, MATHLIB must be loaded. (The
MATHLIB command is ignored on other systems.)
Syntax: $ETOX(<expression>)
expression An evaluatable mathematical expression.
Examples: CALC EPOWER = $ETOX(#N1)
CALC COMPLEX = $ETOX((#N1 + #N2}2) -1)
Commands
Page 120
Q - PRO 4 Commands
$FIELD
------
$FIELD is a function that returns the screen data field that corresponds to
the offset value. Its parameter is the number of the field to be
addressed. Using this function, the programmer may dynamically address and
manipulate data in screen data fields symbolically instead of by name.
Refer to the Programmer's Reference Manual and sample programs for more
detail and examples.
Syntax: $FIELD(<expression>)
expression Any mathematical expression that evaluates to an integer
without sign.
Examples: ADD $FIELD[#N1] TO SUM
Add the screen data field with the offset contained in
the numeric register #N1 to the screen data field (or
variable) SUM.
MOVE &FILE_FIELD[1,#N1] TO $FIELD[#N1 + (#N1 * 6)]
Move the #N1 element of the file data array FILE_FIELD
on file 1 to the screen data field whose offset is the
evaluation of the expression [#N1 + (#N1 * 6)].
Commands
Page 121
Q - PRO 4 Commands
$INT
----
$INT is a function that returns the integer portion of a real number.
Syntax: $INT(<numeric data item>)
numeric data item A literal number (without quotes), numeric register,
numeric variable, or numeric screen data field.
Examples: CALC #N1 =#N1 + $INT(#N2)
CALCulates and places in #N1 the current value of #N1
plus the integer portion of #N2.
CALC #N1 =$INT(5.05)
Result in #N1 is 5.
CALC #N1 =#N2-#N2 * $INT(#N2}#N1)
The result in #N1 is modulo #n1.
Commands
Page 122
Q - PRO 4 Commands
$LN
---
$LN is a function that returns the natural logarithm of the included
expression. $LN may be used in conjunction with ACCURACY to limit the
accuracy and decrease the execution time.
Syntax: $LN(<expression>)
expression A mathematically evaluatable set of terms and operators.
Example: CALC COMPLEX = $LN((#N1 + #N2) * #N3)
$MEMEND()
---------
The $MEMEND() function returns the current top of memory being used by
Q-PRO 4, its file buffers and keypool. Some of this memory, particularly
in the keypool area can be used by the programmer for assembly language
routines without impacting Q-PRO 4 or the remainder of memory. When Q-PRO
4 is loaded, the memory is laid out like this:
|-----Top of memory-----------|
| |
| This area is available |
| |
| |
|-298K (All that can be used)-|
| |
| |
|Q-PRO 4 Data area, up to 64K |
| |
|-----------------------------|
| |
| Application area, up to 64K |
| |
|-----------------------------|
| |
| Runtime Interpreter - 42K |
| |
|-----------------------------|
| |
| BTSYS - the file system |
| (requires 100K) |
|-----------------------------|
| Operating System |
| |
|------Bottom of Memory-------|
Commands
Page 123
Q - PRO 4 Commands
The command:
MEMEND $MEMEND() - 1024
produces this result
|-----Top of memory-----------|
| |
| 1024 bytes available for |
| assembly language program |
|-----------------------------|
| Memory available for key |
| pool. |
|-----------------------------|
|Q-PRO 4 Data area, up to 64K |
| |
|-----------------------------|
| |
| Application area, up to 64K |
| |
|-----------------------------|
| |
| Runtime Interpreter - 42K |
| |
|-----------------------------|
| |
| BTSYS - the file system |
| (requires 100K) |
|-----------------------------|
| Operating System |
| |
|------Bottom of Memory-------|
Use the MA command in DEBUG to find out the keypool size so you can
determine exactly how much memory the program requires.
Commands
Page 124
Q - PRO 4 Commands
$OFFSET
-------
The function $OFFSET returns the offset of the named screen data field.
Use of this function allows generalized code for symbolic screen data
manipulation relative to screen data fields.
Syntax: OFFSET<screen data field name>
screen data field name The name of the screen data field in quotes.
Examples: CALC #N1 = $OFFSET("DATE")
#N1 will contain the offset of the screen data
field DATE.
Note that: $OFFSET($FIELD[#F]) = #F
Commands
Page 125
Q - PRO 4 Commands
C O M M A N D S
===============
ACCURACY
--------
ACCURACY is used with ETOX, exponentiation and LN to set the degree of
accuracy that the calculations will be carried out. As all of these
routines are mathematically converging functions, by using this command,
execution will take only as long as required for the computation.
Syntax: ACCURACY(<numeric data item>)
numeric data item Any expression that evaluates to a whole number between
1 and 7.
Remarks The default is 7.
Examples:
ACCURACY(#n1)
ACCURACY(3)
Commands
Page 126
Q - PRO 4 Commands
ADD
---
The ADD command adds two numeric data items together and optionally places
the result in a third numeric data item. Optionally, the data items may be
preceded by minus sign (-). The results of an add (or any arithmetic
operation) may not be stored in a numeric constant. The receiving data
item must be a numeric data item. For example, ADD FLD1 TO 3 is invalid.
Syntax:
ADD <data item 1> TO <data item 2>{GIVING <data items><B>}
data item 1 A numeric data item such as a literal or numeric register.
An expression is not allowed.
data item 2 A numeric data item. An expression is not allowed. If the
GIVING modifier is not present, the sum of data item 1 and
data item 2 will be stored in data item 2 and data item two
must not be a literal.
data item 3 If present, the sum will be placed in this item. Therefore,
it must not be a variable.
Remarks GIVING is optional serving the purpose of defining a third
data item in which to place the sum. The keyword TO may be
replaced by a comma.
Examples:
ADD #N3 TO SUM
ADD .5, NUMB GIVING #N1
ADD 3 TO FLD1
ADD FLD1 TO 3 GIVING FLD1
Commands
Page 127
Q - PRO 4 Commands
ASEAR
-----
ASEAR searches a memory array by increasing element number (or optionally
by decreasing element number) for the value of an element that satisfies an
expression. If an element is found that satisfies the expression, the
element number will be returned. If not, the error path will be taken.
Syntax 1: ASEAR <name> {DOWN} USING <result> AT <expression>:error
name The name of the array to be searched
result The location to place the array element number if a match is
found.
expression The expression to evaluate the array element. All logical
expressions are valid.
REMARKS The optional DOWN keyword causes the command to searches the
array by decreasing number.
Example:
ASEAR MONTHS USING #N1 AT "JAN" = MONTHS[#N1]
Syntax 2: ASEAR <name> {DOWN} USING <index> <{STARTING expression2}>AT
<expression1>{:error}
array name The array to be searched.
{DOWN} Optionally searches the array from highest order element
number to lowest element number.
{index} On a match of the expression, this numeric data item will
contain the element number with the match.
expression1 The expression that the element must match to get a "hit".
expression2 The expression that defines the starting place for the
search--optional.
Remarks The use of this syntax allows searching an array (up or
down), and continuing the search after a match by modifying
the variable(s) in expression2 after a match.
Commands
Page 128
Q - PRO 4 Commands
BACKSPACE
---------
BACKSPACE positions a RANDOM or INDEXED file to the record previous to the
current position.
Syntax: BACKSPACE <file number> {:<B>error}
file number The file number as a literal, or numeric data item.
Remarks An end-of-file error is generated if the file is empty or
already positioned at the first record in the file.
Example:
(scan file 1 in reverse order, assuming already at file end)
1000 BACKSPACE 1 :1001
READ 1 NOADV
COPY * FROM 1
GOTO 1000
1001 ERROR "END OF FILE"
Commands
Page 129
Q - PRO 4 Commands
BEGIN
-----
BEGIN denotes the start of the structured construct. (ENDBEGIN denotes the
termination of the structured construct.) BEGINs may be nested and may
have any of the following modifiers.
Syntax: BEGIN {WHILE, UNTIL, IF}<logical condition>
WHILE Using this keyword, the statements within the BEGIN . . .
ENDBEGIN structure will be repetitively executed as long as
the logical condition is true.
UNTIL Using this keyword, the statements within the BEGIN . . .
ENDBEGIN structure will be repetitively executed as long as
the logical condition is <BI>not true.
IF When the IF keyword is used, the statements within the BEGIN
. . . ENDBEGIN structure will be executed once.
logical
condition A logically evaluatable expression.
Remarks BEGIN is allowed one modifier, either, IF, WHILE, or UNTIL.
A BEGIN construct with no modifier (WHILE, UNTIL, IF) must be ended with an
ENDBEGIN with a modifier of WHILE, UNTIL or IF.
BEGIN WHILE logical condition>i is the start of a structured construct that
will execute during the time that the conditional value is true. If the
condition remains true, the construct will execute forever.
Examples:
BEGIN WHILE A GT 0
SUB &VALUE(100) FROM A
READ 100
ENDBEGIN
This code will execute during the time that A is greater than 0. If A
is never greater than 0, the code will be ignored.
BEGIN UNTIL A EQ 10
ADD 1 TO A
ENDBEGIN
This code will continue executing as long as A is not equal to 10.
Commands
Page 130
Q - PRO 4 Commands
BEGIN IF A NEQ 0
CALL ZERO_ROUT
ENDBEGIN
This code will execute only if A is not equal to 0.
ELSE and ELSE IF
----------------
ELSE and ELSE IF are used only with the BEGIN IF construct. They provide
excellent conditional controls. The structure is:
BEGIN IF<condition 1>
statements executed only if condition 1 is true
ELSE IF<condition 2>
statements executed only if condition 2 is true
ELSE
statements executed if neither condition 1 nor
condition 2 is true.
ENDBEGIN
Examples:
BEGIN IF #N1 = 1
CALL SUB_ONE
CALL SUB_ONE_A
SET #B1
ELSE IF #N1 = 2
CALL SUB_TWO
CALL SUB_TWO_A
RESET #B1
ELSE
CALL MAIN_SUB
CALL MAIN_SUB_A
ENDBEGIN
If #N1 equals 1, call subroutines SUB_ONE and SUB_ONE_A and SET #B1.
If #N1 equals 2, call subroutines SUB_TWO and SUB_TWO_A and RESET #B1.
If #N1 does not equal 1 or two, call subroutines MAIN_SUB and
MAIN_SUB_A.
A variation of the BEGIN/ENDBEGIN pairing is putting the condition after
the ENDBEGIN.
Examples:
Commands
Page 131
Q - PRO 4 Commands
BEGIN
SUB 1 FROM A
ENDBEGIN WHILE A LT 100
BEGIN
ADD 1 TO A
ENDBEGIN UNTIL A GT #N1
Commands
Page 132
Q - PRO 4 Commands
BELL
----
The BELL command causes the audible alarm to sound (if supported by the
hardware).
Syntax: BELL
Commands
Page 133
Q - PRO 4 Commands
BUFFER
------
The BUFFER command changes the size of the keyboard buffer (used to buffer
up keystrokes while programming statements are being executed). The
default size of this buffer is 32 characters. It may be set to any size
between 0 and 255.
Setting the buffer to zero (0) will speed processing of files and screens.
However, when set to 0, the BREAK procedure, if used, will be disabled.
Also, the machine keyboard buffer, if there is one, is flushed when a
BUFFER statement is executed.
Syntax: BUFFER <numeric data item>
numeric data item A literal or other numeric data item.
Examples:
BUFFER 100
BUFFER #N0
Commands
Page 134
Q - PRO 4 Commands
BROFF
-----
BROFF disables the current PROC BREAK (if any).
Syntax: BROFF
Example:
BROFF
BRON
----
BRON enables the current PROC BREAK (if any).
Syntax: BRON
Example: BRON
Commands
Page 135
Q - PRO 4 Commands
CALC
----
CALC allows the computation of algebraic expressions in those circumstances
where the use of the ADD, SUB, MUL, or DIV commands would be clumsy.
Syntax: CALC<data item> = <expression>
data item The data item may be any valid numeric data item.
expression The expression is an algebraic expression which may contain
nested parentheses and uses the following operators and
functions:
+ = addition $LN $OFFSET
- = subtraction $ETOX $FIELD
* = multiplication $INT
/ = division
^ = exponentiation
Multiplication, division, and exponentiation have precedence over addition
and subtraction, unless overridden with parentheses. Exponentiation, $LN,
$ETOX, and $INT require MATHLIB to be loaded on 8 bit systems.
Examples:
CALC TOTAL = FLD1 + FLD2 + #INT(&FLD[1])
CALC $FIELD[#N0] = (ACCTBAL+5) } 3
CALC AVERAGE = (SUM1+SUM2+SUM3+SUM4+SUM5)}5
CALC SQUARE = NUM ^ 2
CALC COMPLEX=(((FLD1+3)}(FLD2*7))-#N[CUSTTYPE])+ 11.5
Commands
Page 136
Q - PRO 4 Commands
CALL
----
CALL invokes another procedure. Control is returned to the statement
following the CALL when the CALLed procedure executes a RETURN statement.
A maximum of 20 CALL and/or FOR statements may be nested.
Syntax: CALL <procedure>
procedure A procedure name. Any procedure may be CALLed. It is the
responsibility of the programmer to insure that the CALLed
procedure returns to the calling procedure. On RETURN, the
next sequential statement will be executed
The procedure may be replaced by an indexed table name (i.e.,
PROCTBL[#N3]). This allows a computed call facility, affording great
flexibility to the programmer. The table so referenced must consist of a
series of 1-item entries, each item being the name of a procedure. Each
item is referenced by its position in the table, starting with 0 as the
index of the first position.
Examples:
CALL ALPHA1
CALL PRCTABLE[#N1]
Commands
Page 137
Q - PRO 4 Commands
CENTER
------
The CENTER command centers data in a string data item. Centering will
occur even in fields defined as right or left justified.
Syntax: CENTER <data item>
Example: CENTER BANNER
Commands
Page 138
Q - PRO 4 Commands
CHAIN
-----
The CHAIN command brings in another segment of the application. It causes
the named format file to be loaded from disk, its associated screen to be
displayed, and processing to continue. The file name may be any valid
string data item. All register settings, open files and file buffers are
maintained across a chain statement, whereas variables are not.
Syntax: CHAIN <name> {:error}
filename The actual filename in quotes or a valid filename in a
string data item.
error Label to jump to if there is an error.
Remarks If a string data item is to be used, it is highly
recommended that it be moved to a string register trimmed as
shown in the code below. This will preclude trailing blanks
confusing the operating system.
MOVE VARIABLE TO #S0 TRIMMED
CHAIN #S0
Examples:
CHAIN "MENU2"
CHAIN #S0 :100
Commands
Page 139
Q - PRO 4 Commands
CLEAR
-----
The CLEAR command causes the contents of a screen data field to be cleared
to spaces.
Syntax: CLEAR <field or *>
field The literal name of the field or the result of a $FIELD
function.
* If the * option is used instead of a specific field name,
then all enterable, unlocked, and unduplicated fields on the
screen are cleared.
Examples:
CLEAR CUSTNO
CLEAR $FIELD[#F]
CLEAR *
Commands
Page 140
Q - PRO 4 Commands
CLOSE
-----
CLOSE causes a data file to be closed, and the directory for the disk on
which it resides to be updated. All files should be closed when no longer
needed. Q-PRO 4 will close any files left open before returning to the
operating system.
Syntax: CLOSE <file number> {:error}
file number The file number as a literal or symbolic data item.
error The label to jump to if there is an error.
Remarks If no file number is given, then the system will close
all open files, and reset the file control system (the
currently logged drive is preserved).
Examples:
CLOSE 1
CLOSE 99 :320
CLOSE
Commands
Page 141
Q - PRO 4 Commands
COMMENT
A COMMENT line is ignored by Q-PRO 4 and is intended to aid in the
self-documentation of programs. A comment line may be preceded by a line
number or label. Comments are not loaded at runtime.
Example:
* THIS IS A COMMENT
102: * THIS IS A COMMENT WITH A LABEL
Commands
Page 142
Q - PRO 4 Commands
CONCAT
------
CONCAT concatenates a set of string or numeric data items into one string
data item.
Syntax: CONCAT <string> {TRIMMED} + <string> {TRIMMED} INTO <string>
{TRIMMED}
string A literal string or string data item.
TRIMMED This operator truncates trailing spaces of the string data
item preceding it.
INTO The INTO keyword points to the string data item where the
concatenated will be placed. It may <BI>not be a literal,
however it may be one of the non-literal string data items
in the command.
Examples:
CONCAT #S1 TRIMMED + #S2 + #N3 INTO FIELD TRIMMED
CONCAT #S1 + ". " + &FIR[1] TRIMMED + " " + &LAS INTO #S2
Partial strings may be concatenated as shown below:
CONCAT #S1(1,4) + #S2(2,5) INTO #S1
This expression concatenates string register one from character
position 1 for four characters with string register two from
character position 2 for 5 characters into string register 1.
There must be data in the partial string concatenated.
Commands
Page 143
Q - PRO 4 Commands
COPY
----
COPY moves data from the screen to a indexed or random file, from the file
to the screen, or from a file to another file. There must be a FID file
for any data file used. COPY moves only fields with identical names in the
direction given.
Syntax: COPY <file # or *> <TO <file # or *> {:error}
file # The specific file number to COPY from or to.
* An asterisk (*) always refers to the screen whereas a number
or numeric data item always refers to a file number.
Remarks The programmer may take advantage of this feature with
selective naming of the screen data fields and the file data
fields.
If there is data in the I/O file buffer for the target of
the move which does not have the same name as those in the
record being moved, the old data will remain. Normally this
is not a problem. If you want the output buffer to be
pristine, use RCLEAR before the copy.
Examples:
COPY 1 TO *
Moves all file fields from the record for file # 1 to fields with
the same name on the screen.
COPY 1 TO 2
Moves file data fields with the same name from file # 1 to file #
2.
Commands
Page 144
Q - PRO 4 Commands
CURSOR
------
The CURSOR command positions the cursor independently of the displayed form
and its fields.
Syntax: CURSOR <row>,<column>
row A value or expression that evaluates from 0 to the number of
rows minus 1 (23 on most CRTs).
column The column is an expression that evaluates from 0 to the
number of columns minus 1 (79 on most CRTs).
Remarks The cursor position is maintained only until control is
returned to the operator. Then the cursor will move to the
next enterable field.
Example:
CURSOR 22, #N0+5
Commands
Page 145
Q - PRO 4 Commands
CURRENCY
--------
The CURRENCY command allows the user to change the currency symbol used in
the output of the EDIT statement (default is $). $ is still used as the
character in the edit picture to denote the placement of the currency
symbol.
Syntax: CURRENCY<symbol>
symbol may be any character string or string data item up to five
characters long. If it is omitted, the system reverts to
using $ as the output currency symbol.
Examples:
CURRENCY "DM"
CURRENCY
Commands
Page 146
Q - PRO 4 Commands
DEBUG
-----
The DEBUG command invokes the runtime debugger for program debugging. It
is usually invoked by a function key during program development. When
invoked, the following debug commands are available:
? Displays a list of commands on the screen.
DI Allows the user to display a single data item.
For example:
DI #S1 - Displays the contents of string register 1.
DI &FIELD[1]- Displays the contents of the file field
FIELD from file one.
(Any data item may be displayed. Boolean (Bit) registers many
not be displayed.)
SI Sets a new value for any data item.
For example:
SI #S0 = "ABC" - Places the string ABC in #S0.
SI #&FIELD[1] = 100 - Moves 100 into the file field.
DV Displays a list of defined memory variables on the screen.
DS Displays a list of screen fields on the screen.
DO Displays a list of open files on the screen.
DF Displays a list of fields for a particular file number on the screen.
For example:
DF 1 - Displays the fields for file 1.
DM Displays half a screen of memory starting at the given address.
For example:
DM 39284 - displays memory from 39284 decimal
DM H800 - displays memory from 800 hex
SM Sets memory to the value specified at the location specified.
For example:
SM 100=1,2,3 - Sets memory at decimal 100 to 1,
at decimal 101 to 2, and at decimal 102 to 3.
SM H100=H4F - Sets memory at Hex 100 to Hex 4F.
DB Display the settings of the Boolean (BIT) registers.
SB Set a Boolean register.
For example:
SB 1 - Sets register 1
RB Resets a Boolean register.
For example:
RB 1 - Resets register 1
EP Enables the printer. Any data printed on the screen will be echoed to
the printer.
DP Disables the printer. Data printed to the screen will go to the
screen only.
Commands
Page 147
Q - PRO 4 Commands
ET Enables trace.
DT Disables trace.
MA Display memory available for files and variables.
EX Exit Debug and return to the application program.
Remark On 16 bit systems, DM and SM are used in conjunction with the
command DEFSEG.
Example:
PROC KEY9
DEBUG
END
Commands
Page 148
Q - PRO 4 Commands
DEFSEG
DEFSEG is used on 16 bit versions in conjunction with PEEK's, POKE's and
DEBUG. Since the peek and poke commands only allow access to the 64K
runtime data area, DEFSEG is needed to set a new data segment.
Syntax: DEFSEG <expression>
expression must evaluate to a valid integer segment
Example:
DEFSEG 80
PEEK 1,1,prnscn_flg
Looks at the 'print screen in progress' flag on an IBM PC.
Commands
Page 149
Q - PRO 4 Commands
DIV
---
DIV divides one numeric data item by another and optionally places the
result in a third.
Syntax: DIV <data item 1> INTO <data item 2> {GIVING <data item 3>}
data item 1 A valid numeric data item which is the divisor.
INTO This verb points to the dividend. It must be a valid
numeric data item. If the answer or quotient is to be
stored here, it must <BI>not be a literal number.
GIVING Points the numeric data item where the result or quotient is
to be placed.
If the GIVING clause is not present, then the result is
stored in data item 2.
Remarks The keyword INTO may be replaced by a comma (,).
Refer to the Data Items section for legal types of data
items which may be used.
Examples:
DIV 2 INTO WHOLE GIVING HALF
DIV #N0,#N3
DIV COUNT,SUM GIVING AVG
Commands
Page 150
Q - PRO 4 Commands
EDIT
----
EDIT gives the capability to format numeric data items according to a
picture of the desired result. This picture uses descriptor characters to
control leading zeros, decimal point placement, etc.
Syntax: EDIT <data1> USING <picture> INTO <data2> {:<B>error}
data1 Must be a numeric expression.
picture The format picture is a string consisting of a meaningful
combination of the following characters:
"*" Specifies that leading zero fill is to be replaced by
leading '*' characters instead.
$ Specifies that the leftmost digit will be preceded by a
dollar sign.
- May be placed in leading or trailing position. Specifies
that if the number is negative, a sign will be inserted in
the designated position.
+ May be placed in leading or trailing position. Specifies
that the appropriate sign (+ or -) will be inserted in the
designated position.
Z Specifies that a digit is to be placed in this position in
the formatted output. Leading zeroes are suppressed.
9 Specifies that a digit is to be placed in this position.
Leading zeros are not suppressed.
. Specifies that a decimal point is to be placed in this
position.
, Specifies that a comma will be inserted in the output area
if the first non-zero digit occurs to the right of the
comma.
data2 Data item 2 may be a string field or register. If no
numerically invalid characters have been introduced as a
result of the editing process, data item 2 may also be
numeric. Refer to the UNEDIT command for removing
numerically invalid characters.
Examples:
EDIT 12.3 USING "9999.9" INTO #S0 = 0012.3
Commands
Page 151
Q - PRO 4 Commands
EDIT 234.98 USING "*$*ZZZ,*ZZZ.99" INTO #S1 = ***$234.98
EDIT 1234.98 USING "*$*ZZZ,*ZZZ.99" INTO #S1 = *$1,234.98
EDIT $FIELD[#N0] USING "999999.99" INTO $FIELD[#N0]
ELSE - ELSE IF
--------------
An ELSE or ELSE IF is a part of the BEGIN construct and is always
associated with a BEGIN IF. A BEGIN may have any number of IF or ELSE IF
statements associated with it. See BEGIN.
Examples:
BEGIN IF #N1 GT 100
SUB 1 FROM #N2
ELSE IF #N1 LT 100
ADD 1 TO #N2
ELSE
MOVE 0 TO #N2
ENDBEGIN
Commands
Page 152
Q - PRO 4 Commands
END
---
END marks the end of a procedure or table. It should be treated as any
other executable statement, as the examples will show. When the END
statement in a procedure is encountered, control is turned over to the
operator in the next enterable field for data entry.
Syntax: END
Examples:
PROC NOTHING
END
PROC VERIFY0
IF FLD1 EQ 0 THEN END
ERROR "SHOULD HAVE BEEN 0"
END
TABLE STATES
"PA", "Pennsylvania"
"TX", "Texas"
"NJ", "New Jersey"
END
Commands
Page 153
Q - PRO 4 Commands
ENDBEGIN
--------
ENDBEGIN denotes the end of the structured construct. It may have any of
the following modifiers:
Syntax: ENDBEGIN
ENDBEGIN WHILE
ENDBEGIN UNTIL
Commands
Page 154
Q - PRO 4 Commands
ENDFOR
------
ENDFOR terminates a FOR loop. When the ENDFOR statement is executed, the
loop variable is incremented (or decremented, if the loop increment is
negative) and then tested for exceeding the ending value of the loop.
Syntax: ENDFOR <loop variable>
loop variable The same loop variable that began the FOR loop.
Remarks If the ending value is not exceeded, then control
transfers back to the start of the loop (the next
statement after the corresponding FOR statement). Note
that the program may exit FOR-ENDFOR loops prematurely
via GOTO statements. CALL-RETURN and FOR-ENDFOR
management takes care of any aborted loops.
Examples:
FOR #N0 = 1 TO 100
ENDFOR #N0
FOR COUNTER = 1 TO 100
ENDFOR COUNTER
Commands
Page 155
Q - PRO 4 Commands
ERASE
-----
ERASE removes a file from a disk.
Syntax: ERASE <file name> {:<error}
filename The file name may be any string literal, field, or register.
Examples:
ERASE "TEMP.$$$" :10
ERASE #S0
ERASE "B:OLDFILE.DAT"
Commands
Page 156
Q - PRO 4 Commands
ERROR
-----
The ERROR command displays an error message on the last line of the screen
in a format compatible with system-generated error messages (for invalid
keystrokes, etc.).
Syntax: ERROR <message>
message The message may be any data item.
Examples:
ERROR "FILE NOT FOUND"
ERROR #S1
ERROR "UNAUTHORIZED USER"
Commands
Page 157
Q - PRO 4 Commands
ERRTRAP
-------
The ERRTRAP command sets a label as an error branch, or clears such a label
if an error branch was previously set. (Refer to Programmer's Reference
Manual for sample coding and a complete discussion.)
Syntax: ERRTRAP <label>
label Any label, numeric or alphanumeric.
Remarks If the label is not given, then any previous ERRTRAP set is
cleared.
Examples:
ERRTRAP 100
ERRTRAP
Commands
Page 158
Q - PRO 4 Commands
EXEC
----
EXEC causes the execution of a machine code routine that has been loaded
into memory.
Syntax: EXEC <address>, <input string> {<,output string>} {<:<BI>error}
address The memory address at which to begin execution
input string A required string of data to be passed to the assembly
language routine.
output string An optional string for or returned data
Remarks The use of this and other machine code interface commands
presupposes that the programmer knows what he/she/it is
doing, since a call to an invalid address can clearly blow
the system away.
Commands
Page 159
Q - PRO 4 Commands
FCOPY
------
FCOPY copies a file. No wild cards are allowed.
Syntax: FCOPY <filename1> TO <filename2> {<:error}
filename1 The name of the file to be copied expressed as a literal, or
string data item.
TO The pointer to the file to be copied to. A comma may be
substituted for the TO.
filename2 The name of the file to be copied to expressed as a literal.
Remarks No wild cards are allowed. If the destination file exists,
it will be overwritten.
Commands
Page 160
Q - PRO 4 Commands
FILETYPE
--------
FILETYPE returns information about open files.
Syntax: FILETYPE<fileno>
fileno The file number as expressed as a literal or numeric data
item.
Remarks FILETYPE returns the information as shown below:
Indexed Files Random Files
#N0 - File type File type
#N1 - Number of keys Record length
#N2 - Current Key
#N3 - Record length
Another use of FILETYPE is to determine if a file is open or closed. If
the error path is taken, the file is not open.
Examples:
FILETYPE 1
FILETYPE #N6 :100
FILETYPE 1
KEY 1 USING 2
POSN 1 TO KEY RELATIVE
READ 1
COPY 1 TO *
KEY 1 USING #N2
This code fragment illustrates changing keys and reverting to the
original key which will be in #N2.
Commands
Page 161
Q - PRO 4 Commands
FILL
----
The FILL command causes unentered field fill in unlocked fields to be
changed from the default character (space) to any character desired.
Syntax: FILL <string data item>
string data item A literal or string data item.
Remarks The FILL command affects the screen display only. The
data, as seen by the program, is unchanged. The value
for FILL will remain in effect across chains. Normally
this command is used in PROC LOAD.
Examples:
FILL "."
FILL #S8
Commands
Page 162
Q - PRO 4 Commands
FOR
---
FOR is the beginning of a control loop which increments or decrements a
field, numeric variable or numeric register from a given starting value to
a given ending value, with any given increment.
Syntax: FOR <loop variable> = <start> TO <end> {BY <increment>}
loop variable Any numeric register, numeric variable, numeric screen data
field, or numeric file data field.
start Initial value of the loop variable. It may be any valid
numeric data item.
TO Range pointer.
end The ending value of the loop variable. It may be any valid
numeric data item.
BY Points to the increment.
increment Value to add to the initial value on each iteration of the
loop. It must be a valid numeric data item and may be
negative.
Remarks If the BY phrase is not given, then 1 is the assumed
increment. The increment may be positive (in which case the
loop variable increases in value from start to end), or
negative (in which case the loop variable decreases in value
from start to end). The loop variable must be a register or
field; the start, end, and increment values may be any valid
numeric expression. FOR loops may be nested; however, the
total of nested CALLs and FORs may not exceed 20.
FOR loops are terminated by an ENDFOR statement, which must contain the
name of the FOR loop variable whose loop is being terminated.
Examples:
FOR #N0 = 1 TO 20 BY 5
.
.
ENDFOR #N0
FOR COUNT = (#N0+1)}5 TO -10 BY INCR*3
.
.
ENDFOR COUNT
Commands
Page 163
Q - PRO 4 Commands
FORMLOAD
--------
FORMLOAD sets an internal flag, so that on a future exit to the operating
system command level for any reason, the format builder program (FB) is
executed and the current application program is loaded ready for editing.
This provides a convenient feature during debugging when transitions
between the format builder module and the runtime module are frequent. It
is normally the first statement in PROC LOAD.
Syntax: FORMLOAD
Remarks This flag will stay on until reset by NOFORMLOAD, even
through CHAIN operations.
Commands
Page 164
Q - PRO 4 Commands
FREE
----
FREE deletes a key from an indexed file and effectively deletes the record.
Syntax: FREE <file number> {:<error>}
file number The file number expressed as a valid numeric data item.
error Label to branch to if the FREE fails.
Remarks Deleted records will remain in the file with a deleted
record flag until a new record is added.
The key must have been previously accessed via POSN and
READ statements.
Example:
POSN 1 TO #S0
READ 1
FREE 1
Commands
Page 165
Q - PRO 4 Commands
FSEAR
-----
FSEAR is used to search a data file on a record-by-record basis for the
satisfaction of any logical condition.
Syntax 1: FSEAR <file #> {NOADV} AT <condition> {:error}
file # The file number of the file to be searched.
NOADV If NOADV , the file is left positioned at the record which
it was loaded.
AT Points to the search condition.
Condition Any condition which is valid in an IF statement is valid for
FSEAR.
Remarks The file is searched, starting at the current position in
the file. Searching will stop when either the condition is
true, or end of file. If the condition is found, the record
for which the condition was true will be loaded, and the
file left positioned at the next record in the file.
Searching begins at the current file position. For indexed
files, the search sequence is the current file key. If no
match is found, then an end-of-file error is caused.
Examples:
FSEAR 1 NOADV AT &CUSTNO[1] > 100 :99
FSEAR 3 AT &TYPE[3] = TYPE AND &INV[3] GEQ &INV[2] :100
Syntax 2: FSEAR <file #> {NOADV} USING <string data item>:error
NOADV Do not advance the file after a match.
USING The keyword to denote a dynamic search argument.
string data item A string register, string field, or string variable
that contains the search condition.
Examples:
A file is to be searched for a match on a last name input by a user
from the screen. The screen data field name is NAME and the file data
field name is LAST. The code looks like this:
MOVE "NAME = &LAST[1]" TO #S0
FSEAR 1 USING #S0:100
The file is searched sequentially until the condition NAME = &LAST[1]
is met. Then the next sequential instruction will be executed. On no
match, the next record will be read and tested; if end of file then
Commands
Page 166
Q - PRO 4 Commands
control will pass to line number 100. Remember, when using this
command, strings must match exactly for a match and the FSEAR command
will begin searching at the current file position.
Commands
Page 167
Q - PRO 4 Commands
GET
---
GET moves a data field from a file buffer to a register or screen field.
Syntax: GET <data name or *> FROM <file number> <B>FOR <length> {TRIMMED}
{:error}
data name or * This may be a register or field.
If the data name is an asterisk (*), then all
enterable, unlocked fields on the screen are filled
from the current position in the file buffer, in the
order they appear on the screen, starting with the
first unprotected field on the screen.
file number The file number must represent an open file.
TRIMMED If the keyword TRIMMED is present, then trailing spaces
are removed from the data as it is transferred from the
file buffer to the data item. This is invalid in the
GET * usage of the statement.
Remarks It is not used when the movement from file buffer is
done with FID names or the COPY command. With FID
names use the MOVE command.
Note that for sequential files, the normal sequence of
statements is to issue GET's until the end of a record,
and then issue a READ to bypass the carriage
return/line feed sequence which marks the end of a
sequential record. For random and indexed files issue a
READ first, followed by GETs to extract the data from
the file buffer. Each GET issued advances the file
buffer pointer by the length of the GET.
Examples:
GET #N0 FROM 1 FOR 5 :4444
GET CUSTNAME FROM 12 FOR 60 TRIMMED
GET * FROM 1
Commands
Page 168
Q - PRO 4 Commands
GETDATE
-------
GETDATE loads an alphanumeric data item with the current system date.
(Refer also to SETDATE.)
Syntax: GETDATE <string data item>
string data item Any valid string data item except a literal.
Remarks The format of the retrieved date is MM/DD/YYYY
hh:mm:ss, where:
MM = MONTH hh = hours
DD = DAY mm = minutes
YYYY = YEAR ss = seconds
Example:
GETDATE #S0
Commands
Page 169
Q - PRO 4 Commands
GOTO
----
GOTO alters the sequential flow of command execution by forcing an
immediate jump to the program location marked by a numeric or alphanumeric
label.
Syntax: GOTO <label or line number>
label or line number A valid label or line number.
Remarks Instead of an actual label being given, the
program may instead give a table name and index.
Here, the destination of the GOTO is chosen as the
corresponding element of the table. The table
used must consist of a series of 1-item lines,
each item being a label. The first item in the
table is zero (0). See also discussion in
Programmer's Reference Manual.
Examples:
GOTO 100
GOTO DEM_LABEL
GOTO LABTBL[#N0]
Commands
Page 170
Q - PRO 4 Commands
HELP
----
The HELP command allows an unlimited number of help screens to be displayed
by an application.
Help screens are normal QNE format files built by FB, without enterable
fields or PROCs (fields and PROCs will be ignored in help screens in any
case).
Syntax: HELP <screen> {,<screen>,<screen>. . .}{:error}
screen The name of the help screen may be a literal in quotes, or a
valid string data item.
Remarks When the first help screen is displayed, the operator may
either press ESCAPE (in which case no more screens are
displayed), or any other key (in which case the next screen
is displayed). After the last screen, any key will restore
the data entry screen in its original form. The error
branch will be taken if a help screen cannot be found.
Examples:
HELP "B:HELP1","B:HELP2",#S1:123
IF #F EQ 10 HELP "B:FID.HLP"
Commands
Page 171
Q - PRO 4 Commands
HOFF
----
Syntax: HOFF
For the use of HOFF, see HON below.
Commands
Page 172
Q - PRO 4 Commands
HON
---
HON turns the screen highlight on at the current cursor position.
Syntax: HON
Remarks If highlights are not defined for this hardware, a blank
will be printed. (This is the same as having a highlight
character placed on the screen in the background.) HOFF
will turn the highlight off. Note that different screens
will react differently depending on how the highlights are
implemented in hardware.
Examples:
For example, suppose that you want to highlight a message on the
screen which will read "YOU FOOL" at screen position row 2, line 10.
The following will always highlight it:
CURSOR 2,9
HON
PRINT "YOU FOOL"
CURSOR 2, 19
HOFF
Be careful with this instruction if you use a variety of hardware.
Note that the highlight character requires a screen position. Data
previously printed in this location will not be restored.
Commands
Page 173
Q - PRO 4 Commands
HOME
----
HOME moves the cursor to the first enterable field on the screen and
returns control to the operator for data entry.
Syntax: HOME
Remarks No more statements in the current procedure will be
executed. If HOME is executed in PROC ENTER, the fields
will not be cleared.
Commands
Page 174
Q - PRO 4 Commands
HOMECLEAR
---------
HOMECLEAR moves the cursor to the first enterable field on the screen and
clears all enterable fields. As in the HOME command, control is then
returned to the operator for data entry.
Syntax: HOMECLEAR
Commands
Page 175
Q - PRO 4 Commands
HOST
----
The HOST command establishes the host operating system. No files may be
open when this command is given. A HOST statement takes precedence over
the setting of the host bit in SETUP. Refer to the Programmer's Reference
Manual for hosts supported.
Syntax: HOST <string data item>
Examples:
HOST "NETWARE"
HOST #S1
HOSTS available. (See READ.ME for changes.)
OS or LAN HOST
--------- ----
IBM Network or PC-MOS IBMNET or MSNET
PC or MS-DOS PC-DOS or SINGLE
NetWare (Novell) NETWARE
Commands
Page 176
Q - PRO 4 Commands
IF
--
IF allows the conditional execution of program statements.
Syntax: IF <condition> {AND/OR <condition>} {THEN} <statement>
condition A condition is the comparison of two data items of like type
(i.e., either both are numeric or both are string) in the
format <data item 1> <operation> <data item 2> using the
following conditional operators:
EQ or = test for item 1 equal to item 2
NEQ or <> test for item 1 not equal to item 2
LT or < test for item 1 less than item 2
LE or <= test for item 1 less than or equal to item 2
GT or > test for item 1 greater than item 2
GE or >= test for item 1 greater than or equal to item 2
NLT test for item 1 not less than item 2
NLE test for item 1 not less than or equal to item2
NGT test for item 1 not greater than item 2
NGE test for item 1 not greater than or equal to item 2
~ condition negation operator
AND/OR
------
Multiple conditions may be joined by AND and OR operators, although
these are evaluated from left to right without relative precedence.
Conditions may be nested with parentheses for complex logical
evaluations.
THEN
----
The keyword THEN, used for readability, is optional.
Remarks Any executable statement may be performed as a result of an
IF statement, including (for example) an END or another IF
statement.
Examples:
IF CUSTNO EQ 0 THEN ERROR "INVALID NUMBER"
IF #B0 SET THEN CALL SUB_ROUT1
IF TYPE EQ "A" OR TYPE EQ "F" THEN MOVE 0 TO #N0
IF #N0 > #N1 THEN MOVE "OVERFLOW" TO STATUS
IF JOBNAME = "ZZZZZZ" GOTO 100
IF TYPE EQ "A" OR TYPE EQ "B" OR TYPE EQ "C" CLEAR STAT
IF KEY EQ 0 AND NAME EQ "" OR CUSTNO NLT 1000 GOTO 2090
Commands
Page 177
Q - PRO 4 Commands
IF MONTH <= 12 AND MONTH >= 1 THEN END
IF (MON GT 5 AND DAY LT 1) AND MOON EQ "BLUE" THEN END
IF ~A=B THEN GOTO NOT_EQUAL
IF #B0 SET GOTO 100
IF #B9 RESET IF STATUS NEQ "OPEN" MOVE "CLOSED" TO MSG
IF #B2 SET ON #B3 SET ON #B4 RESET HOMECLEAR
IF #B[#N4] RESET CALL READREC
Commands
Page 178
Q - PRO 4 Commands
INSTR
-----
INSTR searches a string for a substring match.
Syntax: INSTR <substring> {TRIMMED}, <string> {TRIMMED}, <result>
substring Substring to be searched for in the string.
TRIMMED Do not use trailing blanks in the substring for the match.
string String to be searched.
TRIMMED Do not use trailing blanks in the string to be searched for
the match.
result A numeric data item to place the result of the search. If
there is a match, <result> will contain the first position
of the match in the searched string. If no match, its value
will be 0.
Example:
INSTR "ABC", &FIELD[1] TRIMMED, #N0
Looks for the string "ABC" in the file field FIELD, TRIMMED. If
found, place the location of the string in #N0. If not found
place a 0 in #N0.
Commands
Page 179
Q - PRO 4 Commands
JDPACK
------
JDPACK calculates a Julian date and moves it into a data item.
Syntax: JDPACK <date string> INTO <data item>
date string The date string must be of the form MM/DD/YYYY.
data item Any numeric data item except a literal.
Remarks The base date is December 31, 1977. Therefore January
1, 1978 will JDPACK to 1 and December 30, 1977 will
JDPACK to -1. Refer to JDUNPACK for converting Julian
dates to calendar dates.
Example
JDPACK "04/25/1984" INTO #N1
Commands
Page 180
Q - PRO 4 Commands
JDUNPACK
--------
JDUNPACK converts the previously created Julian date in a data item to a
calendar date.
Syntax: JDUNPACK <data item1> INTO <data item2>
data item1 A previously packed Julian date.
data item2 The destination data item must be a string.
Remarks Refer to JDPACK for generating the Julian date in a
data item.
Example:
JDUNPACK #N1 INTO #S0
Commands
Page 181
Q - PRO 4 Commands
KEY
---
KEY changes the current ISAM file KEY.
Syntax: KEY <file #> <B>USING <key #>
file # The file number expressed as a literal or numeric data item.
key # The key number from 0 to 9, expressed as a literal or
numeric data item.
Remarks Key 1 is the primary key and must be unique, but the
alternates (2-9) may be duplicates. Duplicates will be in
primary key order. For example, a record has two keys, NAME
and ZIP_CODE, and there are 3 records, MIKE 19438, JOHN
19438, and LARRY 19454. Reading the file in primary key
order the records will be in the sequence: JOHN 19438,
LARRY 19454 and MIKE 19438. Reading in the second key order
the record will be in the sequence: JOHN 19438, MIKE 19438,
and LARRY 19454. Refer to POSN for the method of changing
the key using POSN.
Key 0 puts the file in physical order.
Example:
KEY 1 USING 3
KEY #N1 USING #N3
Commands
Page 182
Q - PRO 4 Commands
LJUST
-----
LJUST left justifies data in a data item.
Syntax: LJUST <data item>
data item Any data item.
Remarks Left justification will occur even in fields defined as
right justified.
Example:
LJUST AMOUNT
LJUST #S3
Commands
Page 183
Q - PRO 4 Commands
LOAD
----
The LOAD command loads a machine code file into memory at the indicated
address.
Syntax: LOAD <file name>, <address> {:error}
file name The name of the file to be loaded as a literal in quotes or
as a string data item.
address The address at which to load the machine language program.
Remarks The error branch is taken if the file cannot be opened.
Otherwise, the file is loaded into memory. The responsi-
bility of making sure the file fits in memory is the
programmer's. Refer to the Techniques Chapter for more
details.
Example:
LOAD "ROUTINES.COM", 48532 :897
Commands
Page 184
Q - PRO 4 Commands
LOCK
----
LOCK makes a normally enterable screen data field unavailable to the
operator. The operator may not enter the field until a corresponding
UNLOCK statement is executed.
Syntax: LOCK<screen data field name>
screen data field name A valid screen data field name.
Remarks Locked fields will not be accessed in GET * or PUT
* statements.
Example:
LOCK CUSTNO
LOCK $FIELD[#N8]
Commands
Page 185
Q - PRO 4 Commands
LPDETACH
--------
LPDETACH detaches the current user from the multiuser or LAN system printer
or terminates the current spool file depending on the operating system.
This allows access to the printer by other users.
Syntax: LPDETACH
Remarks Failure to use this command when printing from Q-PRO 4 (not
the Report Generator) on some operating systems will lock
the print spooler until a system reset. Operating systems
that do not use the command will ignore it.
Commands
Page 186
Q - PRO 4 Commands
LRETRY
------
LRETRY sets the retry count for header record locking on multiuser systems.
Syntax: LRETRY <numeric data item>
numeric data item Any numeric data item.
Remarks It is usually used in PROC LOAD.
Example:
LRETRY 100
Commands
Page 187
Q - PRO 4 Commands
MAKE
----
MAKE deletes a file from the directory of a diskette (if it previously
existed), and then creates it as directed by the parameters to the
statement. At creation a file number is assigned. When the file is
created, it is immediately ready for use.
In all formats, the file name may be a string literal or string data item.
The error branch is taken if the system is unable to create the file (e.g.,
write-protected or full disk). (Refer to the Programmer's Reference Manual
for a full discussion of files.) The statement may take one of four forms.
Syntax 1: (Indexed and Random files)
MAKE <filename> USING <FID filena> {INDEX <INDEX filena>}, <file num>
{:error}
filename The name of the file as a literal in quotes or a string data
item.
USING Points to the FID file name.
FID file name The name of the FID file as a literal in quotes or a string
data item.
INDEX Points to the index file (indexed files only). This phrase
is optional. If omitted, an index file will be created that
is the same name as the FID file with the extension IDX.
INDEX file na The name of the INDEX file as a literal in quotes or a
string data item.
file number A literal or numeric data item. Until closed or deleted,
the file will be referred to by this file number.
Remarks The FID (file item description file created by the FID
generator program) determines if the file is random or
indexed. All additional information (file type, record
size, key size and location, etc.) is derived from
information in the FID file.
Examples:
MAKE "C:NEWDATA" USING "NEWDATA.FID", 1 :654
MAKE #S0 USING #S1 INDEX #S3, #N1: 100
Syntax 2: (Sequential Files)
MAKE <filename>, <file type>, <file number> {<:error>}
filename The name of the file as a literal in quotes or a string data
item.
Commands
Page 188
Q - PRO 4 Commands
filetype The type of sequential (text) file. The file types are:
0 sequential output
1 sequential input
4 SDF (comma delimited) output
5 SDF (comma delimited) input
file number A literal or numeric data item. Until closed or deleted,
the file will be referred to by this file number.
Examples:
MAKE "B:TEMP.$$$",1,1 :100
LAN and Multiuser System Optional KEYWORD
-----------------------------------------
MAKE has an optional keyword after the file number, UNLOCKED. If
UNLOCKED is not used, a file is created in the locked mode.
Examples:
MAKE "FILE" USING "FIDFILE",1 UNLOCKED :100
Commands
Page 189
Q - PRO 4 Commands
MEMEND
MEMEND establishes the highest address in memory that Q-PRO 4 can use,
presumably because machine language programs will be loaded at higher
addresses.
Syntax:
MEMEND <address in decimal {:<error>}
address in decimal The address to be set.
Remarks If the system would be left with insufficient
memory after changing the highest address used,
the error trap is taken with an Out2 OF MEMORY
error.
No particular restrictions apply to open files or
declared variables when MEMEND is invoked.
Example:
MEMEND 49152
Commands
Page 190
Q - PRO 4 Commands
MOVE
----
The MOVE command is used to transfer data between data items. Modifiers to
the basic command provide powerful mechanisms for handling substrings, and
concatenating data items.Data between Data Items
Syntax:
MOVE <dataitem1> {<string source modifier>} TO <dataitem2> {<string
destination modifier>} {TRIMMED}
dataitem1 The data items may be numeric or string literals, or
any string data item (data item 2 may not be a
literal). MOVEing a string to a numeric data item is
acceptable if the string contains only numerically
acceptable data.
string source
modifier The string source modifier provides a way to extract
substrings from a string data item. The source data
item must be a string to use a modifier. The format of
the source modifier is:
[start position,length or *]
The start position may range from 1 to the length
of the string. The length may not exceed the
length of the string. An asterisk (*) may be
substituted for the length of the string, in which
case the right-hand portion of the string from the
starting position on is taken.
string destination modifier
The string destination modifier allows the
placement of substrings within strings, or the
concatenation of strings. The format of the
destination modifier is:
[start position or *]
The source string is moved to the start position
of the destination string. If an asterisk is
used, the source string is appended to the
destination string.
Commands
Page 191
Q - PRO 4 Commands
TRIMMED If the keyword TRIMMED is used, trailing spaces are
eliminated from the source string.
Examples:
Simple Moves
------------
MOVE A TO B
Moves field (or variable) "A" to field (or variable) "B".
MOVE 0 TO #N0
Moves the number zero (0) to numeric register 0, and clears it.
MOVE "PLEASE ENTER A VALID ID CODE" TO STATUSMSG
Moves "PLEASE ENTER A VALID ID CODE" to the field (or variable)
STATUSMSG.
Partial Moves
-------------
MOVE " " TO #S0[3]
Moves 5 blanks to string register 0 beginning in position 3.
MOVE NAME[1,10] TO FNAME
Moves characters 1 through 10 in the field (or variable) NAME to
the field (or variable) FNAME.
MOVE #S0[#N0,FLDLEN] TO #S1[*]
Moves the contents of string register 0 from the number in
numeric register 0 for the length contained in FLDLEN.
Move with Trimming
------------------
MOVE #S3 TO #S3 TRIMMED
Move #S3 to itself removing trailing blanks.
MOVE $FIELD[#N0][1,20] TO #S[#N1][*] TRIMMED
Moves a screen field with the offset contained in #N0 starting in
position 1 for 20 characters to a string register whose number is
contained in #N1. The asterisk indicates that the previous data
in the string register will be left intact and the new data will
be concatenated. The data moved will have trailing blanks
dropped.
Commands
Page 192
Q - PRO 4 Commands
Concatenation (attach one string data item to another)
-------------
MOVE #S0 TO #S1[*]
Concatenates the contents of #S0 to the current contents of #S1.
MOVE #S0 TO #S1[*] TRIMMED
Truncates any trailing spaces in #S0 and then concatenates the
contents of #S0 to the current contents of #S1.
Commands
Page 193
Q - PRO 4 Commands
MUL
---
MUL multiplies two data items and optionally places the result in a third.
Syntax: MUL <data item 1> TIMES <data item 2>{GIVING <data item 3>}
data item 1 The multiplier must be a valid numeric data item.
data item 2 The multiplicand must be a valid numeric data item.
Remarks If the GIVING clause is not present, then the result is
stored in data item 2. Optionally, the keyword TIMES
may be replaced with a comma.
Examples:
MUL 1.5 TIMES REGPAY GIVING OTPAY
MUL FACTOR , BASE
Commands
Page 194
Q - PRO 4 Commands
NCHECK
------
The NCHECK statement will verify that a string data item contains only
numeric data; i.e. no commas, dollar signs, or other trash.
Syntax: NCHECK <data item> {<:error>}
data item the string data item to be checked.
error The error branch is taken if the data item is not numeric.
Note that a field of all spaces is considered numerically
valid (0).
Examples:
NCHECK $FIELD[#N0+3] :100
NCHECK CUSTNUM[CUSTTYPE] :1023
Commands
Page 195
Q - PRO 4 Commands
NEXT
----
The NEXT statement moves the cursor to a specified field and returns
control to the operator for data entry.
Syntax: NEXT <field name or *>
field name or * The name of the screen data field in quotes or a $FIELD
expression. If the asterisk is used, the cursor will
move to the next sequential unlocked field.
Remarks It is the programmer's responsibility to insure that
NEXT does not jump control to a non-enterable screen
data field. A NEXT command with no field specified
will move the cursor to the next enterable unlocked
field.
Examples:
NEXT ALPHA
NEXT $FIELD[#N1]
NEXT *
NEXT
Commands
Page 196
Q - PRO 4 Commands
NOFORMLOAD
----------
NOFORMLOAD turns off the indicator set by the FORMLOAD command. This means
that after the NOFORMLOAD command is executed, a later return to the
operating system will not cause the execution of the format builder
utility.
Syntax: NOFORMLOAD
Commands
Page 197
Q - PRO 4 Commands
NOTRACE
-------
NOTRACE turns off the TRACE mode used for single-stepping through program
statements. Refer to the TRACE statement for an explanation of this mode.
Syntax: NOTRACE
Commands
Page 198
Q - PRO 4 Commands
OPEN
----
OPEN locates a pre-existing file on disk and readies the file for I/O
operations.
Syntax 1: (Random and Indexed Files)
OPEN <filena> USING <FID filena> {INDEX <index filena>},<file num> {:error}
filena The path and name of the file to be opened. This may be a
literal or valid string data item.
USING Points the FID file to be used to open the file.
FID filena The path and name of the FID file (file item description
file created by the FID generator program). When the file
was created, the FID determined if the file was to be random
or indexed. All additional information (file type, record
size, key size and location, etc.) is derived from
information in the FID file.
INDEX If this phrase is used, the user must specifically designate
the INDEX file name and path. If it is not used, the INDEX
file will be understood to be the same as the FID file with
the extension IDX.
file num The number that the file will be know by henceforth.
Examples:
OPEN "C:NEWDATA" USING "NEWDATA.FID", 1 :654
Syntax 2: (Sequential Files)
OPEN <filena>, <file type>, <file num> {<:error>}
filena The name of the file as a literal in quotes or a string data
item.
filetype The type of sequential (text) file. The file types are:
0 sequential output
1 sequential input
4 SDF (comma delimited) output
5 SDF (comma delimited) input
file num A literal or numeric data item. Until closed or deleted,
the file will be referred to by this file number.
Examples:
OPEN "B:TEMP.$$$",1,1 :100
Commands
Page 199
Q - PRO 4 Commands
Multiuser Optional Keywords
---------------------------
OPEN has two optional keywords after the file number, UNLOCKED and R/O
(read/only). By default, a file is opened as read/write and locked.
These keywords may be in any order and need not appear together.
Examples:
OPEN FILE USING FIDFILE,1 UNLOCKED R/O :100
OPEN #S0,2,128,5 UNLOCKED
Commands
Page 200
Q - PRO 4 Commands
PEEK
----
PEEK loads data into a string from memory.
Syntax: PEEK <decimal address>, <length>, <string>
decimal address Address to PEEK
length The length must be less than 256 characters. On 16 bit
systems PEEK may be used in conjunction with DEFSEG.
string String data item to place the data in.
Examples:
PEEK 49012, 6, #S0
PEEK #N1,#N2,WHAT
Commands
Page 201
Q - PRO 4 Commands
POKE
----
POKE moves a string of data into memory.
Syntax: POKE <decimal address>, <string>
decimal address Address to POKE. On 16 bit systems POKE may be used in
conjunction with DEFSEG.
string String data item which contains the data.
Examples:
POKE 50234, &DESC[#N0]
POKE #N1, #S1
Commands
Page 202
Q - PRO 4 Commands
POSN
----
POSN is used to access an indexed file by its key or a random file by its
record number.
Syntax 1:
POSN <file number> TO <record number/key> {RELATIVE} {:error}
file number The file number must be an open random or indexed file.
record number/key If the file is a random file, then it must be
positioned to a numeric record number (i.e., numeric
data item). If the file is indexed, then it must be
positioned to a string value (literal or string data
item). Remember: keys in indexed files are ASCII
strings. If the string is not the same length as the
defined key field of the file, then it is padded out to
the right for key search purposes. Similarly, if the
string is longer than the key field, it is truncated on
the right.
RELATIVE If the key is not found and the keyword RELATIVE is
given, then an indexed file is left positioned at the
next key higher than the one given. Otherwise, the
file is left positioned at the end.
error No error is generated if the position requested is in-
valid (i.e., off the end of the file, or the given key
does not exist.) Such an error would be detected at the
time of the following read or write statement.
Errors generated by this statement pertain to the
validity of the type of key given for the file type
(e.g., a string key for a random file).
Remarks For indexed files, the POSN statement need not be used
to arrive at a specific key for a write statement, as
the key to be written is implicit in the data record.
Such a POSN statement is automatically done before an
indexed write.
Examples:
POSN 1 TO 5 :100
POSN 3 TO "*SYSTEM*" RELATIVE
POSN 1 TO #N0
POSN 99 TO RECNO
Commands
Page 203
Q - PRO 4 Commands
POSN, with the optional modifier, USING, will also change the current key.
Syntax 2: (Change keys and position)
POSN <file number> TO <key> {USING <key #> {:error}
Remarks Identical in function to POSN with the added capability of
changing the current key of an indexed file.
Examples:
POSN 1 TO &KEY[2] USING #N2
Commands
Page 204
Q - PRO 4 Commands
PRINT
-----
PRINT allows the program to issue data directly to the screen at the
current cursor position.
It is most often used in conjunction with CURSOR.
Syntax: PRINT <value> {, <value>, <value> . . .}
value A value may be any numeric or string data item. Numeric
values are issued to the screen as ASCII strings (use @ to
generate control codes). For example, if the sequence ESC
(decimal 27) followed by ")" turns on an unconfigured
highlight, and ESC "(" turns it off, we could place a
highlighted message at the top of the screen as follows:
CURSOR 0,0
PRINT @27,')','THIS IS A TEST',@27,'('
Remarks The data displayed via the PRINT command will not be sent to
the printer via the PRINTSCN command. Data displayed with
the PRINT command on the screen will not be restored after a
HELP or DEBUG command is executed.
Commands
Page 205
Q - PRO 4 Commands
PRINTSCN
--------
PRINTSCN dumps the current contents of the screen to the list device
exactly as seen on the screen.
Syntax: PRINTSCN
Commands
Page 206
Q - PRO 4 Commands
PROC
----
The PROC statement, although not an executable statement as such, is an
important part of the command structure. Its presence in a program denotes
the start of a procedure.
Syntax:
PROC <procedure name>
procedure name This must be a literal that is not in quotes. All
naming conventions apply. See Programmer's Reference
Guide for more detail.
Examples:
PROC ERROR
PROC CUSTNOP
Commands
Page 207
Q - PRO 4 Commands
PUT
---
PUT transfers a data item to a file buffer or printer buffer for later
output to the file or printer.
Syntax: PUT <data item or *> TO <file number> {FOR <length>} {:error}
data item or * Any data item may be used. If the data item is an
asterisk (*), then all enterable, unlocked fields on
the screen are moved to the file buffer, in the order
they appear on the screen, starting with the first
unprotected field on the screen. The FOR clause is not
used here.
TO Points to the file number designator
file number A valid open file. Using a file number of 0 denotes
that the output is to be sent to the system list
device, instead of a disk file.
FOR If the FOR clause is not given, then the data is output
for the full number of character positions it currently
occupies. The FOR clause may be used to place blank
padding on the right, or to truncate the data item, as
appropriate.
Remarks PUT is not used when FID file data is being used. A
special type of data item may be used to output control
characters to the file. An at sign (@) denotes that
the following literal value is a control character to
be output. This is useful when building files to be
later transmitted to a remote computer, or when using
special features of a printer.
For SDF files, all fields are output enclosed within
quotes and separated by commas.
Examples:
PUT PRODNUM TO 1
PUT @09 TO 0
PUT " " TO 0 FOR 10
PUT #S0 TO 5 :1000
Commands
Page 208
Q - PRO 4 Commands
RCLEAR
------
RCLEAR clears the record buffer to spaces and resets the buffer pointer.
Syntax: RCLEAR <file number>
file number The file number of an open indexed or random file.
Remarks This command is not used with sequential files.
Commands
Page 209
Q - PRO 4 Commands
READ
----
The READ command is used to access data records within a file.
Syntax: READ <file number> {NOADV} {:error}
file number If the file number pertains to a sequential input file,
then the file is advanced until a carriage return/line
feed sequence is bypassed. The file is positioned at
the start of a new record, ready for GET statements.
For random or indexed files, the file buffer is loaded
with a new record, the fields of which can then be
accessed by referring to FID fields or with GET
statements.
NOADV If the NOADV keyword is given, the file is remains
positioned at the same record just read. Otherwise,
the file position is incremented to point to the next
record in the file (applies to random and indexed files
only). Using NOADV whenever possible will provide
optimal record access time.
error Errors are generated if there is an attempt to go past
the end of a file, or to access a record with a
non-existent key.
Examples:
READ 3 :1000
READ 5 NOADV
RENAME
------
RENAME changes the name of a file.
Syntax: RENAME <old file name>, <new file name> {:error}
old file name The name of the file to be renamed.
new file name The new file name.
error An error occurs if the old file name is non-existent,
or if the new file name already exists.
Remarks The renamed file MUST NOT be open at the time of
renaming.
Examples:
RENAME "B:TEMP.DAT","MASTER.DAT"
Commands
Page 210
Q - PRO 4 Commands
RENAME #S0,$FIELD[#N9] :1013
RESET
-----
RESET clears a Boolean flag register. Refer to the IF statement for the
use of Boolean registers in conditional statements.
Syntax: RESET <flag register>
flag register Any of the Boolean or flag registers from #B0 to #B9.
Example:
RESET #B4
Commands
Page 211
Q - PRO 4 Commands
RESTART
-------
RESTART places the file buffer pointer (moved across a file buffer by
repeated GET or PUT statements) to an arbitrary position within a file
buffer (does not apply to sequential files).
Syntax: RESTART <file number> {TO <position>} {:error}
file number The number of the file to be restarted. If the file
number is 0, then a form feed is issued to the list
device, and the position value (if any) is used to
space down the next page. The page number register
(#P) is incremented, and the line number register (#L)
is set to the number of lines skipped on the new page
(default 0).
position The position within the record to move the pointer to.
Remarks The default value for pointer placement (taken when the
TO phrase is not given) is the start of the file
buffer.
Examples:
RESTART 0
RESTART 1 TO 25
RESTART 89
Commands
Page 212
Q - PRO 4 Commands
RESUME
------
RESUME gives control back to the operator in the current screen data field.
Syntax: RESUME
Commands
Page 213
Q - PRO 4 Commands
RETURN
------
RETURN gives programmatic control back to a calling procedure. Each RETURN
executed must be matched by a previous CALL statement. It is possible,
however, to exit from a FOR/ENDFOR loop to return to a calling statement
(by executing a RETURN) with no ill effects.
Syntax: RETURN
Examples:
IF #N1 = 5 RETURN
RETURN
Commands
Page 214
Q - PRO 4 Commands
RJUST
-----
RJUST right justifies data in any data item.
Syntax: RJUST <data item>
data item The data item in which data is to be right justified.
Example:
RJUST #S1
Commands
Page 215
Q - PRO 4 Commands
RLOCK
-----
On LANs and multiuser systems RLOCK marks the data record where the file is
currently positioned as being locked.
Syntax: RLOCK <file number> {:error}
file number The file number of the record to be locked.
error If the record is marked as locked, presumably by
another user using the RLOCK command, a branch will be
taken to the error label.
Remarks The record locked is the one currently being pointed to
by the file pointer. Thus these two command sequences
are the same:
POSN 1 TO #S0 POSN 1 TO #S0
RLOCK 1:LOCKED READ 1 NOADV
READ 1 RLOCK 1:LOCKED
At NO TIME is the record physically locked. As it is
always available to the programmer, it is up to the
programmer to take the appropriate action for the
application. RLOCK is ignored by operating systems
that are not multiuser. RLOCK is always used in
conjunction with RUNLOCK.
If a record is locked in a file, another RLOCK command
will unlock the previously locked record as well as
lock the current record. Refer to the Programmer's
Reference Manual for more detail.
Example
RLOCK 1: 100
RLOCK #N1:100
Commands
Page 216
Q - PRO 4 Commands
ROUND
-----
ROUND is used to round a numeric quantity to some significant number of
digits.
Syntax: ROUND <data item 1> BY <size> INTO <data item 2>
data item 1 Data item 1 (which must be numeric) will be rounded off
to the indicated number of significant fractional
digits.
data item 2 The result will be placed into data item 2.
Example:
ROUND #N0 BY 2 INTO AVERAGE
ROUND SUM BY SIGNIF INTO SUM
Commands
Page 217
Q - PRO 4 Commands
RUN
---
The RUN command executes another program directly from Q-PRO 4, and
(normally) returns to the same format file when the loaded program is done.
Syntax: RUN <program name> USING <parameter string> {NORETURN} {NOPAUSE}
{RELOAD <name>} {:error}
program name The program named may be a literal or string data item
containing the name of any valid program.
parameter string The parameter string is a literal or string data item
which contains whatever parameters the program would be
given if executed from the system command level. If
there is NO PARAMETER to be passed, then a null
argument should be used.
Remarks RUN permits the re-execution of Q-PRO 4 automatically.
As control is turned over to another executable
program, any working values that the current Q-PRO4
application program was using (such as registers,
variables, etc) will be lost. Files are automatically
closed.
Keywords
--------
NORETURN Q-PRO 4 is not re-executed upon completion of the
loaded program.
NOPAUSE Control will return to Q-PRO 4 without operator
intervention.
RELOAD<file> Control will go to the named Q-PRO 4 filename.
Examples:
RUN "WORDSTAR.EXE" USING "LETTERS.DAT"
RUN "PIP.COM" USING "B:OLD=B:NEW" NORETURN
RUN "REPORT.CMD" USING #S1
RUN "\COMMAND.COM" USING "/C COPY \DATA\CUSTOMER.DAT
\BACKUP\CUSTOMER.DAT" RELOAD "MENU.QNE"
RUN "WORDSTAR.EXE" USING ""
Commands
Page 218
Q - PRO 4 Commands
RUNLOCK
-------
On a LAN or multiuser operating system RUNLOCK unlocks the record currently
marked as locked for a file.
Syntax: RUNLOCK <file number> {:error}
file number The file number, a literal or string data item, which
is to have the record unlocked.
Remarks RUNLOCK is ignored if there is no locked record.
RUNLOCK is always used in conjunction with RLOCK.
Example:
RUNLOCK 1100
Commands
Page 219
Q - PRO 4 Commands
SECURE
------
Use of SECURE in conjunction with WRITE or FREE will guard against loss of
data because of power loss, etc.
The price of safety is extra time spent updating the file (one sector read,
one sector written) and updating the system directory for the disk on which
the file is located.
Syntax: SECURE <file number> {:error}
file number The file number to be secured.
Remarks SECURE has no effect on sequential or random files.
Example:
SECURE 1
SECURE #N[FILENO]SET
SET
---
SET sets or turns on a Boolean or flag register.
Syntax: SET <Boolean register>
Boolean register The register number from #B0 to #B9.
Remarks Refer to the IF statement for the use of Boolean
registers in conditional statements.
Example:
SET #B0
SET #B9
Commands
Page 220
Q - PRO 4 Commands
SETDATE
-------
SETDATE sets the system date.
Syntax: SETDATE <date string>
date string The date to set the system to as a literal or valid
string data item of the format:
MM/DD/YYYY hh:mm:ss
MM = MONTH hh = hours
DD = DAY mm = minutes
YYYY = YEAR ss = seconds
Remarks On PCDOS and MSDOS this will set the system date. On
all others, the date will be stored in a system
register for later use. The register will be preserved
across CHAINs (BUT NOT RUNs). A literal or string data
item may be used. Refer also to GETDATE.
Examples:
SETDATE "08/31/1987 11:23:45"
SETDATE #S1
SIZE
----
SIZE computes the length of a string data item.
Syntax: SIZE <data item 1> INTO <data item 2> {TRIMMED}
data item 1 Data item 1 is the string register, field, or variable
to be sized.
data item 2 Data item 2 is the numeric register, field, or variable
into which the size should be placed.
Remarks Note that unlike string registers, fields and variables
will always give the same result unless the TRIMMED
form is used to drop trailing spaces, since by nature
fields and variables are of fixed length.
Example:
SIZE #S0 INTO #N0
SIZE APPLE INTO WATERMELON TRIMMED
Commands
Page 221
Q - PRO 4 Commands
SUB
---
SUB subtracts one numeric data item from another and, optionally, leaves
the result in a third.
Syntax: SUB <dataitem1> FROM <dataitem2> {GIVING <dataitem3>}
dataitem1 The number or numeric data item to be subtracted.
dataitem2 The numeric data item to be subtracted from.
GIVING If the GIVING clause is not present, then the result is
stored in data item 2.
Remarks The keyword FROM may be replaced by a comma.
Example:
SUB 5 FROM RESULT GIVING NEWRES
SUB 1 FROM COUNT
SUB #N0 FROM #N1 GIVING #N2
Commands
Page 222
Q - PRO 4 Commands
SYSMODE
-------
SYSMODE is a system initiating command. It has two modifiers:
Syntax 1: SYSMODE BTAB <SET or RESET>
SET SYSMODE BTAB SET specifies that a proc in a screen data
field that the cursor is backtabbed out of is always
executed.
RESET SYSMODE BTAB RESET specifies that a proc is not executed if
there is no data (default mode) in the screen data field and
the cursor is backtabbed out of it.
Examples:
SYSMODE BTAB SET
SYSMODE BTAB RESET
Syntax 2: SYSMODE LPCHK <SET or RESET>
SET On LPCHK SET the system level list device error, not the
Q-PRO 4 generated error, will be displayed on the screen on
a list device error. This is very useful if you are
redirecting the output to a device other than the parallel
printer, so that Q-PRO 4 will not check the status. If you
don't have LPCHK SET and go to the serial printer, Q-PRO 4
may report the printer not ready.
RESET On LPCHK RESET, the Q-PRO 4 error will be displayed. This
is the default mode.
Remarks A single SYSMODE statement can use either BTAB or LPCHK but
not both. LPCHK is used for DOS and MS-DOS only.Use
separate SYSMODE statements for each one.
Commands
Page 223
Q - PRO 4 Commands
SYSTEM
------
The SYSTEM command returns control to the operating system.
Syntax: SYSTEM
Remarks If the FORMLOAD flag was set, control will then be passed to
the format builder utility.
Example:
SYSTEM
Commands
Page 224
Q - PRO 4 Commands
TABLE
-----
The TABLE statement denotes the start of a data table.
Syntax: TABLE <table name>
table name The name of table as a literal without quotes.
Remarks See the Programmer's Reference Manual for more detail on
handling tables.
Example:
TABLE STATES
"PA"
"NJ"
"NY"
"DE"
END
TABLE CUSTTYPE
0, "DEADBEAT"
1, "OEM"
2, "DIST."
3, "RETAILER"
END
TABLE PROCS
PROCA
PROCB
PROCC
END
TABLE LABELS
100
200
300
END
Commands
Page 225
Q - PRO 4 Commands
TRACE
-----
The runtime execution of a program may monitored by executing the TRACE
command.
Syntax: TRACE
Remarks Trace places the system into a "debugging" mode. In
this mode, each statement is displayed on the last line
of the screen just before its execution. When the user
presses the ESC key, the statement is executed. This
allows the user to single-step through sections of
code.
Trace mode is turned off by the NOTRACE statement or by
pressing the RETURN key instead of the ESC key. When
TRACE is on, pressing "D" instead of ESC will invoke
DEBUG after the execution of the instruction displayed
on the screen.
Commands
Page 226
Q - PRO 4 Commands
TSEAR
-----
The TSEAR command allows the search of a table and, optionally, the
extraction of data from the table once a if a match for the search argument
is found in the first column of the table.
Syntax: TSEAR <table name> AT <key> {,<data item list>} {:error}
table name The name of the table to be searched.
key The data item which will be compared to the first
element of each line of the table for an exact match.
To achieve a match, the types of the two keys must be
compatible (string-string or numeric-numeric). If a
match is not found after the first element of every
line is compared, the error branch is taken.
data item list If a match is found, then an item by item data trans-
ferral occurs from the data on the rest of the table
line.
Remarks The TSEAR command can also be used without the data
item list simply to verify the acceptability of an
entry for special codes, etc. Note that a table used
for indexed procedures or labels cannot be used for the
TSEAR command, since they do not contain a key for
searching. Refer to Programmer's Reference Manual for
a more complete discussion of table usage.
Examples:
TSEAR CODETBL AT USERCODE,USERTYPE :100
Searches the table CODETBL with the argument in the field (or
variable) USERCODE. If there is a match in the first column of
the table and USERCODE, the next element of the table will be
placed in the field (or variable) USERTYPE. If there is no match
in the first column of the table with the contents of USERCODE,
control goes to 100.
TSEAR TRANTBL AT TRANCODE :1023
Commands
Page 227
Q - PRO 4 Commands
UCASE
-----
UCASE forces a string data item to upper case.
Syntax: UCASE <data item>
data item This must be a string data item.
Example:
UCASE #S5
UCASE NAME
Commands
Page 228
Q - PRO 4 Commands
UNEDIT
------
UNEDIT removes editing characters from a string field such as dollar sign
($) and comma (,) which usually have been placed there by the EDIT command.
Syntax: UNEDIT <string data item> INTO <data item>
string data item The string data item to be UNEDITed.
data item Where the UNEDITED data will be placed.
Example:
UNEDIT FIELD INTO #N1
Commands
Page 229
Q - PRO 4 Commands
UNLOCK
------
The UNLOCK command unlocks a previously locked field, and makes it
available for operator entry again.
Syntax: UNLOCK <screen data field name or *>
screen data field or * The name of the screen data field to unlock or a
$FIELD function. If * is used instead of a
specific screen field name, all locked fields are
unlocked.
Examples:
UNLOCK DATE
UNLOCK *
Commands
Page 230
Q - PRO 4 Commands
VRBL
----
The VRBL statement establishes in-memory variables which can be used in
exactly the same manner as screen fields, except that as their value
changes, no change is made to the screen display.
Syntax: VRBL <name>, <type>, <length> {,<dimension>}
name Any alphanumeric data item conforming to the Q-PRO 4 naming
conventions. The name must not already be in use for
another variable or field.
type Must be an X (for string) or N (for numeric). Note that
both types of variables are stored in ASCII format, enabling
both string and numeric types of operations on numeric
variables, depending on the statement involved.
length From 1 to 255 characters long for string variables, and from
1 to 20 for numeric variables.
dimension Specifies how many elements of <length> size will be
established. The default dimension is 1. The given
dimension may be from 1 to 65,000.
Remarks Undimensioned variables are referenced exactly like fields,
that is, directly by name. Dimensioned variables are
referenced by name and element number within brackets. The
element number may be any numeric expression from 0 to the
number of elements minus 1.
The ideal place to declare variables is in PROC LOAD, since
variables must be declared, may only be declared once, and
are not retained across a CHAIN operation.
Examples:
VRBL PETE, X, 10
10-character string
VRBL FIVE , N, 5, 20
20 element array of 5-character numerics
VRBL I, N, 4
VRBL SARY, X, 80, 12
.
FOR I=0 TO 11
MOVE "" TO SARY[I]
ENDFOR I
Clear the contents of a string array, using a variable as a loop
Commands
Page 231
Q - PRO 4 Commands
counter.
WRITE
-----
WRITE outputs a data record to a file or issues a carriage return line feed
to the printer.
Syntax: WRITE <file number> {NOADV} {:error}
file number The file number of the record to be written.
NOADV If the NOADV keyword is given (for random and indexed
files only), the record position in the file is not
advanced. Otherwise, the record positioned is advanced
to the next position in the file. Using NOADV whenever
possible will provide optimal record access time.
Actions of WRITE With Various File Types
----------------------------------------
Sequential files
A data record is written and terminated by a carriage return/line
feed sequence.
Random files
The record is written to the current position of the file.
Indexed files
The record is written to the position defined by the key of the
record. A POSN command before an indexed file write is therefore
both unnecessary and wasteful.
List device
If the file number is 0, then a carriage return/line feed
sequence is output to the list device. The line number register
(#L) will then be incremented automatically.
Examples:
WRITE 0
WRITE 1 NOADV :122
Commands
Page 232
Q - PRO 4 Commands
Q - P R O 4 E R R O R M E S S A G E S
========================================
Trappable Errors
================
#N0 Value Message
--------- --------
1 BAD DATA IN FIELD
2 BAD SIGNED RESULT
3 BAD OPERAND
4 ARITHMETIC OVERFLOW
5 NO TABLE MATCH
6 FILE UNAVAILABLE
7 FILE NOT OPEN
8 BUFFER OVERFLOW
9 OUTPUT FILE ONLY
10 END OF RECORD
11 END OF FILE
12 INPUT FILE ONLY
13 BAD DEST. START
14 BAD REC POSN
15 BAD INDEXED FILE
16 NO SUCH FILE
17 BAD FORMAT DESCRIPTOR
18 NO DATA IN BUFFER
19 BAD FILE NAME
20 DISK IO ERROR
21 NO FID FILE
22 BAD FID FILE
23 BAD FID ITEM INDEX
24 MEMORY OVERFLOW ON MEMEND
25 FILE EXCLUSION LOCK FAILED
26 FILE SYNCH. FAILURE
27 BAD HOST STATEMENT
28 FILE READ ONLY
29 EXEC ERROR
30 LINE PRINTER ERROR (16 bit only)
31 MATHLIB (8 bit only)
33 FILE SYSTEM NOT LOADED
34 DELETED RECORD READ
Error Messages
Page 233
Q - PRO 4 Commands
Error Codes for #E
------------------
Error numbers found in #E under DOS are interpreted as follows:
#E Value Message
-------- -----------
1 data file open
2 data file creation error
3 data file read error
4 data file write error
5 data close error
6 FID file open
7 FID file read error
8 FID file wrong version
9 Out of memory
10 Index file error
11 Error during handle reuse
12 error during file system initialization
13 data file less than the minimum length (8 characters)
14 Unable to unlock record
15 (reserved)
16 Maximum indices exceeded (100 allowed)
17 Not enough handles
18 Activity tried on inactive file.
100 End of file
101 (Reserved)
102 Illegal function on file (deleting a random record)
103 Deleting a record before a read
104 (Reserved)
105 File read only
106 Bad host value
107 Record locked
108 Header busy (try again)
109 Deleted record read
110 Bad key description list
Error Messages
Page 234
Q - PRO 4 Commands
Cross Reference of Trappable Errors
===================================
#N0 #E
Value Error Value
---------------------------------------
6 File unavailable 1,2
11 End of file 100
18 No data in buffer 103
21 No FID file 6
22 Bad FID file 7,8
24 Memory overflow 9
25 File exclusion lock 107, 108
27 Bad host statement 106
8 File read only 105
34 Deleted record read 109
20 All other disk I/O errors 3
BTSYS Errors
============
These errors are reported as "C-Tree" errors.
Error Number Description
231 A data file index is so corrupted that the file handler
cannot proceed any further. The only recover is using
QMAINT to recover the file.
230 This is a different error with the same cause and
solution as the one above.
Error Messages
Page 235
Q - PRO 4 Commands
Error Message Descriptions
==========================
The following is a complete list of error messages generated by the Q-PRO 4
system (in programs FB and QNE). Certain of the error messages generated by
the run-time system (QNE) are either recoverable by the operator (by
pressing ESCAPE), or are programmatically trappable. Otherwise, all
run-time errors are fatal.
, EXPECTED
Statement syntax requires a comma.
= EXPECTED
Statement syntax required an equals sign, and there was none.
" EXPECTED
Statement contains unbalanced quotes.
] EXPECTED
Statement contains unbalanced brackets.
[ EXPECTED
Statement syntax requires a left bracket, and none was found.
ARITHMETIC OVERFLOW
Attempt made to perform invalid calculation (such as divide by zero).
Trappable globally as error 4.
AT EXPECTED
Statement syntax requires the keyword "at".
BAD BUFFER SIZE
An invalid value (greater than 255) as given as the keyboard buffer size in
a BUFFER statement.
BAD COMMAND STRING
An invalid command string was given in a SYSTEM command.
BAD CONDITION
Unrecognizable condition in IF statement, or attempted to compare a number
to a string.
BAD DATA IN FIELD
Non-numeric data exists in field (usually put there programmatically).
Trappable globally as error 1.
Error Messages
Page 236
Q - PRO 4 Commands
BAD DEST. START
Program attempted a partial move from past the end of a string. Trappable
globally as error 13.
BAD EXPRESSION
Statement contained an invalid arithmetic expression.
BAD FID FILE
An invalid file was attempted for use as a fid file.
BAD FID ITEM INDEX
An out-of-range value was given for a fid field index.
BAD FIELD FILL
Numeric calculation not possible with a numeric field whose fill character
is other that a blank or a digit.
BAD FILE FORMAT
Locked file format was not correct.
BAD FILE NAME
Program attempted to OPEN or MAKE a file with an invalid given name.
Trappable locally in OPEN and MAKE. Trappable globally as error 19.
BAD FILE NUMBER
Program attempted to OPEN or MAKE a file with a number less than 1 or
greater than 255.
BAD FILE TYPE
Program attempted to OPEN or MAKE a file with a type not in the range 0-5.
BAD FLAG REGISTER REFERENCE
Flag register reference expected.
BAD FORMAT DESCRIPTOR
Program attempted to EDIT a numeric data item with an invalid descriptor.
Trappable locally in EDIT. Trappable globally as error 17.
BAD FUNCTION KEY
Undefined or non-numeric function (escape) key sequence was pressed.
Recoverable.
BAD HOST STATEMENT
A host statement was executed which either did not have a recognizable name
or at a time when all files were not closed. Trappable as error 27.
Error Messages
Page 237
Q - PRO 4 Commands
BAD INDEXED
Program attempted to OPEN a file with an invalid internal format as an
indexed file. Trappable locally in OPEN. Trappable globally as error 15.
BAD INDEX LENGTH
Program attempted to MAKE a file whose index length takes the key out of
the first 128 bytes of the data record.
BAD INDEX START
Program attempted to MAKE a file whose index start was greater than 128.
BAD KEYSTROKE IN FIELD
Operator keyed an invalid character for the field type. Recoverable.
BAD MODIFIER
Invalid string starting position in MOVE modifier.
BAD OPERAND
Program attempted to store into an invalid data item. Trappable globally as
error 3.
BAD PROC FORMAT
Illegal PROC statement.
BAD PROC NAME IN FILE
Program contains an invalid or missing procedure reference.
BAD REC POSN
Invalid value given for a record number. Trappable locally in POSN.
Trappable globally as error 14.
BAD REC SIZE
Record size may not be 0.
BAD REGISTER
Program attempted to do a modified MOVE from a numeric register.
BAD SIGNED RESULT
Program attempted to put a negative number in a digit (D descriptor )
field. Trappable globally as error 2.
BAD STATEMENT
Statement is unrecognizable.
Error Messages
Page 238
Q - PRO 4 Commands
BAD TABLE NAME IN FILE
Program contains an invalid or missing table reference.
BAD VRBL DECL
Variable declaration contains an invalid parameter.
BAD VRBL INDEX
Index to a variable array exceeded the maximum value.
BUFFER OVERFLOW
Program attempted to move a file buffer pointer past the end of the file
buffer. Trappable locally in PUT. Trappable globally as error 8.
BY EXPECTED
Statement syntax requires the keyword "by".
DEMO SYSTEM LIMITS EXCEEDED
Program attempted to exceed limitations of the evaluation version of the
system.
DISK IO ERROR
A hardware fault was returned by the operating system after a disk opera-
tion. Trappable locally in any file statement. Trappable globally as
error 20.
DUPLICATE FIELD NAME
Field name has already been assigned.
END OF FILE
Program attempted to read past the end of a file. Trappable locally in GET
(for sequential files) and READ (for random/indexed files). Trappable
globally as error 11.
END OF RECORD
Program attempted to GET past the end of a record. Trappable locally in
GET. Trappable globally as error 10.
EXEC ERROR
The programmer has POPPED the normal return from the stack and issued a
RETURN. Trappable globally as error 29.
ENDFOR WITHOUT FOR
An ENDFOR statement was detected for which there was no corresponding FOR
statement.
FIELD OUT OF SCREEN RANGE
Error Messages
Page 239
Q - PRO 4 Commands
Given field length would exceed screen boundary.
FIELD UNAVAILABLE
Program attempted to NEXT to a non-enterable field.
FILE EXCLUSION LOCK FAILED
System tried to lock record 0 of an indexed file. (required for most file
operations) and could not get the lock. Trappable as error 25.
FILE LIMITS OVERRUN
An attempt was made to add data to a file already occupying the operating
system maximum megabytes of data.
FILE NOT OPEN
Program failed to OPEN or MAKE file before first I/O reference. Trappable
locally in any file statement. Trappable globally as error 7.
FILE OPEN
Program attempted to OPEN or MAKE a file using an already active file
number.
FILE READ ONLY
Tried to write to a read only file. Trappable as error 28.
FILE SYNCH. FAILURE
Files are said to be out of synch when one process reads a record with
apparently valid index links, which is then discovered to have been deleted
by some other process. Trappable as error 26.
FILE UNAVAILABLE
File does not exist. Trappable locally in OPEN. Trappable globally as error
6.
FOR EXPECTED
Statement syntax requires the keyword "FOR".
FORMAT LOAD OVERRUN
The format file indicated will not fit in memory.
FORMAT CREATE ERROR
The format file can not be created due to disk error or filled directory.
FORMAT MEMORY OVERFLOW
No room left in memory for a new field definition.
FORMAT WRITE ERROR
The format file cannot be saved on disk (I/O error or full disk).
Error Messages
Page 240
Q - PRO 4 Commands
FROM EXPECTED
Statement syntax requires the keyword "from".
INCONSISTENT "MAY ENTER" ENTER">
The given MAY ENTER value does not agree with the given MUST ENTER value
(if MUST ENTER is Y, then MAY ENTER must be Y as well).
INPUT FILE ONLY
Program attempted to write to an input sequential file. Trappable locally
in PUT or WRITE. Trappable globally as error 12.
INTO EXPECTED
Statement syntax requires the keyword "into".
INVALID DESCRIPTOR TYPE
Field descriptor was an invalid character.
INVALID FIELD LENGTH
The given field length was zero, or non-numeric.
INVALID FIELD NAME
A field name must be maximum ten alphanumeric characters, starting with an
alphabetic.
INVALID FILE NAME
Indicated file name does not obey system rules for an unambiguous file
name.
INVALID "JUSTIFY"
The value for the justification field must be L or R.
INVALID PARAGRAPH NUMBER
A non-numeric paragraph number was requested.
INVALID "MAY ENTER"
The value for the may-enter field must be Y or N.
INVALID "MUST ENTER"
The value for the must-enter field must be Y or N.
INVALID "MUST FILL"
The value for the must-fill field must be Y or N.
INVALID "MUST TAB"
The value for the must-tab field must be Y or N.
Error Messages
Page 241
Q - PRO 4 Commands
INVALID PROCEDURE NAME
A procedure name must be a maximum of ten alphanumeric characters, starting
with an alphabetic.
INVALID SELECTION
A non-existent or non-numeric selection was made from the main menu.
INVALID X COORDINATE
Given row coordinate is non-numeric, or exceeds the length of the screen.
INVALID Y COORDINATE
Given column coordinate is non-numeric, or exceeds the width of the screen.
LINE PRINTER ERROR
Printer not ready. Trappable globally as error 30.
MATHLIB NOT LOADED
(8 bit only) Attempted to use $LN, $ETOX, $INT, or exponentiation without
MATHLIB loaded. Trappable globally as error 31.
MEMORY OVERFLOW
Format file will not fit in available memory, or there is no space to open
a new file, or no space to allocate a new variable, or expression required
too much temporary storage to execute.
MISSING FILE NAME
Statement syntax requires a file name.
MUST ENTER FIELD
Operator attempted to exit a field without entering any data. Recoverable.
MUST FILL FIELD
Operator attempted to exit a field without filling it. Recoverable.
NEW FILE
The given file name does not exist; it will be created at file save time.
NO DATA IN BUFFER
Program attempted to delete an indexed record without first loading the
record. Trappable locally in FREE. Trappable globally as error 18.
NO ENTERABLE FIELDS
Format file contains no enterable fields.
NO FILE
Attempted to initially load a non-existent format file.
NO FORMAT DEFINED
Error Messages
Page 242
Q - PRO 4 Commands
The indicated menu selection requires the previous selection of main menu
choice N.
NO FID FILE
A fid file was named in an OPEN or MAKE statement which does not exist.
NO MORE ROOM FOR PARAGRAPH
Updating the indicated paragraph would exceed memory space.
NON-NUMERIC FIELD
Program attempted to perform arithmetic with non-numeric data.
NO SUCH FILE
Program attempted to CHAIN to a non-existent file. Trappable globally as
error 16.
NO SUCH TABLE
Program referenced a non-existent table.
NO SUCH FIELD OR VRBL
Referenced field or variable does not exist.
NO SUCH LABEL
Referenced label does not exist.
NO TABLE MATCH
Program executed a TSEAR statement that resulted in no match being found.
Trappable locally in TSEAR. Trappable globally as error 5.
OUTPUT FILE ONLY
Program attempted to GET or READ an output sequential file. Trappable
locally in GET and READ. Trappable globally as error 9.
RECURSIVE ERROR
An error in closing a file caused the system to go into termination logic,
which also attempts to close the file. Rather than hang up in an infinite
attempt to deal with the offending file, this error message is displayed
and QNE reboots directly.
RETURN WITHOUT CALL
Program attempted to RETURN without a corresponding CALL.
STACK OVERFLOW
Program executed too many nested CALL statements.
TO EXPECTED
Error Messages
Page 243
Q - PRO 4 Commands
Statement syntax requires the keyword "to".
USING EXPECTED
Statement syntax requires the keyword "using".
WHAT?
User attempted to load a non-format file for editing.
Error Messages
Page 244
Q - PRO 4 Commands
QMAINT
======
Overview
--------
QMAINT.EXE packs, verifies or recovers an indexed file. QMAINT may be run
from the command line with prompting or the entire command with parameters
may be typed from the command line or executed from a RUN command or a .BAT
file. Under MS-DOS and PC-DOS, the full 64 character file names may be
used.
Prompted Execution
------------------
Typing QMAINT on the command line followed by a Return will display this
prompt:
File Maintenance Utility
Copyright (c) QNE International, 1985
Menu selections are:
1 - PACK
Pack compresses the index file. It is never mandatory to run PACK but
if the indexed data file has a large number of deleted records, PACK
will reclaim the space in the index file. This will reduce the size
of the index file. PACK creates a temporary file and copies the file
to be packed to it. After a successful pack the original index file
will be erased and the packed file renamed to the original.
2 - VERIFY
Verify checks the data file and the index file for validity. This
utility should be run if the indexed data file is suspected of being
corrupted. If there is any error message during the execution, then
the file should be RECOVERed. Verify does not use any disk space.
Verify rebuilds the deleted record chain as it goes, automatically.
3 - RECOVER
Recover restores a data file's index to a usable condition. Note that
index files get corrupted, not data files. Most of the time corrup-
tion of an index file can be traced to one of the following causes:
o The user turning off the machine before the files are closed.
o Trying to use the same index file for two data files.
o Miscellaneous hardware, power and operating software problems.
First the old index file is erased first and then a new one is built.
Utilities
Page 245
Q - PRO 4 Commands
X - Exit
--------
Return to operating system.
Making any menu selection, except X, will display these prompts:
Please enter data file name Type the name of the data file and its
extension followed by a Return.
Please enter IDX file name: Type the name of the index file and its
extension. If the name of the index
file is the same as the data file and
only the extension is different, you may
omit the index file name and press
Return. QMAINT will assume that the
index file is the same name as the data
file with the extension "FID".
Please enter FID file name: Type the name of the FID file including
its extension. If the name of the FID
file is the same as the data file and
only the extension is different, you may
omit the FID file name and press Return.
QMAINT will assume that the index file
is the same name as the data file with
the extension "IDX".
Please enter options (RESULT,CONTINUE,VERBOSE):
The Options are:
RESULT If any of the functions fail the file, QMAINT.BAD, will be
created (but will be empty). If RESULT is not specified and
an error occurs, a return code of 1 will be set when the
program exits (DOS only). This return code may be used
logically in a DOS BAT file, e.g., "IF NOT ERROR LEVEL 0
GOTO . . . ." (See Batch Processing Commands in DOS 2.0 and
higher manuals.)
CONTINUE used only with VERIFY. If specified, the verify function
will not stop after a verify error.
VERBOSE Display key values instead of flashing "WORKING".
Select the options desired and press Return. An appropriate message will
Utilities
Page 246
Q - PRO 4 Commands
display.
Execution from the Command Line
-------------------------------
QMAINT may be run from the command line by typing the command in the syntax
shown below:
QMAINT <function><filename>{parameters}
where:
<function> PACK, VERIFY, or RECOVER
<filename> datafile name \FIDfile name\\INDEX file name. If the
FID or index file name is omitted, it will be assumed
to be the same as the datafile name with the proper
extensions.
<parameters> Optionally RESULT, CONTINUE, VERBOSE. These options
are the same as shown above.
Execution from the RUN Command or a .BAT file
---------------------------------------------
The RUN command and the .BAT file syntax are identical to the command line
syntax.
Examples:
QMAINT PACK data1.dat FID data1.fid INDEX data1.idx VERBOSE
PACK a file named DATA1.DAT whose FID file is DATA1.FID and whose
index file is DATA1.IDX and display the activity as it occurs.
Note that the FID file name is preceded with the keyword "FID" and the
index file name is preceded with the keyword "INDEX".
QMAINT PACK DATA1.DAT VERBOSE
VERIFY a file named DATA1.DAT whose FID file is DATA1.FID and whose
index file is DATA1.IDX. If verify fails create the file QMAINT.BAD.
If verify fails, continue with the verification. Display the activity
as it occurs.
QMAINT VERIFY data1.dat FID data1.fid INDEX data1.idx RESULT, CONTINUE,
VERBOSE
or
QMAINT VERIFY DATA1.DAT RESULT,CONTINUE,VERBOSE
Utilities
Page 247
Q - PRO 4 Commands
Q N E I N T E R N A T I O N A L
Order Form
Please send:
___ Copies of Q-PRO 4 at $50.00 each __________
___ Copies of Q-PRO 4 Plus $90.00 each __________
___ Copies of Author's LockUp at $150.00 each __________
___ Report Generator distribution licence at
$150.00 each __________
___ Copies of Q2C at $250.00 each __________
___ Membership in QNE User's Group at $25.00 each __________
___ One year of telephone technical support at
$150.00 per year __________
___ Q-Query, post relational query language at
$50.00 each __________
Subtotal __________
Shipping:(UPS Ground, US $7.00) __________
Pennsylvania and New Jersey residents please
add 6% sales tax __________
Total $__________
Name: ______________________________________________________
Company: ___________________________________________________
Address: ___________________________________________________
City: _________________________ State:_____ ZIP:__________
Telephone: ______________________ FAX:_____________________
Payment by: __MC __ VISA __Check
Cardnumber __________________________________ Expiration ___/___
Signature: _______________________________________________
To place your order send this form or call (800)333-0448.
Sorry, NO COD's
Utilities
Page 248