Delta BASIC_Reference_Manual_May1985 BASIC Reference Manual May1985

DeltaBASIC_Reference_Manual_May1985 manual pdf -FilePursuit

DeltaBASIC_Reference_Manual_May1985 DeltaBASIC_Reference_Manual_May1985

User Manual: DeltaBASIC_Reference_Manual_May1985

Open the PDF directly: View PDF PDF.
Page Count: 130 [warning: Documents this large are best viewed by clicking the View PDF Link!]

!)1.
.
i
}'S'tf
ELEMENTS OF DeltaBASIC SYSTEMS SUPPORTED* 1,:· g'
Visual screen attributes, function keys, arrow keys, i,,.'i
and diskette formats for the following are supported }] 'H
COMMANDS by DeltaBASIC. !Í.,,,,.
Com,ute,s, d"\,. 0sr O
AUTO LIST Kaypro 'y' ",i !' D. . ;"
CLEAR LISTP Epson QX-1O ""
DEL LOAD Radio Shack Model lV m m
FILES OFF (CP/M Plus, [v. 3.0])
FREE RENAME Xerox 820-11
GO RUN Televideo (CP/M orTurboDOS)
HELP SAVE A variety of disk formats, including IBM 3740 stan- "-
STATEMENTS dard 8" diskette (SS/SD), is available. 0D
m
CHAIN ON GOTO Terminals:
CLOSE ON RESTORE ADM-3A ,
DATA OPEN (diskfile, Televideo 900 Series
DEF FN data entry screen) Qume QVT-102 -'
DIM OPTION Wyse 100
END PRINT (formatted, *NOTE: New implementations are regularly added to 0 0 (
EXIT unformatted) this list. Please contact DeltaSoft, Inc., for further in-
FOR/NEXT READ (internal data, formation on computer systems and terminals not
FORM diskfile, data listed.
GOSUB entry screen) About DeltaSoft, Inc.
D"Q
GOTO REM .,,
IF/THEN/ELSE RESET DeltaSoft, Inc., was established by professional pro-
INPUT RESTORE grammers to develop improved software for business
LET RETURN applications. DeltaBASIC, based on apowerful sub- i
LINPUT REWRITE(disk file, set of IBM System/34 BASIC, is ciesigneci to provide
ON ATTN data entry screen) the programmer with the most effective utilization of
ON (Error STOP the rapidly developing capabilitites of microcom- OOJ'
Condition) WRITE(disk file, puters. The present release is in 8080 Assembly '
ON GOSUB data entry screen) Language and runs on CP/M, MP/M-80, and Turbo-
FUNCTIONS DOS. An 8086/8088 version is under development.
Call or Write for More Information:
Numeric: Character: A DeltaSoft technical representative will be happy to 1> "
ABS CHR$ discuss your specific applications. Please call us at
ATN CNVRT$ (214) 581-1425.
CMDKEY DATE$
ERR STR$ Trademarks:
EXP TIME$ CP/M and MP/M are trademarks of Digital Research. TurboOOS is atrademark of
INT Software 2000, Inc. IBM System/34 is atrademark of IBM Corporation. !'t
LEN Substring function:
LINE (a: b) replaces
LOG string functions
POS LEFTS, MID$
RND and RIGHT$ ,. S''
ROUND of other BASICS,
SGN allows insertion ',.l\\,
SIN and deletion '
SQR
STATUS DeltaSoft, Inc. ·
VAL '"7524 S. Broadway
P. O. Box 7082
Tyler, TX 75711 ABuslness·Orlenteg
(214)581-1425 BASIC Language
©1984· DeltaSoft, Inc.
DeltaRA@IC
ABusiness-Oriented
BASIC Language
Designed to fill the gap in business proAramming Powerful Substring Function SPECIFICATIONS
languages for microcomputers, DeltaBASL provides One simple, versatile substring function (a: b) allows
the multi-user support and other programming great flexibility in string hand|ing. It not only replaces
features essential to the development of efficient, the MID$, LEFT$, and RIGHT$ in other BASICS, but
smoothly-functioning and well documented soft- also allows both insertion and deletion of characters Source Language: 8080 Assembly
ware. within strings. (8086/8088 under development)
Keyed files, decimal arithmetic, formatted data entry Powerful FORM Statement Provides Versatility in Operating Systems Supported:
screens, and other amenities familiar to users of PRINT, READ, WRITE, and REWRITE CP/M-80, MP/M-80, TurboDOS
main-frame languages have been incorporated. With Acomprehensive forms specification list allows Recommended Memory Size:
DeltaBASIC, the business programmer is now able to precise positioning of decimals, dollar signs, leading 48K minimum
achieve maximum effective use of the rapidly devel- or trailing pluses and minuses, and DR and CR Essential Terminal Capabilities:
oping capabilities of microcomputers. codes; definition of character and numeric fields; Clear Screen
and packed or zoned decimal fields where appli- Cursor Positioning
cable. Supported Terminal Capabilities'
FEATURES Run-Time Module Low Intensity
Interactive Design of Run-time modules are available from DeltaSoft as Blink
Formatted Data Entry Screens: needed forthe distribution of applications programs. Non-Display
A menu-driven utility allows you to design screens in- Plus Other Useful Features Reverse Image
teractively, using afull complement of visual and Many other time-saving and convenient features are Underline
data entry attributes, including reverse video, blink- built into DeltaBASIC including program chaining, Function Keys
ing, and field protection. HELP messages may be in- on-screen program editing, aHELP facility for identi- Arrow Keys
corporated to speed operator learning and data entry. fying errors, long variable names, support of function Field Color
Once designed, ascreen may be accessed by simple and arrow keys, and an extensive error-trapping Attributes Available to
READ/WRITE statements. capability. Formatted Data Entry Screens:
Keyed Data Files for Controlled Field Exit
Fast Indexed Access Adjust/Fill
DeltaBASIC provides fast access to files, using rapid UTILITY PROGRAMS INCLUDED Mandatory Field Entry/Fill
sequential or random access by key in addition to ac- Field Type
·· · P · · (Alphanumeric or Numeric)
cess by record number. SDU: Screen Design Utihty for Interactlve design of Auto Screen Entry
For Single- or formatted data entry screens. Position Cursor
Multi·User Systems KEYSORT: Sorts data files by key (predefined) to Field Protection
DeltaBASIC's file- and record-locking capabilities allow keyed sequential access. Data File Access Methods:
allow programming for multi-user environments. GENMSG: A "message generator" which works with Sequential
Decimal Precision your text editor to create HELP messages to be used Relative by Record Number
The precise calculations required by business math with data entry screens. Sequential by Key
are achieved with DeltaBASIC's decimal arithmetic. ORGANIZE: Provides conversion of ASCII text files Random by Key
The errors inherent in other BASIC'S binary-to- to DeltaBASIC and the reverse; conversion of unkey- Data Formats:
decimal conversions have been eliminated. Precision ed files to keyed; or the removal of previously marked Character
is selectable to eight or sixteen digits. records (e.g., Inactive) from data files. Numeric
Binary-Tree Data Management RENUM: Renumbers aDeltaBASIC program. Zoned or Packed Decimal
DeltaBASIC uses internal binary-tree data manage-
ment for faster program execution and file access.
DeltaSoft,lnc. A
RELEASE DOCUMENTATION (May 1, 1985)
DeltaRASIC Version 3.0 (T)
I. Configuration:
A. Operating System -- TurboDOS 1.3
B. MP/M Compatibility -- Full
C. Diskette Format -- IBM 8" SS/SD standard
D. Terminal -- Wyse 100
l. Keyboard Assignment
attention (ATTN) key -- ESC ("I)
begin/end toggle -- "B
cursor left —— left arrow ("FI)
cursor right -- right arrow ("L)
cursor down —- down arrow ("V)
cursor up -- up arrow ("K)
delete right -- ^G
field exit -- line feed ("J)
HELP key -- "Z
insert toggle -- "O
next line -- "X
previous line —— "E
rub out -- RUB OUT
tab next field -- TAB ("I)
Note: "means hold down CONTROL key and press letter key.
2. Function Keys
Function keys FI through F8 are implemented.
3. Visual Attributes
low intensity -- implemented
blink -- implemented
non-display -- implemented
reverse -- implemented
underline -- implemented
1
E. Printer -- system list device
Defaults: auto form feed on -- on
page overflow
line length -- 132
page length -- 66
page overflow -- 64
II. Files included on diskette no. 1
A. DeltaBASIC system files
DBASIC.CCM -- DeltaBASIC command file
DBERR.MSG -- Error message file for HELP facility
DBREF.MSG -- Command, statement,and function reference message file
for HELP facility
SDU.COM -- Screen Design Utility command file
KEYSORT.COM -- Keysort Utility command file
ORGANIZE.COM -- Organize Utility command file
GENMSG.COM -- Help message generation command file
RENUM.COM -- Renumber Utility command file
B. DeltaBASIC demonstration programs
CUSMAN.BAS -- Customer Master Maintenance program
CUSXAN.FRM -- Format file containing data entry screens 'CMM-OO1' and
'C!YM-002' used by CUSMAN.BAS
CUSMAS.DTA -- Customer master file (data) used by CUSXAN.BAS
CUSMAS.KEY -- Customer master file (key) used with CUSMAN.DTA
CUSMAS.DEF -- Customer master file definition
CMM-OOI.LIB -- Library (ASCII text) file of HELP messages for screen
'CMM-OQ1'
CMM-OO1.MSG -- HELP message file for screen 'CPM-OOl' (Created from
'CMM-OO1.LIB' using the GENMSG Utility)
CMM-002.LIB -- Library (ASCII text) file of HELP messages for screen
'CMM-002'
CPM-002.MSG -- HELP message file for screen 'CMM-OO1' (Created from
'CMM-OC)2.LIB' using the GENMSG Utility)
2
CUSREP.BAS -- Customer master file report program: reports menu
CUSREP.FRM -- Format file containing data entryscreen 'CMR-OO1',
'CMR-002', and 'CMR-003' used by CUSREP.BAS
CUSREP1.BAS -- Customer master file report program: sequential access
CUSREP2.BAS -- Customer master file report program: access by selected
record number range
CUSREP3.BAS -- Customer master file report program: sequential access
by key
CUSREP4.BAS -- Customer master file report program: sequential access
by selected key range
DES.BAS -- Data entry screen demonstration program
DES.FRM -- Format file containing data entry screens 'DES-OO1',
'DES-002', and 'DES-003' used by DES.BAS
KED.BAS -- Keyed data file demonstration program
C. Miscellaneous Files
CUSDEL.DO -- TurboOOS 'DO' file used to remove records marked for
deletion in CUSMAS.DTA
RENUY.DO -- TurboDClS 'DC)' file used with RENUM utility to renumber
DeltaBASIC programs
MENU.COM -- Menu utility provided with De1taBASIC system
MENUCll -- Demonstration menu text file interpreted by MENU.COM
HELP.COM -- DeltaSoft interactive TurboDOS utility HELP facility
III. Special files on diskette no. 2(if included)
Auxiliary Demonstration Data Files
K500O.DTA -- Data file used by KED.BAS above
K500O.KEY -- Key file used with K500O.DTA
IV. Features Highlighted by Demonstration Programs
A. CUSMAN.BAS -- Customer Master File Maintenance
1. Formatted Data Entry Screens with Help Messages
2. Random Access of aKeyed File
3
3. Multi-User Support (Shared File Access)
4. Substring Function
5. OFF statement with "Command line"
6. Error Trapping
7. Use of Function and Arrow Keys
B. CUSREP.BAS, CUSREP1.BAS, etc. -- Customer Master File Reports
1. Formatted Data Entry Screens
2. Sequential, Relative, and Keyed-Sequential File Access
3. FORM specifications including "PIC" for formatted output
4. Program chaining
5. Forms control utilizing internal page length and overflow
C. DES.BAS -- ñata Entry Screen Demonstrator
I. Explicit demonstration of visual attributes
2. Explicit demonstration of data entry attributes
3. Use of substring function to build "INDIC" string
4. Use of Function keys
D. KED.BAS -- Keyed File Demonstrator (if included)
1. Access of relatively large (5000 records) data file by key
2. Random number generator
V. Sample Terminal/Computer Interface Module
The following listing may be helpful for basic reconfiguring of your version
of De1taBASIC. Either DDT.COM (CP/M or MP/M) or MOR'ITOR.COM can be used to
load, modify, and resave DBASIC.COM. Care must be execised to prevent
changes in code other than those provided for below. DeltaSoft, Inc.
assumes no responsibility for the modification of DBASIC.COM by the user.
Please see the license agreement for more information.
NOTE: The configuration below is asample only and does not correspond with
your implementation of De1taBASIC.
%d 4 ? @ b te L~j Lpt µxt~jµzL.t4b-4@ !>9>t but dLpQpjpj f Lpb<b L. fYLJp%bbj· ? >L.f f f d f f Y P L t. r Jp C >"7 Ur r,Trbrhrrrr"r"r"rTT"rT r r órir r trtór r r ót i lrrrlRrrÓ Ó·T' rÓ h rn T ri b Ó
gJp xC
""r T
g
;* DeltaBASIC *
·* *
g
4
;* (C) COPYRIGHT 1984 BY DeltaSoft, Inc. *
.* *
g
;* Version: 1.3 *
.* *
g
;* Rev. Date: 23 May 1984 *
.* *
g
;* Rev. Time: 3: 00 PM >;<
L*
0q>
g
;* Terminal: SAMPLE *
·* *
g{b++ tp¿twwjp 1~&^ b Ct 4 @ llCtr td p bj~j M? W t~j C C C? CWíd e t~&p+bgp%LpMLpU C Ct¶ L) d +
i"r rrrím r r rm rt ri "Ti trm br r r rt trn ár r i"i ri rm n t t ó b "r"r"r"r rá >ri n n t ób4r
?
*
g
;MISC. EQUATES
0
g
;OFFH IS USED TO INDICATE ANULL CHARACTER STRING
g
DOFF =N EQU OFFH
0
?
;THE HIGH BIT IS SET TO MARK THE END OF CHARACTER
;STRINGS. FOR CONVENIENCE, THE VALUE P CAN BE ADDED
;TO THE LAST CHARACTER OF ASTRING.
e
?
0080 =P EQU 128
*
?
0
g
0103 ORG 103H
0
g
;THE XFER SUBROUTINES ARE USER MODIFIABLE SO LONG AS
;THE ADDRESSES IN THE TABLE BELOW ARE UPDATED. THE
;ADDRESS SPACE FOR THESE SUBROUTINES IS 03A2H TO 053FF!.
;TWO SIJBROUTINES THAT COULD PROVE USEFUL ARE (I) DIRIO
;(AT 3C30H WHICH OUTPUTS THE ASCII CHARACTER IN THE 'A'
;REG TO THE TERMINAL AND (2) CURSO AT O1F6H WHICH
;POSITIONS AT THE CURSOR AT THE ROW GIVEN IN THE H REG
;AND COLUMN IN THE L REG.
0
:
;THE GENERAL SPECS FOR THE XFER SUBRC)UTTNES ARE GIVEN
;BELOW.
:
;NOTE: NO ADDRESSES ARE SHOWN IN THE TABLE BECAUSE THEY
;DIFFER DEPENDING ON THE SPECIFIC COMPUTER/TERMINAL
;IMPLEMENTATION.
e
g
0103 C30000 TTNIT: JMP ..... ;TERMINAL INITIALIZATION
0106 C30000 AWRSET: JMP ..... ;VISUAL ATTRIBUTE WRITE SET
0109 C30000 AWRRST: JMP ..... ;VISUAL ATTRIBUTE WRITE RESET
OlOC C30000 ARDSET: JMP ..... ;VISUAL ATTRIBUTE READ SET
O1OF C30000 ARDRST: JMP ..... ;VISUAL ATTRIBUTE READ RESET
0112 C30000 CLRATR: JMP ..... ;CLEAR VISUAL ATTRIBUTES
0115 C30ClOO SETTMO: JMP ..... ;GET TIME INTO [HL]
0118 C30000 SETDTO: MP ..... ;GET DATE INTO [HL]
0
7
;CONFIGURATION DATA
r
g
;1. OPERATING SYSTEM FLAG
5
0
g
;0=CP/M 1=MP/M 2=TURBODOS
0
:
0118 00 OPSYS: DB O;CP/M
0
7
;2. ANSI FLAG
*
g
;0=NC) 1=Y
O
:
OllC 00 ANSI: DB O;NO
0
?
;3. COMPATIBILITY FLAG (TURBODOS ONLY)
0
g
;BIT 7=PERMISSIVE FLAG
;6=SUSPEND FLAG
;5=GLOBAL-WRITE FLAG
;4=MIXED-XODE FLAG
;3=LOGICAL FLAG
;(BITS 2-O NOT DEFINED)
0
g
0110 00 COMPAT: DB O;FULL MP/M
0
g
;4. TERMINAL INITIALIZATION DATA
©
g
O11E FF00000OOOINIT: DB N,0,O,O,O ;N=N0NE
0123 0000000000 DB 0,0,0,0,0 ;
0128 0000000000 DB 0,0,0,0,0 ;
012D 0000000000 DB 0,0,0,0,0 ;
W
g
;5. MOVE CURSOR LEFT DATA
0
y
0132 880000OOOOCURLFT: DB 08H+P,O,O,O,O ;"H
0
?
;6. MOVE CURSOR RIGHT DATA
9
?
0137 8C00OOO0OOCURRGT: DB OCH+P,0,O,O,O ;"L
0
:
;7. CURSOR POSITIONING DATA
O
g
;SEE BELOW
O
g
013C 1BBDOOOO0OCURPS1: DB 1BH,'='+P,O,O,O ;CUR POS PREAMBLE: 'ESC='
0141 IF CURPS2: DB 31 ;LINE NUMBER BIAS: 31
0142 FF CURPS3: DB N ;SEPARATOR CHAR: N=N0NE
0143 IF CURPS4: DB 31 ;COL NUMBER BIAS: 31
0144 FF0O000OO0CURPS5: DB N,0,O,O,O ;CUR POS TRAILER: N=NONE
0
:
;8. ROW/COL ORDER
0
g
;OOH =ROW/COL OFFH =COL/ROW
*
7
0149 00 RCORD: DB OOH ;R0W/COL
O
g
;9. ATTN CHARACTER DATA
0
g
6
014A IB ATNCHR: DB 1BH ;ESC
e
g
;10. KEY DATA TABLE
0
g
0148 FFOOOO LICHR: DB N,0,O ;LEAD-IN CHARACTER: N=N0NE
014E 870000 DB 07H+P,O,O ;DELETE RIGHT: "G
0151 FFOOOO DB 7FH+P,O,O ;RUB OUT: RUB OUT
0154 880000 DB 08FI+P,O,O ;CURS0R LEFT: "FI
0157 8COOOO DB 0CH+P,O,O ;CURS0R RIGHT: "L
015A 8AOOOO DB 0AH+P,O,O ;CURS0R DOWN: "J
015D 880000 DB OBH+P,0,O ;CURS0R UP: "K
0160 8FOOOO DB OFH+P,0,O ;INSERT TOGGLE: "O
0163 820000 DB 02H+P,O,O ;BEGIN/END TOGGLE: "B
0166 8AOOOO DB 0AH+P,O,O ;FIELD EXIT: "J
0169 890000 DB 09H+P,O,O ;TAB NEXT FIELD: "I
016C 850000 DB 05fl+P,O,O ;PREVI0US LINE: "E
016F 980000 DB 18H+P,O,O ;NEXT LINE: "X
0172 9AOOOO DB 1AH+P,O,O ;FIELD MESSAGE HELP: "Z
?
;11. FUNCTION KEY TABLE
P
g
0175 810000 FICHR: DB O1FI+P,O,O ;LEAD-IN CHARACTER: soFt ("A)
0178 810000 DB 31H+P,O,O ;FUNCTI0N KEY 1
017B B20000 DB 32H+P,O,O ;FUNCTI0N KEY 2
017E 830000 DB 33H+P,O,O ;FUNCTI0N KEY 3
0181 840000 DB 34R+P,O,O ;FUNCTI0¥ KEY 4
0184 850000 DB 35H+P,O,O ;FUNCTI0N KEY 5
0187 860000 DB 36H+P,O,O ;FUNCTION KEY 6
018A 870000 DB 37H+P,O,O ;FUNCTI0N KEY 7
018D 880000 DB 38H+P,O,O ;FUNCTI0N KEY 8
0190 800000 DB N,O,0 ;NOT IMPLEMENTED
0193 800000 DB N,0,O ;NOT IMPLEMENTED
0196 800000 DB N,0,O ;NOT IMPLEMENTED
0199 800000 DB N,0,O ;NOT IMPLEMENTED
019C 800000 DB N,0,O ;NOT IMPLEMENTED
019F 800000 DB N,0,O ;NOT IMPLEMENTED
O1A2 800000 DB N,O,0 ;NOT IMPLEMENTED
O1A5 800000 DB N,0,O ;NOT IMPLEMENTED
0
:
;12. HOME CURSOR DATA
*
:
O1A8 8000000O0OHOME: DB N,0,O,O,O ;NONE
*
3
;13. CLEAR SCREEN DATA
O
9
O1AD 9A0O00OO00CLR: DB 0IAH+P,0,O,O,O ;"Z
0
9
;14. PRINTER SKIP PERF
P
g
;0=OFF 1=ON
*
g
0182 01 PINIT: DB 1;ON
0
:
;15. PRINTER LINE LENGTH
0
:
7
0183 50 DB 80 ;80
0
:
;16. PRINTER LINES PER PAGE
*
g
0184 42 DB 66 ;66
0
g
;17. PRINTER OVERFLOW LINE
*
7
0185 40 DB 64 ;64
*
g
;18. MISC TURBODOS PATCHES
W
g
;SEE BELOW
0
g
;TurboOOS Ver. 1.22 1.3
V
g
0186 5000 TDOSA: DB 50H,O ;FUNCTI0N CALL ADDRESS 05H,O 50H,O
0188 OD DB 13 ;SET COMPATIBILITY FLAG 120 13
0189 12 DB 18 ;SEND COMMAND LINE 108 18
O1BA IB DB 27 ;PRINT MODE SET 76 27
O1BB 00000000 DB 0,0,0,0 ;LEAVE ROOM FOR MORE
P
g
;19. ATTRIBUTE TABLE
e
g
;ORDER: DIM,BLINK,BLANK,REV,UND
O1BF 4002010408ÁTTBL: DB 40H,02H,O1H,04H,08H
*
}
;20. TERMINAL SIGN-ON MESSAGE
0
g
;MUST INCLUDE 32 POSITIONS
*
g
O1C5 5465726D69ATRMSG: DB 'Terminal: ADM-3A ',' '+P
0
©
g
;DATA END
0
g
0
3* 0 0
*
?*Y*k*T*7k**kTk>77M: "r\kl**>k>k:P***TkT*k7***gr**>:<**t"r\>m****lT::*P**7k
g
,*
y
;MISC. SUBROUTINES -- USER MODIFIABLE *
.*
g
·**>P**>k****a\*: k*M::k*>k****"r***y**k***kq"r*7*q"T*kP****7Y*t***:k*******>É
g
0
g
;XFER SUBROUTINES ARE USER MODIFIABLE. THE ENTRY
;POINT JUMP TABLE AT 0103H MUST BE MODIFIED TO
;REFLECT ADDRESS CHANGES. ALL REGISTERS CAN BE MODIFIED
;BUT TFIE STACK MUST BE PRESERVED.
0
g
;NOTE: NO CODE IS GIVEN--ONLY SUBROUTINE DEFINTIONS.
0
g
;TERMINAL INITIALIZE SUBROUTINE: CALLED ONCE BEFORE
;SIGN-ON.
P
g
8
;XFER0:
*
:
0
?
;VISUAL ATTRIBUTE CONTROL
0
g
*
?
;VISUAL ATTRIBUTE WRITE SET SUBROUTINE: SETS SPECIFIED
;VISUAL ATTRIBUTES AND POSITIONS CURSOR AT ROW/COL IN
;HL BEFORE WRITE.
0
g
;H=ROW L=C0L B=FLD LEN C=ATTR BYTE
g
g
;ATTR BYTE -TRUE=1
*
g
;(AS DEFINED ABOVE)
9
y
;BIT 765432 1 O
;ODIM OOUNO REV BLINK BLANK
0
?
;NOTE: MUST RETURN WITH CURSOR AT P0S(H,L)
0
?
;XFER1:
*
?
;ATTRIBUTE WRITE RESET SUBROUTINE: RESETS VISUAL
;ATTRIBUTES AFTER WRITE IF NECESSARY.
*
?
;XFER2:
e
7
;VISUAL ATTRIBUTE READ SET SUBROUTINE: SETS SPECIFIED
;VISUAL ATTRIBUTES AND POSITIONS CURSOR AT ROW/COL IN
;FIL BEFORE READ IF NECESSARY.
0
g
;H=R0W L=C0L !3=FLD LEN C=ATTR BYTE
0
:
;ATTR BYTE -TRUE=1
0
g
;BITS 7654321 O
;ODIM O O UNO REV BLINK BLANK
0
g
0
g
;NOTE: MUST RETURN WITH CURSOR AT P0S(H,L)
0
g
;XFER3:
*
g
;ATTRIBUTE READ RESET SUBROUTINE: RESETS VISUAL
;ATTRIBUTES AFTER READ IF NECESSARY.
0
y
;XFER4:
0
:
;CLEAR RESIDUAL ATTRIBUTES: CLEARS VISUAL ATTRIBUTES
;AFTER INTERRUPTION.
0
?
;XFER5:
0
g
;GET TIME SUBROUTINE: STORE HH:MM:SS AT ADDRESS
9
;POINTED TO BY REG HL. USE 99: 99:99 IF TIME NOT
;AVAILABLE.
0
?
;XFER6:
0
g
;GET DATE SUBROUTINE: STORE YYYYMMDD AT ADDRESS
;POINTED TO BY REG HL. USE 00000000 IF DATE NOT
;AVAILABLE.
0
}
;XFER7:
W
g
10
,~ a
g.
\
DéltaBASTC LiK=&e
MTRñWk Read this license C.&.l=f!=é.P¿ carefully opening this packíge. If you do not agree
with the terns and conditions ccntained herein, return the unoµ'ned package to DéltaSoft, Inc., 7524
S. Broadway Suite 119, Tyler, Texas 7SU3.
I.License
MtaSoft, Inc. agrees to grant to the Licmsee, upon tjE Licensee's acceptance of the terms and
conditions of this agreerent, armtransferable and ncnexclusive license to use the DeltaSoft, Inc.
software enclosed in the accQmnying µEkage·
2. Restrictions on Use
The Liagrees to use the enclosed software only cm the ccimµiter sc) deságnated on the licmse
registration form. Neither this license nor the encksed software tray be asiñgned, sublicensed, or
otherwise transferred by the Liumsee without written permission of IkltaSoft, Inc.
3. 'Back-up Copies of Program
The Lícmsee my náke up to twD copies of tiie enclosed software provided it is for the Liamsee's
.
4. Copies of Documentation
The Limy not copy in whcñe or in part the enc1Q8ed dttaticn or related mteria1s.
Addition copies of the d«trrmtation can te obtained fran DeltaSoft, Inc., 7425 S. Bruadway Suite
119, Tyler, Texas 75703.
5. Modif ication
The Licensee tray nrdify the prc)gr= only to Üe! extent to adapt it to aterminal or
printer. No other rtrxlificatícns my be wade.
6. Copyrig?n" Notice
The SO: ÉF 7rq, CiCf" tmmtation, and related mterials contained herein are copyrighted by Ik1taSoft,
Inc. The ¡jL¿jeiIsee agrees not to rgIr)ve any copyright notices. Fírrther, tN Licmsee agrees to
reprMuce such notices on any copies of the software mde by the Licensee.
7. NcyÉFdigtlosttre
MúcEm!e agrrm not to provide, disclose, or otherwise make available any lkltaSoft, Inc.
softmre, dcrmmtátion or related mteria1s to any Ferson other than errployees of the Licensee and
then only to tjiz extmt to conduct business of Ü1e Licensee.
8. TetiM of License
The 1ica1g? sMll remain in effect for such perícxj as Úe! Licmsee ccrrplíes vith the tand
tmditions athe li. The License is subject to cancellation by IELtaSoft, Inc. for faihre of
LioeEsee to tmp1y with tie t«irg and conditions of this li.
9. EMmncelmmts and Updates
Re! verskm of sdímre, dttation, and related mteria1s was currmt at the time this µíckage
~mmfa±ured.
si±scri! to the DékaSoft, Inc. Soft\Ñare Uµjate Prcgram.
10. Limited Warrmty
,
mftware, d(mn=athm, and related mrpri·l1q enclcsed in this Facikage. DéltaSoft, Inc.
d'q"1'Af'!'q all hiplied warranties of mercMntabi1ity or for aµírticular FurpKjge. IkltzGoft,
Inc. diá11 mt te liable for ccnsequaitial damges or related expenses evm if mtified oF the
p~intyofsiKhda=. TheIÁceEEEm]sttl~ltjlmuu~ingthisprum.
.
DeltaBASIC Registration Form
This form inust be fi.l-led out and returned to DeltaSoft, Inc., 742-5 S. Broadway
Suite 1!9, Tyler, Texas 75703 within 30 days after purchase to ensure proper
registration.
Serial number:
Computer system on which the software will be used:
Serial number of computer system:
T,(Licensee") ,agree to the terms and
conditions of the DeltaSoft, Inc. DeltaBASÍC License Agreement enclosed. If
the software package was not purchased by an individual, Trepresent that Iam
the authorized agent of the company named below.
signature of individual or agent representing company date
Address
City/State Zip Code
Phone No. ( )
Iam lam not enclosiñf' $75.00 for aone-year subscription to the
DeltaSoft, Inc. Software Update Program. Tunderstand that by subscribing, I
will receive all software and publication updates for the above named software
package for aperiod of one year.
DeltaBASIC Reference Manual NOTICES
COPYRIGHT NOTIICE
Copyright (C) 1984 by DeltaSoft, Inc.
All Rights Reserved
All material in this publication is copyrighted. No part may be
reproduced in any form whatsoever without written permission of
DeltaSoft, Inc., 7524 S. Broadway, Suite 119, Tyler, Texas, 75703.
TRADEMARK NOTICE
CP/M and MP/M are trademarks of Digital Research. TurboDOS is a
trademark of Software 2000, Inc. IBM System/34 is atrademark of
IBM Corporation.
DISCLAIMER OF WARRANTY
DeltaSoft, Inc. makes no express or implied warranty of any kind
with respect to the use of the contents of this publication.
DeltaSoft, Inc. expressly disclaims all implied warranties of
merchantability or fitness for aparticular purpose. DeltaSoft,
Inc. shall under no circumstances be liable for consequential
damages or related expenses even if notified of the possibility
of such damages. The user must assume the entire risk of using
the contents of this publication.
DeltaBASIC Reference Manual TABLE OF CONTENTS
TABLE OF CONTENTS
Section IIntroduction
Features of DeltaBASIC 1-l
Organization of the Reference Manual ........... l—1
Section 2Definitions
Constants .. .. 2-l
Variables ., 2-l
Numeric Expressions ................ 2-l
Character Expressions ........... 2-2
Relational Expressions ......... 2-2
Logical Expressions ........... 2-2
Section 3Abbreviations ...... 3-l
Section 4Basic Operation
The Command/Prograin Edit Mode .................. 4-l
Editing Keys ................................... 4-l
The Program Execution Node ..................... 4-l
Section 5Commands
Description .................................... 5-l
AUTO .... ................ 5-2
CLEAR ............................... 5-3
DEL ... ................. 5-4
FILES ............... .... 5-5
FREE ........................................... 5-6
GO ..5-7
HELP ... ..5-B
LIST .......................... 5-lO
LISTP ...... ......................... 5-ll
LOAD 5-12
OFF ................................. 5-13
RENAME .5-14
RUN .............. 5-lS
SAVE ................... 5-16
Section 6Statements
Description ........ 6-l
CHAIN .......................................... 6-2
CLOSE .... 6-3
DeltaBASIC Reference Manual TABLE OF CONTENTS
DATA ............... ............... 6-4
DEF FN ........ 6-5
DIM ..................... ........... 6-7
END .................... ............. 6-B
EXIT ........................................... 6-9
FOR/NEXT ......... 6-lO
FORM ........................................... 6-ll
GOSUB ................. .......... 6-15
GOTO ........................................... 6-16
IF/THEN/ELSE........... 6-17
INPUT .......................................... 6-18
LET ........... ......... 6-19
LIXPUT ......................................... 6-20
ON ATTN .......... ........ 6-21
ON Error Condition ............................. 6-22
ON GOSUB ......... ... 6-23
ON GOTO ........................................ 6-24
ON RESTORE .............. ............ 6-25
OPEN (disk file) ............................... 6-26
OPEN (work station file) ....................... 6-28
OPTION ......................................... 6-29
PRINT (unformatted) ............................ 6-30
PRINT (formatted) .............................. 6-31
READ (internal data)............................ 6-32
READ (disk file) ............................... 6-33
READ (work station file) ....................... 6-34
REM ............................................ 6-35
RESET ... ............................ 6-36
RESTORE ........................................ 6-37
RETURN .......................... 6-38
REWRITE (disk file) ............................ 6-39
REWRITE (workstation file) ........ 6-40
STOP ...................... ........ 6-42
WRITE (disk file) .................. 6-43
WRITE (workstation file) ....................... 6-44
Section 7Intrinsic Functions
Description ...,..,.................. 7-l .
Intrinsic Numeric Functions .................... 7—l
ABS .7-2
ATN ........................................ 7-2
CMDKEY ... ......... 7-2
ERR ........................................ 7-2
EXP ...................... 7-2
INT ......................... 7-2
LEX ................ 7-2
LINE ........................ 7-2
LOG ........................ 7-2
POS ........................................ 7-2
RND ......................... 7-3
ROUND ....................... 7-3
SGN ............................ 7-3
DeltaBASIC Reference Manual TABLE OF CONTENTS
SIN .. ..................................... 7-3
SQR '7-3
$
STATUS ....... ...... 7-3
VAL .......... .7-3
Intrinsic Character Functions .. 7-4
CF1R$ .... .7-4
CNVRT$ ..................................... 7-4
DÁTE$ .. 7-4
STR$ ....................................... 7-4
TTME$ ...................................... 7-4
(Special character substring function) ..... 7-4
Section 8Utility Programs
Description ................. 8-I
GENMSG ......................................... 8-2
KEYSORT ........................................ 8-5
ORGANIZE ....................................... 8-6
RENUM ..................... 8-ll
SOU ..... ...................... B-12
Appendix AError Codes
Format ......................................... A-l
List of Error Codes ............................ A-l
Appendix BReserved Words ................................. B-1
Appendix CDisk File I/O
Description ......... .C-l
Sequential Access .............................. C-2
Output Mode ............. C-2
Input Mode ................................... C-4
Update Mode ............ C-5
Relative Access ................................ C-6
Output Mode ............... C-6
Input Mode ..... ................... C-6
Update Mode ........... C-7
Keyed Access ................................... C-9
Random by Key/Output Mode .................... C-lO
Random by Key/lnput Mode ..................... C-ll
Random by Key/Update Mode C-12
Sequential by Key/lnput Mode ................. C-13
Sequential by Key/Update Mode ................ C-14
DeltaBASIC Reference Manual TABLE OF CONTENTS
Appendix DFormatted Data Entry Screens
Description ..............,..................... D-l
Data Entry Attributes .......................... D-l
Visual Attributes .............................. D-2
Appendix EMulti-User Information ......................... E-l
Appendix FLanguage Compatibility ......................... F-l
Appendix GIndex .......................................... G-1
DeltaBASIC Reference Manual INTRODUCTION
Section 1. INTRODUCTION
DeltaBASIC was designed to meet your needs for aversatile but easy-to-use
business programming language. Its most important features include:
l. Versatile disk file access for Unproved data management
2. Formatted data entry screens for better user interfacing and more
complete utilization of computer system capability
3. Decimal arithmetic (8 or 16 digits) for improved accuracy.
To take full advantage of these and other features of DeltaBASIC, you should
become familiar with the commands and statements described in this manual.
The reference manual is organized as follows:
Sections 2and 3 define the terms and abbreviations used in this manual.
Section 4describes the basic operating modes of DeltaBASIC.
Sections 5through 7describe the commands, statements, and functions
available for use in DeltaBASIC.
Section 8describes various utility programs that provide support functions
to programs written in DeltaBASIC.
Appendix Alists error codes and their meanings.
Appendix Blists the reserved words that have restricted use in DeltaBASIC
programs.
Appendix Cdescribes DeltaBASIC's disk file I/O features.
Appendix Ddescribes the powerful formatted data entry screen features of
DeltaBASIC.
Appendix Eprovides information concerning multi-user capabilities.
Appendix Fdiscusses DeltaBASIC's compatibility with other BASIC
implementations.
Page l-1
DeltaBASIC Reference Manual DEFINITIONS
Section 2. DEFINITIONS
Constants
Values that remain the same during program execution are called constants.
Numeric constants are accepted within the range 1.OE-62 to 9.99...E+62 and
have aselectable precision of 8or 16 significant digits (see the OPTION
statement). Character constants are formed by enclosing alphanumeric
characters in quotation marks. Character constants can be from Oto 255
characters in length.
Examples: 2.45
1.3E-20
"JAMES SMITH"
Variables
Values that can change during program execution are called variables.
Variables take two possible forms: numeric or character. Numeric variables
have the same size restraints as constants (above). Character variables can
have any length from 1to 255 characters, with the length assigned using the
DIM statement. (If no length is assigned, it is automatically set at 18
characters.) Either numeric or character variables can be used in arrays.
Each variable must be given a name consisting of lto 8alphanumeric
characters (A-Z, 0-9). The first character of the name must be alphabetic.
The name of acharacter variable must end with adollar sign ($)·
Examples: RATE
CUSTOMER$
CNST(I0,5)
TABLE$(I)
Numeric and character variables cannot have the same name; le., DAY and DAY$
cannot be used in the same program. Certain words are reserved for use by
DeltaBASIC and may not be used as variable names. For alist of these
reserved words, see Appendix B.
Numeric Expressions
Numeric expressions are composed of numeric variables and constants, intrinsic
numeric functions, arithmetic operators (+, ,*,/,"), and parentheses.
Algebraic rules are used to establish precedence for evaluating anumeric
expression:
Page 2-l
DeltaBASIC Reference Manual DEFINITIONS
First: l. Expressions within parentheses
2. Exponentiation (^)
3. Negation (-)
4. Multiplication (*), Division (l)
Last: 5. Addition (+), Subtraction (-)
When equal precedence is encountered, evaluation proceeds from left to right.
Examples: -35/2
2*SQRT(X"2+Y"2)+180
Character Expressions
Character expressions are composed of character variables and constants,
concatenation operators (&), and intrinsic character functions.
Examples: A$&" DB"
STR$(65)
Relational Expressions
Relational expressions are composed of two numeric expressions or two
character expressions separated by arelational operator. The valid
relational operators are <,>,=, or acombination of two of these. The
combination <> means "not equal to". Relational expressions are evaluated by
the program as either true or false.
Examples: HOURS<=12
FIRST$>LAST$&"A"
Logical Expressions
Logical expressions are composed of relational expressions, logical operators
(NOT, AND, and OR), and parentheses. Logical expressions are evaluated by the
program as either true or false. Evaluation precedence is as follows:
First: 1. Expressions within parentheses
2. NOT
3. AND
Last: 4. OR
When equal precedence is encountered, evaluation proceeds from left to right.
Examples: NOT(A<B)
(C$<>TEUP$) AND A<l
Page 2-2
DeltaBASIC Reference Manual ABBREVIATIONS
Section 3. ABBREVIATIONS
The following abbreviations are used to simplify the commands, statements, and
functions described in this manual.
num—cnst numeric constant
char-cnst character constant
cnst constant——either numeric or character
cnst-list constant list (comma used as separator)
num-var numeric variable or numeric array element
char-var character variable or character array element
var variable——either numeric, character, or array element
var-list variable list (comma used as separator)
num-expr numeric expression
char-expr character expression
expr-list expression list (comma used as separator)
num—fnc numeric function
char-fnc character function
rel—expr relational expression
rel-optr relational operator
log-expr logical expression
log-optr logical operator
char-str character string--not enclosed in quotes
line-num. line number (1—65534)
file-ref file reference (1-254)
drv: name.typ disk file drive, name, and type.
RETURN the RETURN key
(return key) press the RETURN key
ATTN the attention key (usually the ESCAPE key)
I/O input/output
Throughout the remainder of the manual, braces (l)) indicate optional
parameters. The braces themselves are not part of the format.
Page 3-1
De1taBASIC Reference Manual BASIC OPERATION
Section 4. BASIC OPERATION
As with most BASIC interpreters, DeltaBASIC has two operational modes: the
comrnand/program edit mode and the program execution mode.
To bring up the command/program edit niode from the operating system, enter
DBASIC (return key)
Then, after sign-on, you can either load an existing program from disk or
enter the lines of a new program. The command/program mode allows you to
enter commands, add lines to the current program, or change or remove existing
lines.
Certain special keys that can be used when in the command/program edit mode
are listed below. The caret (") means the control key is held down while the
key is pressed.
"H Moves the cursor to the left one character.
"l. Moves the cursor to the right one character.
"J Moves the cursor up one line (rnultiline statements).
"K Moves the cursor down one line (multiline statements).
^B Moves the cursor to the beginning of the line.
"O Turns the insert capability on/off.
^G Deletes one character to the right.
RUB OUT Deletes one character to the left.
RETURN Enters the cominand or line.
These key choices may vary, depending on computer system and terminal used.
To enter the program execution mode from the command/program edit mode, enter
RUN (return key)
Execution will begin with the first line of the current program and continue
until aSTOP, END, or OFF statement is executed or an untrapped error occurs.
The program can also be interrupted by pressing the ATTN key.
To enter the program execution mode directly frorn the operating system, enter
DBASIC jdrv: }name{.BAS} (return key)
where the file narne refers to aDeltaBASIC program saved in non-source form.
After DeltaBASIC loads, the program will load and begin execution.
Page 4-l
DeltaBASIC Reference Manual COMMANDS
Section 5. COMMANDS
The following DeltaBASÍC commands are used to control such tasks as clearing a
program froin memory or loading aprogram frorn disk. Commands are not usually
found in programs but are executed directly from the keyboard while De1taBASIC
is in the command/program edit mode. To enter acommand, type the command
name and any appropriate parameters, then press the RETURN key.
Page 5-l
DeltaBASIC Reference Manual COMMANDS
.
AUTO {line--num,mm—cnst)
The AUTO command automatically generates line numbers, freeing you frorn the
task of typing aline number before entering each step of your program.
Numbering begins with line-num and is incremented by num-cnst. If line-num
and num-cnst are not specified, numbering will begin with 10 and increment by
5. If aduplicate line number occurs, the old line is displayed instead of a
blank line. To end the AUTO mode and return to the command/prograrn edit mode,
press the ATTN key.
Example:
AUTO (return key)
Ablank line with line number 10 appears at the bottom of the screen with the
cursor positioned for editing. When the line is completed, pressing the
RETURN key enters it. The line number is then incremented by 5 and ablank
line 15 is displayed ready for editing.
AUTO 100,10 (return key)
Same as above, except the first line number is 100 and the increment will be
10.
Page 5-2
DeltaBASIC Reference Manual COMMANDS
CLEAR
The CLEAR command closes any open files, then clears the program and data
areas of memory.
Be careful—-this command permanently erases all the program and data
information currently in memory. It is not possible to recover this
information.
Example:
CLEAR (return key)
Open files are closed and the current program and data areas are cleared from
memory. DeltaBASIC then returns to the command/program edit mode.
Page 5—3
DeltaBASIC Reference Manual COMMANDS
DEL line—mm I{,líne—num 2)
The DEL command removes line-num 1or, when asecond line number is entered,
all lines from line-num 1through line-num 2. DEL does close all open files.
Examples:
DEL 35 (return key)
Line 35 is removed from the program.
DEL 100,200 (return key)
Lines lOó through 200 inclusive are removed.
Page 5-4
DeltaBASIC Reference Manual COMMANDS
FILES {drv: }
The FII.FS command displays adirectory of the files on the specified drive or,
if no drive is specified, on the default drive.
Examples:
FILES (return key)
Adirectory of files on the default disk drive is displayed.
FILES C: (return key)
The directory for disk drive Cis displayed.
Page 5-5
DeltaBASIC Reference Manual COMMANDS
FREE {drv: }name.typ
The FREE command erases the named file from the disk. The file name and file
type are both required. If the disk drive is not specified, the default disk
drive is assumed.
FREE can also be used as a statement in aprogram.
Examples:
FREE PAYMÁS.BAS (return key)
The PAYMÁS.BAS file is removed from the default drive.
FREE C: PAYTRN.DTA (return key)
The PAYTRN.DTA file is removed from disk drive C.
Page 5-6
DeltaBASIC Reference Manual COMMANDS
GO {line—mm}
{END)
The GO command starts the program running again after anon-error
interruption. (Non-error interruptions include pressing the ATTN key and
execution of aSTOP statement.) If lines are not added or removed during the
interruption, variables are preserved and disk files are left open.
The primary use of GO is in debugging aprogram. STOP lines are placed at
various points in the program so that program and variable status can be
checked. GO then permits execution to resume at the specified line number
or——if no line number is specified--at the next line. If lines are added,
removed, or changed, execution will start at the first line of the program.
If after interrupting aprogram, it is decided that resumption of the program
is not needed, the GO END command closes all open files to prevent loss of
data and ends the program.
Example:
20 A=16*B+C
21 STOP
30 IF A<30 THEN 40
35 B=A+C
40 A=A+1
* * 0
Line 21 has been inserted so that the values of A, B, and Ccan be printed and
checked. After this has been done, entering GO causes execution to resume at
line 30.
If the ATTN key is pressed just just as line 35 is to be executed, GO will
continue execution at line 35. GO 40 would cause program execution to start
at line 40.
Page 5-7
DeltaBASIC Reference Manual COMMANDS
HELP {parameter)
The HELP command causes the computer to display an explanatory message. The
message displayed depends on the parameter specified, as follows:
HELP
Displays a message to explain the last error. To conserve memory, error codes
are abbreviated. Because you may have trouble interpreting these codes at
first, the HELP command provides the additional information needed to
understand them. As you learn the meaning of the abbreviated error codes, the
HELP facility will become less important.
HELP mm—cnst
Displays amessage to explain the error whose number is given by the numeric
constant. Error numbers are given in Appendix A.
HELP command name
statement name
function name
Displays abrief explanation of the command, statement, or function.
Examples:
20 IF COUNT>3 THAN A=lO
Line 20 contains asyntax error: THAN should be THEN. When line 20 is
executed, an error is detected and this message displayed:
(I) SYNTAX Error in Line 20
While the meaning of this error is probably clear enough, entering HELP will
provide this additional information:
SYNTAX ERROR: an unrecognizable cotnmand/statement was encountered.
Suppose you correct the THEN error and try again to execute. This time a
different error message appears.
(2) SYN EDS Error in Line 20
Although the abbreviation SYN clearly points to asyntax error, the EDS may be
alittle mysterious. Entering HELP gives this additional information:
SYNTAX ERROR AT END OF STATEMENT: colon or line end expected.
EDS is short for "END OF STATEMENT". Looking at the end of line 20, you see
that the letter Owas used instead of the number O. Changing this makes line
20 correct.
HELP 10 (return key)
The HELP message for error number 10 is displayed.
Page 5—8
DeltaBASIC Reference Manual COMMANDS
LIST {line—mm}
The LIST command lists the program currently in memory. If the optional line
number is not specified, the entire program is listed. If the optional line
number is used, then the program line with aline number greater than or equal
to the one specified will be the last line listed. In this case, the last
line will be positioned near the bottom of the screen with the cursor located
at the first character of the line. At this point, you can change the line
and place it back in memory by pressing the RETURN key. In addition to the
command/program edit mode cursor control keys (see BASIC OPERATION, Section
4), the following special keys are activated at this time:
"E Move to the previous line in the program.
"X Move to the next line in the program.
Example:
LIST 120 (return key)
The program is listed with line 120 near the bottom of the screen. The cursor
appears at the beginning of line 120 so that the line can be changed.
Pressing the RETURN key replaces the line in the program.
Page 5-lO
DeltaBASIC Reference Manual COMMANDS
LISTE' (line—mm l,line—num 2)
The LISTP command lists the current program to the printer (the list device)
either in its entirety or over the optional line number range (1ine-num 1
through líne-num 2).
Examples:
LISTP (return key)
The entire program is listed to the printer.
LISTP 100,300 (return key)
Program lines IDO through 300 are listed to the printer.
Page 5-11
DeltaBASIC Reference Manual COMMANDS
LOAD {drv: }name{.typ){,S}
The LOAD command loads the named DeltaBASIC program frorn disk. The file name
can include adisk drive reference and file type. The Soption is used to
load asource (ASCII) file. The defaults file types are BAS for non-source
files and SRC for source files.
Open files are closed before loading begins. Loading anon-source file clears
the data area of memory, thus destroying all previously defined variables.
Loading asource program also clears the data area, but the program area is
left intact, with the new program merged into the current program. In case
of duplicate line numbers, the old line is replaced by the new line.
Examples:
LOAD PAYMAIN (return key)
The program PAYMAIN.BAS (BAS is the default file type) is loaded into memory.
LOAD C: PAYMAIN,S (return key)
The source (ASCII) program PAYMAIN.SRC is loaded from drive C, merging with
the current program.
Pmze S-12
De1taBASIC Reference Manual COMMANDS
OFF {char-expr}
The OFF command returns control to the operating system after first closing
any open files. For computer systems using TurboDOS and CP/M 3.0, the
optional character expression specifies acommand line to be executed upon
return to the operating system.
OFF can be used as program statement to terminate program execution. Unlike
the END statement, which returns to the command/program edit mode, OFF returns
to the operating system.
Example:
OFF (return key)
Operation returns to the operating system after closing any open files.
999 OFF "KEYSORT CUSMAS"
In CP/M 2.2 systems, the program terminates and returns control to the
operating system. In TurboDOS and CP/M 3.0 systems, the program terminates,
returns control to the operating system, and then begins execution of the
specified command line.
Page S-13
DeltaBASIC Reference Manual COMMANDS
RENAME (drv: )name l{.typ},name 2{.typ)
The RENAME command changes the name of the file specified by name 1to the new
name specified by name 2. The file to be renamed must already exist and the
new name must not be the same as that of an existing file.
Example:
RENAME PAYNAS.BAS,PAYMAS.BAK (return key)
The file PAYMAS.BAS is renamed PAYMAS.BAK.
Page 5-14
DeltaBASIC Reference Manual COMMANDS
RUN
The RUN command executes the DeltaBASIC program currently in memory. Before
execution begins, the data area of memory is cleared and any open files are
closed.
Example:
RUN (return key)
Program execution begins at the first line of the current program.
Page 5-lS
DeltaBASIC Reference Manual COMMANDS
SAVE {drv: }name{.typ}{,S}
The SAVE command saves the DeltaBASIC program currently in memory storing it
on the disk in the specified drive and in afile of the specified name and
type. Certain words are reserved for use by DeltaBASIC and may not be used as
disk file names. For alist of these reserved words, see Appendix B. With
the Soption, the program is saved in source (ASCII) form. The defaults file
types are BAS for non-source files and SRC for source files.
Examples:
SAVE D: PAYMAS (return key)
The program in memory is saved using the file name PAYMAS and type BAS on the
disk in Ddrive. Non-source form is used.
SAVE H0URS,S (return key)
The program in memory is saved on the default drive using the file name HOURS
and type SRC. Source (ASCII) form is used.
Page 5-16
DeltaBASIC Reference Manual STATEMENTS
Section 6. STATEMENTS
DeltaBASIC statements are the instructions used in aprogram to accomplish
such tasks as reading data, performing computations, or printing results. In
the command/program edit mode, astatement preceded by aline number becomes
part of the current program. Most statements can be executed directly by
entering the statement without aline number and pressing the RETURN key.
You can put more than one statement on aline, but such multiple statements
must be separated by acolon. The maximum line length is 240 characters.
Page 6-l
DeltaBASIC Reference Manual STATEMENTS
CHAIN {drv: )name{.BAS) {,FILES}{,var-list}
The CHAIN statement provides away to pass execution from the program in
memory to aprogram on disk. It replaces the current program with the program
specified, then continues execution. The chained program must be in non-
source form (type BAS).
Files will be closed unless the FILES option is taken. All variables except
those in the variable list will be removed from the data area. When an array
name appears in the variable list, the entire array remains after chaining to
the new program.
Examples:
100 CHAIN ACTPAY.BAS,PAYDATE,CLIENT
The current program is replaced with the program ACTPAY.BAS from the default
drive. All open files are closed, and the variables PAYDATE and CLIENT are
preserved.
10 CHAIN E: ACTPAY,FILES
The current program is replaced with the program ACTPAY.BAS from drive E.
Open files are left open, but all variables are cleared.
Page 6—2
DeltaBASIC Reference Manual STATEMENTS
CLASE #file-ref: {IOERR line-mm)
or {EXIT line—num)
The CLOSE statement closes the file previously opened under the file reference
given. IOERR or EXIT provides abranch line number should an error occur.
It is very important to close files that are no longer in use. The CLOSE
statement provides this capability for individual files during program
execution. To close all open files at program termination, use the END or OFF
statement. GO END will take care of closing all open files after an
interruption. Remember, STOP does not close files.
Example:
20 CLOSE #1: IOERR lOó
P 0 0
lOó REM I/O ERROR PROCESSING
000
The file with file reference number lis closed. Should an I/O error occur,
execution will continue at line 100.
Page 6-3
DeltaBASIC Reference Manual STATEMENTS
DATA cnst-list
The DATA statement is used to create adata list within aprogram. This
internal data list is then used in conjunction with the READ statement to
assign data values to program variables.
After entering RUN or executing RESTORE, an internal data pointer is set to
the first constant of the first DATA statement. As READs are executed, the
data pointer will move through the constants in that line and to other DATA
statements as necessary, always keeping track of the next constant to be read.
The internal data pointer can be positioned at any DATA statement in the
program using the ON...RESTORE statement. (See ON...RESTORE, below.)
ADATA statement must be the first statement on a line and cannot be followed
by any executable statement on the same line. Remarks are permitted at the
end of aDATA line. (See REM, below.)
Anull data entry leaves the corresponding variable unchanged. (See the
example below.)
Example:
10 READ NÁME$,RATE,TIME
0 D 0
20 READ NAME$,RATE,TIME
* O 0
30 DATA "sMITH,jIM",4.50,6.25,"mE,jANE",,12.00
When line 10 is executed, variable assignments are made as follows:
NAME$: SMITH,JIM
RATE :4.50
TIME :6.25
The data pointer will then point to D0E,JANE. When line 20 is executed, these
additional assignments will be made:
NAME$: D0E,JANE
TIME :12.00
RATE remains 4.50 since anull entry appears in the DATA statement.
Page 6-4
DeltaBASIC Reference Manual STATEMENTS
DEF FNname{$}{(var-1íst))=expr
The DEF statement defines auser function that can be referenced by name in
the program, as follows:
FNnarne{$){(expr-1ist))
During execution, each expression in the optional expression List is evaluated
and its value passed to the corresponding variable in the DEF statement. The
expression in the DEF statement is then evaluated and the result is passed
back.
Expression list items must agree in number and type (numeric or character)
with the items in the DEF variable list. Functions can be either numeric or
character, but character functions must be indicated by the dollar sign (S) in
the function name. The function name contains from lto 8alphanumeric
characters, the first character of which must be alphabetic. Certain words
are reserved for use by DeltaBASIC and may not be used as function names. For
alist of these reserved words, see Appendix B. Variables used in afunction
are local to that function; i.e., are used only within that function.
ADEF statement must be executed before the user function is referenced in the
program. Once it is defined, it cannot be redefined by second DEF statement.
Afunction statement cannot include areference to itself or refer to a
function that includes areference to itself.
Examples:
10 DEF FND(S,D)=S*D
0 * »
30 DISTANCE=2*FND(SPEED,DURATION)
Assume SPEED is 30 and DURATION is 10. When line 30 is executed, the
following assignments are made:
S: 30
D: 10
FND is evaluated as 300 and passed back to the expression of line 30.
Evaluation is completed and the assignment made:
DISTANCE: 600
l0 DEF FNCI.ASS$(P$,N$)=P$&" "&N$
* * ¥
30 CLASS$=FNCLASS$(PREFIX$,NUHBER$)
Assume PREFIX$ is ART and NUMBER$ is 124A. When line 30 is executed, the
following assignments are made:
P$: ART
N$: 124A
Using these values, the user-defined function of line 10 is evaluated to ART
124A. This result is passed back to the character expression of Line 30,
Page 6—S
DeltaBASIC Reference Manual STATEMENTS
DIM var(m{,n,·..)) {,var(m(,n,.··})) {g·-·}
var$(m{,n,...)){*L) {,var$(rn{,n,...}){*L))
var$*L {,var$*L}
The DIM statement is used to assign space for numeric and character arrays in
the data area of memory, and to fix the maximum length of character variables.
The constants m,n,... are maximum dimension sizes and L is the maximum
character string length for acharacter array element.
Array subscripts begin with 1. Array variables can be dimensioned only once
in aprogram.
Example:
10 DIM SALES(10,1O),SAf.EM$(10)*30,TEMP$*lO
When executed, the following allocations are made:
SALES :two-dimensional numeric array of size 10 by 10
SALEM$: one-dimensional character array of size 10 by I;
each character element with length 30
TE!'ÍP$ :single character variable with length 10
Page 6-7
DeltaBASIC Reference Manual STATEMENTS
END
The END statement is used to terminate aDeltaBASIC program. It closes all
files and returns DeltaBASIC to the command/program edit rnode.
Program exit should be through the END statement if you want to remain in
DeltaBASIC command/program edit mode afterwards. Terminating a program with
END (or OFF) is especially important to ensure that files otherwise left open
are properly closed.
Example:
9999 END
When program termination is required, statement 9999 is executed. All open
files are closed and DeltaBASIC enters the command/program edit mode.
Page 6-8
DeltaBASIC Reference Manual STATEMENTS
EXIT {IOERR line-mm} {,IOERR line—mm) (9···)
{DUPKEY line-num) {,DUPKEY line-num}
{NOKEY line-mm) {,NOKEY line-mm)
{EOF line-mm) {,E0F line-num)
The EXIT statement can be used with OPEN, READ, WRITE, REWRITE, and CLOSE
statements to provide branching when the specified errors occur. (See the
appropriate statements for more information concerning these errors.) The
EXIT statement can be accessed only by way of one of these I/O statements;
when otherwise encountered during execution, EXIT is ignored much as a REM
statement would be.
EXIT is especially useful when anumber of I/O operations have the saíne error
processing lines. Each I/O statement would contain an EXIT line number
referring to the EXIT statement, which would in turn contain the line numbers
for the various error traps.
Examples:
10 READ #1,USING II: A,B EOF 100 IOERR 130
II FORM ...
0 0 0
lOó REM END-OF-FILE ERROR PROCESSING
105 ...
00 O
130 REM I/O ERROR PROCESSING
135 ...
EXIT is not used in this program segment. If an end-of-file error occurs
while file #1 is being read, the program branches to line 100 for recovery
processing. If an I/O error occurs, the program branches to line 130.
Yow consider an equivalent method using the EXIT statement.
10 READ #I,USING II: A,B EXIT 20
11 FORM ...
20 EXIT EOF 1OO,IOERR 130
0 9 0
lOó REM END-OF-FILE ERROR PROCESSING
105 ...
000
130 REM l/O ERROR PROCESSING
135 ...
An error in the READ statement of line 10 causes execution to divert to the
EXIT statement of line 20. Here the various error conditions are handled.
Besides making the READ statement simpler, the EXIT statement can be used by
other I/O statements for error branching to line 20.
Page 6-9
DeltaBASIC Reference Manual STATEMENTS
FUR var=num-expr ITO nuin-expr 2{STEP num-expr 3}
0 e D
included DeltaBASIC staternents
ee *
NEXT var
The FOR/NEXT statements set up a loop that performs the included DeltaBASIC
statements one or more times, depending on the beginning value of the index
variable (num-expr I), ending value (num-expr 2), and the step size (nurn-expr
3). If not specified, the step size is l.
The included DeltaBASIC statements will be executed at least one time before
termination conditions are checked. The "exit" value of the index variable
will be the first value that meets or exceeds num-expr2.
FOR/NEXT loops can be nested to alevel of 8deep.
Exiting aFOR/NEXT loop before normal termination is allowed but not
recommended. Repeated exits of this type will cause the maximum FOR/NEXT
level to be exceeded.
Examples:
10 FOR INDEX=1 to 20 STEP 2
20 PRINT INDEX
30 NEXT INDEX
These FOR/NEXT statements cause line 20 to be executed 10 times, printing the
values from 1to 19 in steps of 2. The "exit" value of INDEX is 21.
Page 6-10
DeltaBASIC Reference Manual STATEMENTS
FORM specification list
The FORM statement gives the format specification for PRINT, READ, WRITE, and
REWRITE statements. The specification list can consist of any combination of
the following specifications, separated by commas:
"char-cnst"
Character constant: the character string between the quotation marks is
output at the current position. Allowed in PRINT and WRITE only.
Cw
Character field: the matching character value is treated as acharacter
string that is left-justified in ablank field of width w.
CUR(m,n)
Cursor: the next value will be output at line mand position n. Allowed in
PRINT only.
Nw{.d)
Numeric field: the matching numeric value is treated as acharacter string of
width w, including ddecimal positions. For output, the width must include
both asign and decimal point position. For input, an explicit decimal
overrides the implicit decimal position d.
PI) w.d
Packed decimal: the matching numeric value is given in packed decimal format.
For output, the value is rounded to ddecimal places, then packed two binary
coded decimal digits per position and written right-justified into afield of
width w. Only the low nibble of the leftmost position contains adigit. The
high nibble is 0000 binary for apositive value and 1000 binary for a
negative. As with zone decimal, no explicit decimal is written. For input,
the value is read from afield wwide and then given ddecimal positions.
Packed decimal is not allowed in the PRINT statement.
PIC(char-str)
Picture: the matching numeric value is written into afield with width and
composition given by the character string. Valid characters are described
below:
#
Number digit: always replaced by adigit.
Z
Leading zero: any leading zero replaced by ablank.
Page 6-11
De1taBASIC Reference Manual STATEMENTS
$
Leading dollar sign: dollar sign placed to the left of the first nonzero
digit.
+
Leading plus sign: plus sign placed to the left of the first nonzero
digit for apositive value, or aminus sign placed to the left of the
first nonzero digit for anegative value.
Leading negative sign: blank placed to the left of the first nonzero
digit for apositive value, or minus sign placed to the left of the first
nonzero digit for anegative value.
Blank (ASCII space)
Ablank is placed in the field.
?
Comma: a comma is inserted in the field if anonzero digit precedes it;
otherwise, the comma is replaced with ablank.
0
Decimal point: adecimal point is placed in the field. Only one decimal
point can appear in the character string.
+
Trailing plus sign: aplus sign is placed to the right of the last digit
for apositive value, or aminus sign is placed to the right of the last
digit for anegative value.
Trailing minus sign: ablank is placed to the right of the last digit
for apositive value, or aminus sign is placed to the right of the last
digit for anegative value.
CR or DB
Credit or debit code: CR or DB is placed to the right of the last
nonzero digit for anegative value, or two blanks are placed to the right
of the last digit for apositive value.
POS n
Position: the next value will be input or output at position n.
Page 6-12
DeltaBASIC Reference Manual STATEMENTS
SKIP n
Skip lines: the next nlines are skipped. Allowed in PRINT only.
Xn
Skip positions: the next npositions are skipped.
ZD w.d
Zone decimal: the matching numeric value is given in zoned decimal format.
For output, the value is rounded to ddecimal positions and written in ASCII
without adecimal point, right-justified into afield of width w. For a
negative output value, the high bit of the leftmost position is set to 1. For
input, the value is read from afield wwide and then given ddecimal
positions. Zone decima1 is not allowed in the PRINT statement.
Note: Specifications N, C, ZD, and PO can be preceded by aconstant
replication factor and an asterisk (*); for example, 2*N 6.2 will set up two
contiguous numeric fields of width 6with 2decimal positions.
AFORM statement must be the first statement on a line and cannot be followed
by any executable statement on the same line. Remarks are permitted at the
end of aFORM line.
Adollar sign ($), leading plus (+), or leading minus (-) character cannot
follow a#.
Examples:
20 Print #255,USING 21: A,B$
21 FORM "A=",N 9.2,X 2,C 4
Assume Ais 12.258 and B$ is BAJ.. When line 20 is executed, the printed line
would appear as follows:
A= 12.26 BAL
·...)....1....)....2
OO
Now consider the effect of using aPIC specifier in place of N9.2 in the
above example:
PIC specification Value of APrinted Result
######.## 12.258 000012.26
ZZZZZ#.## 12.258 12.26
ZZZZZ#.## -12.258 -12.26
+++++#.## 12.258 +12.26
+++++#.## -12.258 -12.26
-----#.#// 12.258 12.26
-----it## -12.258 -12.26
$$$$$#.#//CR 12.258 $12.26
$$$$$#.##CR -12.258 $12.26CR
Page 6-13
,DeltaBASIC Reference Manual STATEMENTS
Here is an example using zoned decimal format:
30 WRITE #3,USING 31: A,B$
31 FORM ZD 5.2,POS 9,C 10
Assume Ais 2.528 and B$ is ABCD. When line 30 is executed, the written
record would appear in hexadecimal as follows:
VALUE +0 O 2 5 3 A B CD
HEX 30 30 32 35 33 20 20 20 41 42 43 44 20 20 20 20 20 20...
POS —- -- -- -- 5-- -- 10 —— -- -- 15 —- -- --
SPEC !ZD 5.2 )POS 9—>) C10
To see how packed decimal format works, consider the following data record and
program segment:
VALUE +0 02 58 -O 02 58 +0 O25 8 -O O25 8
HEX 00 02 58 80 02 58 30 30 32 35 38 bo 30 32 35 38
pos -- -- -- -- 5-- -- -- -- 10 -- -- -- -- 15 -- -- --
spec pd 3.lj )pd 3j lzd 5.1 !)zd 5.1 !
40 read #6,using 41: a,b,c,d
41 form 2*pd 3.1,2*zd 5.1
When line 40 is executed, the values assigned are as follows:
A: 25.8
B: -25.8
c: 25.8 "
D: -25.8
Page 6—14
DeltaBASIC Reference Manual STATEMENTS
GOSUB line—mm
The GOSUB statement branches to asubroutine at the specified line number. A
RETURN in the subroutine branches back to the statement immediately following
the GOSUB.
GOSUBs can be nested up to 20 deep.
Exiting asubroutine without using RETURN is allowed but is not considered
good practice since it leaves the nested level incorrect. Repeated exits of
this type will cause the maximum GOSUB level to be exceeded.
Example:
10 GOSUB 50
20 ...
Oe0
50 REM SUBROUTINE
e 0 0
60 RETURN
When line 10 is executed, the program branches to the subroutine at line 50.
The RETURN at line 60 branches back to line 20.
Page 6-lS
DeltaBASIC Reference Manual STATEMENTS
t
G(YID líne—num
The GOTO statement branches to the specified line number.
Example:
10 GOTO 50
0e0
50 ...
When statement 10 is executed, the prograrÍí branches to line 50.
Page 6-16
DeltaBASIC Reference Manual STATEMENTS
IF log—expr THEN line—mm or statement {ELSE line—mm or statement}
The IF statement branches or executes astatement depending on whether the
logical expression evaluates to true or false. If true, execution continues
at the line number or statement following THEN. If false, execution continues
at the next statement in the program or, if the ELSE option is used, at the
line number or statement following the ELSE.
Examples:
10 IF A>=B+C THEN B=Á
20 ..
When line 10 is executed, A>=B+C is evaluated. If Ais greater than or equal
to the sum of Band C(making the the expression true), then Bis assigned the
value of A. If Ais not greater than or equal to the sum of Band C(making
the expression false), then the value of Bis not changed. In both cases,
execution continues at line 20.
10 IF NAME$<>TEMP$ AND A<B THEN A=B-C ELSE 100
20 ...
0 0 0
100 ...
If NAME$ is not equal to TEMP$ and Ais less than B, then the program assigns
the value of expression B-C to Aand continues at line 20; otherwise, it
branches to line 100.
Page 6-17
DeltaBASIC Reference Manual STATEMENTS
INPUT {"char—str": }var—list
The INPUT statement allows the operator to enter data values from the keyboard
during program execution. When the INPUT statement is executed, aquestion
mark (?) is displayed as a prompt unless the optional character string
(message prompt) is included. The user then enters the data values (separated
by commas) that are to be assigned to each variable in the variable list, and
presses the RETURN key to continue program execution.
If the correct number of data values is not entered, aquestion mark (?) is
displayed and INPUT continues. If avariable/data type mismatch occurs, a
REDO message is displayed and INPUT must be redone from start.
To enter leading blanks with acharacter string, enclose them within the
quotation marks.
Example:
10 INPUT "ENTER NAME, AMOUNT: ": NAME$,AM0UNT
When line 10 is executed, the message is displayed and execution pauses while
the name and amount are entered, separated by acomma:
ENTER NAME, AMOUNT: JOE SMITH,1200 (return key)
The following assigments are made:
NA9IE$ :JOE SMITH
AMOUNT :1200
Page 6-18
DeltaBASIC Reference Manual STATEMENTS
{LET) num—var=num—expr
{LET) char—var {(num—expr l:num—expr 2))=char-expr
The LET stateinent assigns the value of an arithinetic or character expression
to the specified variable.
For the character LET, the optional substring specification can be used to
delete, replace, or insert characters in the character variable, depending on
the optional parameters, as follows:
nurn-expr 1'<= num-expr'2
Character positions from nurn-expr 1through nurn-expr 2are replaced by the
character expression. The number of replacement characters can be less than,
equal to, or greater than the number being replaced.
num-expr1 >num—expr 2
The character expression is inserted before the character position given by
num-expr l. In this case, num-expr 2is ignored.
Examples:
10 A=2*B
20 C$=ADRS$&" "&ZIP$
Assume Bis 6, ADRS$ is "lOó MAIN sr', and ZIP$ is "29012". When lines 10 and
20 are executed, the following assignments are made:
A:12
C$: 100 MAIN ST 29012
To see how LET can delete characters, asswne A$ in the following statements is
ABCD.
10 A$(2:2)=""
When executed, line 10 will delete the letter B(the second character
position) from A$, so that A$ becomes ACD.
Characters can be substituted in asimilar manner:
ID A$(2:3)="123"
This statement replaces BC with 123, so that A$ becomes A123D.
Now consider asubstring assignment to insert characters.
10 A$(2:!)="XY"
Since nurn-expr 2is less than nurn-expr l, num-expr 2is ignored and the
characters XV are inserted before B. A$ becomes AXYBCD.
Page 6-19
DeltaBASIC Reference Manual STATEMENTS
LINPUT {"char-str":}char-var
The LINPUT statement assigns an entire line eritered from the keyboard to the
specified character variable. Unlike the regular INPUT statement, LINPUT
reads acomma as part of the data entered rather than as a data separator. A
question mark (?) is displayed as aprompt unless the optional character
string (message prompt) is included.
Example:
10 LINPUT NAME$
This statement assigns keyboard-entered characters to NAME$ until the RETURN
key is pressed. If the line entered is
SMITH,J0E Q. (return key)
then the following assignment is made:
NAME$: SMITH,J0E Q.
Page 6-20
DeltaBASIC Reference Manual STATEMENTS
ON ATTN GOTO line-mm
IGNORE
The ON ATTN statement selects alternate ways of handling program interruptions
caused by pressing the ATTN key. Normally the program is terminated and the
command/program edit mode is entered. Using ON ATTN GOTO will instead cause
branching to the specified line number should the ATTN key be pressed. The ON
ATTN IGNORE form will result in the ATTN key being ignored altogether.
The ON ATTN selection can be turned off by using:
ON ATTN GOTO O
Example:
10 ON ATTN GOTO IDO
20 ...
00e
lOó )ATTN RECOVERY PROCESSING
If the operator presses the ATTN key at any time after line 10 is executed,
the program braches to line lOó for recovery processing.
10 ot: ATTN IGNORE
* P 0
Following execution of line 10, pressing the ATTN key will have no effect on
program operation.
Page 6-21
DeltaBASIC Reference Manual STATEMENTS
ON Error Condition GOTO líne-num
where Error Condition can be CONY, ERROR, OFLOW, UFLOW, SOFLOW, or ZDIV.
The ON Error Condition statement sets the line number for an error trap. If
that error occurs, the program branches to the specified line number for
recovery processing. Error conditions result from avariety of causes. See
Appendix Afor more information.
The error trap can be removed by using:
ON error condition GOTO O
Example:
10 ON ZDIV GOTO lOó
00 0
30 B=12/A
35 A=A+1
0 0 D
lOó B=1E+60
105 GOTO 35
Assume Ais O. When line 10 is executed, the division-by-zero error trap line
is set to lOó. When azero division error occurs in line 30, the program
branches to line 100, where arecovery procedure is executed.
Pzaoe 6—22
DeltaBASIC Reference Manual STATEMENTS
ON num—expr GOSUB line—mm 1{,line—num 2,...}
The ON..,,G0SUB statement causes a branch to one of several lines, depending on
the valué of the numeric expression. The value is first rounded to an
integer, then if it is 1, the program branches to line-mm I; if 2, to line-
num 2; etc. An invalid expression value causes execution to continue at the
statement following the ON...GOSUB.
After branching to asubroutine, subsequent execution of aRETURN branches
back to the first statement following the ON...GOSUB. As with astandard
GOSUB, leaving the subroutine other than by anormal RETURN statement should
be avoided.
Example:
10 ON 2*A-l GOSUB 20,30,40
15 A=A+1
2¿)'ij$=HI$
25 RETURN
30 B$=MED$
35 RETURN
40 B$=LOW$
45 RETURN
?
Assume Ai's 2. When line 10 is executed, the numeric expression 2*A-l
evaluates to 3and the program branches to line 40. At line 45, the program
branches back to line 15.
Page 6-23
DeltaBASIC Reference Manual STATEMENTS
ON num—expr GOTO line—mm l{,line—num 2,...}
The ON...GOTO statement causes a branch to one of several lines, depending on
the value of the numeric expression. The value is first rounded to an
integer, then if it is 1, the program branches to line-num l; if 2, to line-
num 2; etc. An invalid expression value causes execution to continue at the
statement following the ON...GOTO.
Example:
10 ON 3*(A+l)/5 GOTO 20,30,40
15 A=A+1
2á'á$=HI$
25 GOTO 50
30 B$=MED$
35 GOTO 50
40 B$=LOW$
50 ...
Assume Ais 2. When line 10 is executed, the numeric expression 3*(A+l)/5
evaluates to 1.8, which is rounded to 2. The program therefore branches to
line 30.
Page 6-24
DeltaBASIC Reference Manual STATEMENTS
ON num—expr RESTORE line-mm l{,line-num 2,...)
The ON...RFSTORE statement sets the internal data pointer to one of several
lines, depending on the value of the numeric expression. The value is first
rounded to an integer, then if it is I, the internal data pointer is restored
to line—num l; if 2, to Line-num 2; etc. An invalid expression value results
in no RESTORE being executed.
Example:
ID ON 3*(A+I)/5 RESTORE 20,30,40
15 A=A+1
0 O ¥
20 DATA 7,8,9,0
30 DATA 4,5,6,0
40 DATA 1,2,3,0
Assume Ais 2. When line 10 is executed, the numeric expression 3*(A+l)/5
evaluates to 1.8, which is rounded to 2. The data pointer is set to the first
data value on line 30.
Page 6-25
DeltaBASIC Reference Manual STATEMENTS
OPEN #fiíe—ref: char-expr,fi1e attributes {IOERR line-mm}
or {EXIT line-mm)
(Open adisk file)
The OPEN statement opens a disk file for input, output, or update access. The
file reference number can be any integer from lthrough 254. (File #0 is
reserved for regular display terminal operation and #255 is reserved for
printer operation. These special file references do not require OPEN statements.)"
The disk file ID is specified by char-expr and includes the following
parameters (separated by commas):
(i) NAME={drv: }name{.typ} -- required data file name.
(ii) NEW -— used only if a new file is being created.
(iii) RECL=record length (1-2048 bytes) -- required if NEW specified..
(iv) KEYL=key length (1-32) -- required if NEW specified and the new
file is to be keyed.
(V) KEYP=key position -- required if NEW specified and the new file
is to be keyed.
(vi) RANDOM -- used if akeyed file is to be accessed randomly by key
or if records are to be added to akeyed file.
(vii) SHR —— required if the file is to have ashared status in a
multi—user environment.
The file attributes include the following parameters (each preceded by a
comma):
(i) KEYED if the file is to be accessed by key or RELATIVE if the
file is to be accessed by record number. If neither KEYED nor
RELATIVE is specified, then sequential access is selected by
default.
(ii) INPUT if the file mode is input (reads only allowed) or OUTPUT
if the file mode is output (writes only allowed). If neither
INPUT nor OUTPUT is specified, then update mode is selected
(both reads and writes allowed).
(iii) BEGIN if sequential/output access is to begin at record one
rather than at the end of the file.
If an I/O error occurs and IOERR line-num is specified, then execution
continues at the line number given. If EXIT line-num is given instead, the
EXIT statement at the specified line is used. If neither IOERR nor EXIT line-
num is specified, an error interruption results.
For more information about disk file I/O, see Appendix C.
Page 6-26
I)e1taBASIC Reference Manual STATEMENTS
Examples of disk file openings:
LO OPEN #1: "NAM=PAYTRN.DAT,NEW,RECL=200",OUTPUT ÍOERR 200
Line 10 creates the new file PAYTRN.DAT with arecord length of 200. Since
neither KEYED nor RELATIVE access is specified, records will be arranged
sequentially, in the order they are written. The first record written will be
record I. The OUTPUT attribute prescribes that file reads are prohibited. If
an I/O error occurs, execution will continue at line 200.
10 OPEN #1: "NAME=PAYTRN.DAT",0UTPUT
Since neither I"EYED nor RELATIVE is specified, access will be sequential.
With the OUTPUT attribute, file reads are prohibited. Since BEGIN is not
specified, new records will be added to the end of the file. This file
opening would be used to add records to an existing file.
10 OPEN #1: "NAMF.=PAYTRN.DAT" EXIT lOó
Since neither KEYED nor RELATIVE is specified, access will be sequential.
Without INPUT or OUTPUT specified, both file reads and rewrites are permitted
(update mode). The first read will access record I. Subsequent reads will
access the remainder of the file in asequential manner (record 2, record 3,
etc., to the end-of-file). If an error occurs, the EXIT statement at line 100
is referenced for error recovery processing. This file opening would be used
to update records in the file PAYTRN.DAT.
10 OPEN #1: "NAM=PAYTRN.DAT",RELATIVE,INPUT
Record file PAYTRN.DAT is opened for read-only access by relative record
number. Requesting arecord beyond the current end of file results in an
error.
10 OPEN Ill: "NAME=pAMAs.DAT,NEw,REcL=3Q0,KEYL=l0,KEYp=1,RAND0M",KEyED,0UTpUT
This file opening would be used to build a new keyed file. File PAYPIAS.DAT is
created with record length 300. Key length is 10 and the key begins in
position I. Since OUTPUT and RANDOM are specified, only new records can be
added to the file.
lCl OPEN #1: "NAME=pAmAs.DAT,RANDo}í",KEYED,INpUT
Keyed file PAYMAS.DAT is opened for random access by key. Since INPUT is
specified, only reads are permitted. This file opening would be used to
obtain data randomly by key.
10 OPEN #1: "!iAM=pAYMAs.DTA",KEYED
Keyed file PAYMAS.DAT is opened for sequential access by key. Since neither
INPUT nor OUTPUT is specified, both reads and rewrites are permitted (update
mode). This file opening could be used to update records in order by key.
Page 6—27
DeltaBASIC Reference Manual STATEMENTS
OPEN Kile-ref: char-expr {IOERR Iíne-num)
or {EXIT line-mm}
(Open avork station file)
The OPEN statement opens a work station file for update access. The file
reference number can be any integer from 1through 254. (File #0 is reserved
for regular display terminal operation and #255 is reserved for printer
operation. These special file references do not require OPEN statements.)
The file ID is specified by char-expr and includes the following parameters
(separated by commas):
(i) WS -- required.
(ii) NAME={drv: )name.FRM -- required screen format file name.
(iii) RECL=constant -- required.
The file specified must be of type FRM and created by the screen design
utility program SDU.COM. The record length must be greater than or equal to
the length of the longest screen input or output buffer in the screen format
file.
If an I/O error occurs and IOERR 1ine-num is specified, then execution
continues at the line number given. If EXIT line-num is given instead, the
EXIT statement at the specified line is used. If neither IOERR nor EXIT line-
num is specified, an error interruption results.
When awork station file is opened, the display file (#0) automatically
closes. The INPUT and PRINT statements cannot be used with the display
terminal until the work station file is closed.
For more information about work station files, see Appendix D.
Examples:
10 OPEN #1: "WS,NAME=PÁY.FRM,RECL=200"
This statement closes the display station file (#0) and opens work station
file #1. PAY.FRM contains the screen formats to be used. The maximum input
or output buffer length is 200, which requires the record length to be set to
200. Screen output and keyboard input are performed using READ #1.../WRITE
#1... statements. If work station file #1 is later closed, the display
station file #0 will automatically reopen.
Page 6-28
DeltaBASIC Reference Manual STATEMENTS
OPTION {PRTZO II}, (,SPREC or LPREC), {,PTRSET s,l,n,o), {,PTRSK1 s,char-
expr 1, char—expr 2)
The OPTION statement provides the user the choice of certain options:
(i) PRTZO n: print zone width of n(l to BO) characters (default width is
16)
(ii) SPREC: short precision in ca1culation--8 digits (default is SPREC)
LPREC: long precision in ca1culation--16 digits.
(iii) PRTSET s,l,n,o: Printer forms control, where:
s=0N: automatic form feed on page overflow
s=OFF: automatic form feed suppressed
1=line length: Oindicates no change from the previous setting (default
value is 132)
n=1ines per page: Oindicates no change (default value is 66)
o=page overflow line: Oindicates no change (default value is 64).
(iv) PRTSET s,char-expr l,char-expr 2: Printer mode control for TurboOOS
operating system only, where:
s=D ... printing is direct
s=S ... printing is to spooler
s=C ... printing is to console
s=U ... unchanged
char-expr 1=Printer or Spooler assignment (A-F',U)
char-expr 2=Spool drive (A-P,U)
Options do not take effect until the statement is executed.
Example:
10 OPTION PRTZO 20,LPREC,PTRSET ON,0,58,52,PRTSET S,"A","E"
When line 10 is executed, the following options are selected:
Print zone width is set to 20.
Long precision arithmetic is selected.
Printer will automatically form feed on page overflow, line length is
unchanged, lines per page is set to 58, and page overflow point is
set at line 52.
Output to printer is routed to spooler Aon drive E(TurboDOS only).
Page 6-29
DeltaBASIC Reference Manual STATEMENTS
PRINT {#255:)list {; or .)
(Unformatted PRINT)
The unformatted PRINT statement outputs the specified list to the display
terminal or, if #255 is used, to the printer. The list can consist of any
combination of the following data items:
arithmetic expressions
character expressions
TAB({1,)p) -- moves to position por, optionally, to line 1position p
NEWPAGE -- sends clear screen command to display or new page command
to printer
The items must be separated by a comma to left-justify data items into columns
or zones (see OPTION, above) or by asemicolon if data items are to be
adjacent on the line. Ending the list with a comma or semicolon inhibits a
final carriage and line feed.
Examples:
10 PRINT "TODAY ";8$;" IS";A;" YEARS OLD."
Assume Ais 10 and B$ is ROBERT. When line 10 is executed, the following line
is output to the display terminal:
TODAY ROBERT IS 10 YEARS OLD.
·...!....1....)....2....)....3
OO O
Note that spaces between words must be supplied in the character expressions.
10 FOR I=l TO 4
20 PRINT E255: I,I1*I
30 NEXT I
This short program outputs the following multiplication table (arranged in 16-
position columns) to the printer:
1l
24
39
416
....!....1....)....2
OO
Page 6-30
DeltaBASIC Reference Manual STATEMENTS
PRINT {f255,)USING line-mm: expr-list
(Formatted PRINT)
The formatted PRINT statement outputs the expression list to the display
terminal, or if //255 is specified, to the printer, using format specifications
given by the FORM statement at the USING line number. (Sec the explanation of
FORM statements above.) The expression list consists of numeric or character
expressions separated by commas.
Example:
10 PRINT USING li: B$,2*A
II FORM "SERIAL NO. ",C lO,X 2,"WEIGHT: ",N 8.2
Assume Ais 12.347 and B$ is A1O-1897. When line 10 is executed, the
following is output to the display terminal:
SERIAL NO. A1O-1897 WEIGHT: 24.69
·...)....1....|....2....)....3....)....4
OOOO
Modifying line 10 as shown below will direct output to the printer instead.
10 PRINT #255,USING li: B$,2"A
Page 6-31
DeltaBASIC Reference Manual STATEMENTS
READ var—list
(Read internal data)
This READ statement assigns the named variable adata value from the current
position of the internal data pointer. The data pointer is then advanced to
the next data value. (See the DATA statement above.)
Example:
10 READ NAME$,A?40UNT
*0 P
50 DATA JOHN JONES,I0.50,JANE SMITH,8.40
Assume the data pointer is set to JOHN JONES. Line ID makes the following
assignments:
NAME$: JOHN JONES
AMOUNT: 10.50
The data pointer then advances to JANE SMITH.
Page 6-32
DeltaBASIC Reference Manual STATEMENTS
READ #file—ref,USING Iíne—num {,KEY=char—expr) :var-list {IOERR line-mm}
{,KEY>=char-expr) {NOKEY line-mm)
{,REC=num-expr) {EOF line—mm)
or {EXIT line-mm)
(Read adisk file)
This READ statement reads data from the disk file specified by the file
reference number. Variables separated by commas in the variable list are
assigned values from the current record of the file, using the specifications
in the FORM statement given by the USING line number.
KEY=char-expr specifies that the record with the given key be read. If the
record is not found and NOKEY is specified, execution continues at the NOKEY
line number; otherwise, an error is reported. The file must be open for
keyed-random/input or keyed-random/update access.
KEY>=char-expr specifies that the first record with akey greater than or
equal to the given key be read. The file must be open for keyed-
sequential/input or keyed-sequentia1/update access.
REC=num-expr specifies that the record with the given record number be read.
The file must be open for relative/input or reiative/update access.
Reading anon-keyed file sequentially results in the next record being read
until an end of file indication is encountered. If akeyed file is read
sequentially, the records are taken in order by key until all sorted keys are
read (see KEYSORT utility, Section 8). In either case, if an EOF line number
is given, the program will then branch to that line; otherwise, an error
results. IOERR, NOKEY, and EOF errors can be trapped at the specified line
numbers, or an EXIT statement can be used.
Examples:
10 READ #1,USING 15,KEY="PENCIJ.": COST NOKEY 100 IOERR 200
15 FORM POS 1O,ZD 7.2
0 0 e
100 REM NOKEY ERROR PROCESSING
e 0 0
200 REM I/O ERROR PROCESSING
Assume file #1 is open for keyed/random access. When line 10 is executed,
file #1 is read using the key PENCIL. If the record is found, the stored
value is assigned to COST. If no key is found, the program branches to line
100. Should an I/O error occur, execution will continue at line 200.
10 READ #15,USING IS: KIND$,SIZE EOF 100
15 FORM X2,C lO,X 6,PD 4
0* *
lOó REM END-OF-FILE ERROR PROCESSIXG
Assume file #15 is open for non-keyed sequential access. When line 10 is
executed, the next record of file #15 is read and the stored values are
assigned to variables KIND$ and SIZE. If the end-of-file is encountered,
execution continues at line 100.
Page 6-33
DeltaBASIC Reference Manual STATEMENTS
READ #file—ref,USING line—mm: var—list
(Read awork station file)
This READ statement reads data from awork station file. In this case, the
only data record is the screen input buffer. The USING line number gives the
F0R7'Í statement that describes how the variables are read. When awork
station read is executed, the user enters data into the fields displayed on
the screen. Pressing the return key or aspecial function key enters the
screen data into the appropriate variables, and execution continues at the
next statement.
Whenever awork station file is open, INPUT and PRINT cannot be used with the
display terminal.
The following special keys are activated while the work station file is open:
"L Moves the cursor one character to the right.
"H Moves the cursor one character to the Left.
^G Deletes one character to the right.
DEL Deletes one character to the left.
"I Moves the cursor to the next field.
^Z Display field help message if defined. See Note Ibelow.
LINE FEED Moves the cursor to the next field with blank or zero fill.
RETURN Enters the screen data.
FI,F2,... (Function keys) Enters the screen data. See Note 2below.
Note I: The field message facility requires that amessage file of the same
name as the screen and type of MSG be present on the default disk drive.
Pressing the "Z key displays the corresponding field message in the message
file. Pressing "Z asecond time displays the global message for the same
file. At either point, pressing the space bar returns to the data entry
screen. The field message file is created with the GENMSG utility. (See
UTILITY PROGRAMS, Section 8.)
Note 2: After returning to DeltaBASIC, the numeric function CMDKEY can be
used to determine the last key pressed. (See INTRINSIC FUNCTIONS, CMDKEY, in
Section 7.)
Examples:
30 READ #3,USING 31: NAME$,ADRS$,CITY$,ZIP$,BAT.ANCE
31 FORM 3*C 30,C 5,N 8.2
Assume file #3 is open as a work station fil-e. After line 30 is executed, the
user makes changes to the data items on the screen. The work station input
buffer is updated to reflect this data entry. After the RETURN key is
pressed, the work station input buffer is read and assignments are made to the
four variables according to the FORY specification in line 31.
Page 6-34
DeltaBASIC Reference Manual STATEMENTS
REM
REM is anon—executing statement that is used to include remarks or other
documentation in aprogram. The length of aremark is limited by the total
length of the line on which it is found. The REM statement must be the last
statement on aline.
The special character can also be used for including comments in a program.
It is not actually treated as a DeltaBASIC statement but rather as an end-of-
line blanking character--anything entered beyond the will be ignored by the
statement processor. While can appear at the beginning of aline, it cannot
appear following acolon used as amulti—statement separater.
Example:
10 REM THIS IS ACONÍENT
*e 0
20 )THIS IS ALSO ACOMENT
0P 0
30 C0UNT=COUNT+I )A COPMENT CAN BE HERE, TOO.
Page 6-35
DeltaBASIC Reference Manual STATEMENTS
RESET
The RESET statement performs adisk reset to allow diskettes to be changed.
Open files are not closed.
Example:
10 RESET
Nhen line 10 is executed, the disk system is reset.
PaRe 6-36
DeltaBASIC Reference Manual STATEMENTS
RFSTURE
The RESTORE statement moves the internal data pointer to the first data value
of the first DATA statement in the program.
Example:
10 RESTORE
00 $
20 READ A,B
0 0 4
lOó DATA 12,14
200 DATA 14,16
Line 10 sets the data pointer to 12 in line lOó. The READ statement of line
20 will then make the following assignments:
A:12
B:14
Page 6-37
De1taBASIC Reference Manual STATEMENTS
RETURN
The RETURN statement branches back from asubroutine to the main program
Execution continues at the next statement after the GOSUB that called the
subroutine.
Example:
10 GOSUB 50
20 ...
0 0 *
50 REM SUBROUTINE
e0*
60 RETURN
When line 10 is executed, the program branches to the subroutine at line 50.
The RETURN at line 60 branches back to line 20.
Page 6-38
DeltaBASIC Reference Manual STATEMENTS
REm:TE #file—ref,USING line-mm: expr-líst {IOERR line-mm)
or {EXIT line-num)
(Rewrite adisk file)
This REWRITE statement rewrites adisk record that has previously been read.
Expressions are evaluated then rewritten into the disk record using the format
given by the FOR9! statement at the specified USING line number. IOERR or
EXIT provides abranch line number should an error occur.
REWRITE is useful for updating records in adisk file. All or part of the
last record read can be rewritten.
The file must be open in update mode; otherwise an error occurs. In addition,
the last operation to the file must have been aread.
When rewriting akeyed file, an error occurs if the key field is changed.
Example:
30 READ #3,USING 35: A,B,C
35 FORM 3*PD 4.1
40 C=A+B+C
50 REWRITE #3,USING 55: CEXIT lOó
55 FORM POS 9,PD 4.1
0 0 e
lOó EXIT IOERR 200
0 0 $
200 REM I/O ERROR PROCESSING
Assume disk file #3 is open for keyed-sequentia1/update access. When line 30
is executed, data values A, B, and Care read from the record of the next key
in the disk file. Cis then re-computed (line 40) and rewritten to the
original record (line 50). Fields for values Aand Bon the record are not
changed. The EXIT line number (lOó) will be used if an error occurs. If an
I/O error has occured, the program will then branch to line 200.
Page 6-39
DeltaBASIC Reference Manual STATEMENTS
REWRITE #file-ref,US1NG 1ine-num{,INDIC char-expr): expr-líst {IOERR line-mm)
or {EXIT line-num)
(Rewrite for awork station file)
This REWRITE statement rewrites data and attributes to awork station record
that has previously been read. It is useful for updating ascreen when only
certain fields need changing. Expressions are evaluated then rewritten into
the work station output buffer using the format given by the FORM statement at
the specified USING line number.
The optional INDÍC parameter is used to control visual and data entry
indicators specified when the work station file is created. Characters in the
INDIC character expression correspond positionally to indicators 01 to 99.
The first character of the expression controls indicator 01. Acharacter I
sets indicator Dl to on while acharacter Osets it to off. The second
character controls indicator 02 and so forth to 99. Indicators are
initialized to off when the work station file is opened and remain off unless
set on with INDIC. When INDIC is not used, indicators remained unchanged.
For REWRITE, only fields with the output attribute conditioned by an indicator
will be rewritten and then only if that particular indicator is turned on.
Also, no screen clear is issued before the screen is rewritten.
IOERR or EXIT provides abranch line number should an error occur. An error
occurs if the last operation to the work station file was not aREAD.
Example:
20 WRITE #I,USING 25,FORMAT "CMM-OO1",INDIC "IQ": CNAME$,CZIP$,STAT$
25 FORM C30,C 5,C I
30 READ #1,USING 35: CNAl'tF.$,ZIP$,STAT$
35 FORI'Í C30,C 5,C l
40 IF STAT$="A" OR STAT$="I" OR STAT$="D" THEN 70
50 REWRITE #1,USING 55,INDIC "11": " "
55 FOR9Í POS 36,C 1
60 GOTO 30
70 ...
Assume work station file Ill is open and screen CM-OOl consists of three
update fields: CNAXE$, CZIP$, AND STAT$. Further, assume only the following
attributes are conditioned by indicators:
FIELD ATTRIBUTE INDICATOR
STAT$ Output 01
STAT$ Position 02
When line 20 is executed, the screen is cleared and the screen format C6M-OOl
is displayed. Since attribute OI is set on, the STAT$ field will be output.
When line 30 is executed, screen input is accepted. Note that since indicator
02 is off, the cursor will appear at field CNAME$, the first field on the
screen. When data entry is complete, the operator presses the RETURN key and
execution continues at line 40. If STAT$ is avalid character (A, I, or D),
the program continues at lirie 70. Otherwise, line 50 causes a rewrite and
PaRe 6-40
DeltaBASIC Reference Manual STATEMENTS
sets indicators DI and 02 on. Since only the STAT$ output field is
conditioned by an indicator, it is rewritten while all other fields will
remain unchanged. Because indicator 02 is turned on, the cursor will be
positioned on the STAT$ field for the next read.
Page 6-41
DeltaBASIC Reference Manual STATEMENTS
STOP
The STOP statement stops the program. All files remain open and astop
message is printed. To continue the program, aGO command must be entered
frorn the keyboard. (See the explanation of the (jO command in Section 5.)
Example:
100 STOP
When line lOó is executed, program execution is interrupted until aGO
command is entered. Files open at this point are left open.
Page 6-42
DeltaBASIC Reference Manual STATEMENTS
WRITE #fil-ref,USING line-mm {,RFC=num-expr}: expr-list {IOERR line-mm}
{DUPKEY line-num)
(Write to adisk file) or {EXIT line-mm)
The WRITE statement writes data to adisk file specified by file reference
number. Expressions are evaluated then written to the current record of the
disk file using the specifications given in the FORM statement at the
specified USING line number.
REC=num-expr specifies the record with the given record number be written.
The file must be open for RELATIVE access.
Keyed files must be open for keyed-random access when writing new records.
The key for the new record is taken from the key position and length as
defined for the file. Before the record is added to the file, the key is
checked against the key list. If aduplicate is found and DUPKEY is
specified, then execution continues at the DUPKEY line number; otherwise, an
error results.
When anon-keyed sequential file is written, new records are added to the end
of file unless the BEGIN parameter was specified when opening the file. See
the OPEN statement above for more information.
An I/O error can be trapped at the specified line by IOERR or an EXIT
statement can be used.
Examples:
10 WRITE #1,USING IS: PART$,QTY DUPKEY lOó IOERR 200
15 FORM C 7,X 30,ZD 6
* * 0
lOó REM DUPKEY ERROR PROCESSING
e 0 0
200 REM I/O ERROR PROCESSING
Assume file #1 is open for keyed-random access, and that the key position of
the record begins in position Iand has length of 7. Further, assume PART$ is
10-1054 and QTY is lOó. When line 10 is executed, 10-1054 (PART$) is checked
against both the sorted and unsorted key lists. If aduplicate is found,
execution continues at line lOó; otherwise, a new record is written to file #1
and 10-1054 is added to the unsorted key List. Should an I/O error occur,
execution will continue at line 200.
IQ WRITE #15,USING 15: A+B,C EXIT lOó
15 FORM POS 30,ZD 7.l,X 2,PD 4
0 * P
lOó EXIT IOERR 200
0 0 0
200 REM I/O ERROR PROCESSING
Assume file #15 is open for non-keyed sequential access. Since BEGIN is not
specified, the new record containing the values of A+B and Cis added to the
end of the file. If an error occurs during the write, execution continues at
line lOó.
Page 6-43
DeltaBASIC Reference Manual STATEMENTS
WRITE #fil-ref,USING 1ine-num,FORMAT char-expr {,INDIC char-expr): expr-list
(Write to awork station file)
The file reference must refer to afile opened as awork station. The screen
is cleared, then the expression list values are displayed on the screen and
written into the work station output buffer using the format given by the FORM
statement at the specified USING line number.
FORMAT specifies which screen in the format file is to be used.
The optional INDIC parameter is used to control visual and data entry
attribute indicators specified when the work station file is created.
Characters in the INDIC character expression correspond positionally to
indicators 01 to 99. The first character of the expression controls indicator
DI. Acharacter ! sets indicator 01 to on while azero sets it to off. The
second character controls indicator 02 and so forth to 99. Indicators are
initialized to off when the work station file is opened and remain off unless
set on with INDIC. When INDIC is not used, indicators remained unchanged.
Example:
30 WRITE #3,USING 31,FORMAT "CMM-OO1",INDIC "1010": NAME$,ADRS$,CITY$
31 FORM 3*C 30
Assume file #3 is open as awork station file. When line 30 is executed,
format CMN-OOI is written to the display terminal along with the character
values NAME$, ADRS$, and C1TY$. Fields and attributes conditioned by
indicators Dl and 04 are turned on; attributes conditioned by indicators 02
and 03 are turned off. This data is also written to the work station input
buffer so that it can be changed during subsequent READ operations.
Page 6-44
DeltaBASIC Reference Manual INTRINSIC FUNCTIONS
Section 7. INTRINSIC FUNCTIONS
DeltaBASIC provides anumber of intrinsic functions that can be used in
numeric and character expressions. Those that produce numerical results are
classified as numerical functions, while those that produce character results
are classif led as character functions. The first list below contains
numerical functions and the second, character functions.
-r
Page 7-1
DeltaBASIC Reference Manual INTRINSIC FUNCTIONS
.
INTRINSIC NUMERICAL FUNCTIONS
A8S(num—expr)
Gives the absolute value of the numeric expression.
ATN(mm-expr)
Gives the angle (in radians) whose tangent is given by the numeric expression.
(MDKEY
Gives one of the following values, depending on which key was pressed to leave
awork station screen read:
Key pressed Value
RETURN O
function key. FI 1
function key F2 2
.0 0 0
ERR
Gives the error number of the last error. See Appendix Afor alist of error
numbers ,and messages.
EXP(nuin—expr)
Gives the value of constant eraised to the power of the numeric expression.
INT(ním-expr)
Gives the largest integer less than or equal to the numeric expression.
LEN(char-expr)
Gives the number of characters in the string currently assigned to the
character expression.
LINE
Gives the line number of the last error.
I1AG(num—expr)
Gives the natural logarithm (base e) of the numeric expression.
FOS(char—expr l,char—expr 2{,nim-expr))
Gives the position of the first occurrence of char-expr 2within char-expr 1.
The search begins with position 1unless num-expr is specified in which case
the search begins with the position given by num-expr.
Page 7-2
DeltaBASIC Reference Manual INTRINSIC FUNCTIONS
RND(num—expr)
Gives apseudo-random number between Oand l, with the followinp variations:
num-expr <Othen the pseudo-random number generator is reseeded.
num-expr =Othen previous pseudo-random number is given.
num-expr >Othen a new pseudo-random number is generated.
ROUND(num-expr 1,num-expr 2)
Rounds the value given by num-expr lto the number of decimal places given by
the value of num-expr 2. If num-expr 2is zero, num-expr Iwill be rounded to
awhole number. Anegative value for num-expr 2will cause rounding to that
many positions left of the decimal point.
SGN(nurn-expr)
Gives the value:
Iif num-expr >O.
Oif num-expr =O.
-l if num—expr <O.
S1N(num—expr)
Gives the sine of the angle (in radians) specified in the expression.
SQR(num-expr)
Gives the square root of the numeric expression.
STATUS(num—cnst I{,num—cnst 2))
Gives the status of certain system parameters, depending on num-cnst I:
num-cnst lSTATUS
OLast keyboard key pressed
1-254 File information--see below
255 Current printer line
256 Number of bytes of unused memory
257 Current user number
If num—cnst Iis afile reference number of an open file, then num-cnst 2
determines which additional file parameters are given.
num-cnst 2STATUS
ORecord length--all DeltaBASÍC files
IEnd-of-file record number--all DeltaBASIC files
2Number of sorted keys--keyed files only
3Number of unsorted keys--keyed files only
VAL(char—expr)
Page 7-3
DeltaBASIC Reference Manual INTRINSIC FUNCTIONS
Gives the numeric value of the character expression.
INTRINSIC CHARACTER FUNCTIONS
CHR$(num-expr l{,num-expr 2})
Gives the ASCII character with value of num-expr I. When num-expr 2is
specified, the ASCII character is repeated the number of times given by num-
expr 2.
CNVRT$(char-expr,num-expr)
Converts the value of the numeric expression to acharacter string, using the
format specified by the character expression. The N, ZD, PO, and PIC format
specifications can be used (see the FORM statement in Section 6above).
DATE$
Gives the date in character string representation YYYYMDD. For example, the
value of DATE$ for March 16, 1945 is 19450316.
STR$(num-expr) '
Converts the value of the numeric expression to acharacter string.
TIME$ )
Gives the time in character string representation (HH: M:SS). l
l
Character substring function '
{
(num—expr l:num—expr 2)
Creates asubstring beginning with the position given by num-expr 1and ending
with the position given by num-expr 2. If the substring specifications are
beyond the last character of the string, anull character string is returned.
The substring function can follow character variables and character functions.
Examples:
If A$ is ABCD, then A$(2: 3) will be BC.
If TINE$ is 02: 30:15, then TIME$(4: 5) will be 30.
Pciqe! 7—4
DeltaBASIC Reference Manual UTILITY PROGRAMS
Section 8. UTILITY PROGRAMS
In addition to DeltaBASIC itself there are several utility prof'rams provided
by Deltasoft, Inc. to assist you in program development and file maintenance.
The utility programs discussed in this section are:
PROGRAM DESCRIPTION
GEIYMSG Used to create field message files
KEYSORT Used to keysort aDeltaBASIC keyed data file
ORGANIZE Used to perform certain file maintenance operations
RENUM Used to renumber DeltaBASÍC programs
SOU Used to design formatted data entry screens
Page 8-l
DeltaBASIC Reference Manual UTILITY PROGRAMS
GENMSG
CÉ)ÑS(j is autility for generating field message (HELP) files used with
formatted data entry screens. GENMSG is invoked from the operating system by
using:
GENMSG {drv:)filename (return key)
The filename refers to an existing ASCII text file that contains alist of the
messages intended to accompany aformatted data entry screen. The filename
must be the same as the screen name and be of file type LIB. Each field
message in the LIB file consists of acomment line beginning with apound sign
(#) followed by one or more message lines, the last of which is terminated
with avertical bar symbol ().
The LIB file can be created with any standard text editor. Each line should
be terminated by acarriage return and line feed. The order of the message
corresponds to the order of the fields on the formatted data entry screen,
except that the first message block is reserved as aglobal message for the
entire screen. The second message is associated with the data entry field
nearest the upper left corner of the screen. The remaining messages are
associated with the remaining data entry fields, proceding from left to right
and top to bottom down the screen.
GENMSG uses the LIB file to create asecond file with the same name but of
type MSG. This file, not the LIB file, is accessed by DeltaBASIC to display
field messages.
To illustrate the use of screen messages, consider the simple formatted data
entry screen below:
HELP MESSAGE EXAMPLE SCREEN
Data Output Field 0OOO00OO
Data Input Field l: ********
Data Input Field 2: ********
Assume the screen name is HPIE-OO1 and is contained in format file HELPEX.FRM.
The screen consists of four constant or label fields, one output only field
(designated by 00000000), and two data entry fields (designated by ********).
The first step is to create aHELP message (LIB) file with the name !lúíE-O0I
using astandard text editor. The result appears below:
Page 8-2
DeltaBASIC Reference Manual UTILITY PROGRAMS
#The following is aglobal HELP message for screen INE-OO1:
Screen HME-OO1 is used to illustrate HELP messages for DeltaBASIC.
#The following is aHELP message for data entry field l:
This is the HELP messa3e for data entry field 1.
#The following is aHELP message for data entry field 2:
This is the HELP message for data entry field 2.
(end-of-file mark: IA hex)
Next the LIB message file must be converted to aMSG file for use by
DeltaBASIC. This is accomplished by using the GEXl'lSG utility as follows:
GENMSG HME-OOI (return key)
When the GENMSG utility finishes, the file FNE-OOIMSG will exist on the
default drive.
The screen HELP messages are now ready to access from DeltaBASIC. Assume the
HELPEX.FRM is open as a work station file and screen EME-OOI has been
displayed with aWRITE statement. After executing awork station read, the
screen looks like this:
HELP MESSAGE EXAMPLE SCREEN
Data Output Field HELPTEST
Data Input Field I: //
Data Input Field 2:
The string "IIELPTEST" occupies the output field and blanks occupy the two data
entry fields. The pound symbol (#) indicates the location of the cursor.
Pressing the HELP key ("Z) displays the HELP message for the first data entry
field. (The second HELP message is selected--the first is the screen global
message.) The screen then looks like this:
Page 8-3
DeltaBASIC Reference Manual UTILITY PROGRAMS
This is ahelp message for data entry field l.
Pressing the HELP key another time displays the global HELP message:
Screen HME-OO1 is used to illustrate HELP messages for DeltaBASIC.
Pressing any other key returns the original work station screen with
everything exactly as it was before.
fiad the cursor been positioned at the second data entry field, pressing the
HELP key would have displayed the third HELP message:
This is ahelp message for data entry field 2.
Otherwise, operation would be exactly as in the case above.
^g
DeltaBASIC Reference Manual UTILITY PROGRAMS
KEYSORT
The KEYSORT utility reorders the key file of aDeltaBASIC keyed data file.
The key file (type KEY) is actually composed of two lists. The first list
contains sorted keys with pointers to records in the data file. The second
list contains unsorted keys and pointers associated with data that has been
added to the file since the last KEYSORT was performed. When the file is
accessed randomly, the sorted and unsorted lists are both checked using a
binary tree search algorithm. If the requested key is found, the pointer is
used to gain access to the corresponding data record. Keyed sequential access
is managed differently. Pointers from the sorted key portion of the key file
are accessed sequentially, resulting in key-order processing of the
corresponding data records. In this case, keys in the unsorted part of the
key file are not accessed.
The KEYSORT utility sorts the unsorted keys and merges them into the sorted
list ensuring that all data records will be accessed during keyed sequential
processing. For more information, see Appendix C, Disk File 1/0.
The KEYSORT utility is invoked from the operating system using the following
command:
KEYSORT {drv: )name (return key)
The filename must refer to akeyed data file. No file type is needed.
Page 8-5
DeltaBASIC Reference Manual UTILITY PROGRAMS
ORGANIZE
The ORGANIZE utility is used to perform certain data file management
operations. These include:
(i) Convert an ASCII text file to aDeltaBASIC data file.
(ii) Convert aDeltaBASIC data file to an ASCII text file.
(iii) Remove marked records from aDe1taBASIC data file.
(iv) Convert aDeltaBASIC data file to akeyed file.
ORGANIZE is an interactive program that is invoked from the operating system
by entering:
ORGANÍZE (return key)
You are then presented with aseries of questions that, when answered,
determine the specific operation that is to take place. The remainder of this
section describes the dialog for each of the four operations listed above.
Page 8-6
DeltaBASIC Reference Manual UTILITY PROGRAMS
(i) Converting an ASCII text file to aDeltaBASIC data file.
Occasionally it is necessary to convert data from an incompatible format for
use with DeltaBASIC. The first step involves building an ASCII text file with
the data written on each line exactly in the position it will occupy in the
DeZtaBASIC data file. Each text line should be terminated by acarriage
return and line feed. ORGANIZE is then used to copy each line of ASCII text
into aseparate record in the DeltaBASIC data file, preserving the data's
positional relationship. If the text line is shorter than the DeltaBASIC data
file record, the remainder of the DeltaBASIC data record will be filled with
blanks. If the text line is longer than the DeltaBASIC data file record, the
text beyond the end of the record will be ignored. The interactive steps for
this operation are as follows:
ORGANIZE Question Your Reply Explanation
INPUT FILE
File name? {drv: }name{.typj Enter the name of the ASCII text file
File type? AEnter Afor ASCII
OUTPUT FILE
File name? {drv: }name{.typ) Enter the name of the new DeltaBASIC
data file
Record length? num-cnst Enter the record length of the
DeltaBASIC data file
Continue? Yor NEnter yto complete the operation or N
to restart
Page 8-7
DeltaBASIC Reference Manual UTILITY PROGRAMS
(ii) Converting aDeltaBASIC data file into an ASCII text file
You can use ORGANIZE to prepare an ASCII text file that can be used by another
program such as a text editor. This is in effect the reverse of operation (i)
above, The resulting ASCII text file will have line lengths exactly equal to
the record length of the DeltaBASIC data file. Follow these steps to complete
this operation:
ORGANIZE Question Your Reply Explanation
INPUT FILE
File name? {drv: }name{.typ} Enter the name of the DeltaBASIC data
file
File type? DEnter Dfor data
Key position? (return key) Press the RETURN key
Delete position? (return key) Press the RETURN key
OUTPUT FILE
File name? {drv: }name{.typ} Enter the name of the ASCII text file
File type? AEnter Afor ASCII
Continue? Yor NEnter yto complete the operation or N
to restart
Page 8-8
DeltaBASIC Reference Manual UTILITY PROGRAMS
(iii) Removing marked records from aDeltaBASIC data file
Deleting arecord from aDeltaBASIC data file (keyed or not) is done by
marking the record in some way, then copying all unmarked records to anew
file. In defining the fields of adata file, it is useful to include a one
character status field for this purpose. To eliminate marked data records
using ORGANIZE, follow these steps:
ORGANIZE Question Your Reply Explanation
INPUT FILE
File name? {drv: jname{.typj Enter the name of the DeltaBASIC data
file
File type? DEnter Dfor data
Key position? (return key) Press the RETURN key
Delete position? num-cnst Enter the position of the delete field
Delete character? num-cnst Enter the numeric value of the ASCII
or delete character or the character
"character" itself enclosed in quotes.
OUTPUT FILE
File name? {drv: )name{.typ) Enter the name of the new DeltaBASIC
data file
File type? DEnter Dfor data
Record length? nurn-cnst Enter the record length of the new
DeltaBASIC data file
Continue? yor NEnter Yto complete the operation or N
to restart
Note: If the new data file is to be keyed, use the procedure of (iv) below to
rebuild the keyfile.
Page 8-9
DeltaBASIC Reference Manual UTILITY PROGRAMS
(iv) Converting aDeltaBASIC data file to akeyed file
Several situations may arise that call for the conversion of aDeltaBASIC data
file into akeyed file. The list below contains afew examples:
1. Anew DeltaBASÍC data file was built from an ASCIT text file or by
deleting records from an old data file (see above) and it needs to be
converted to akeyed file.
2. ADeltaBASIC data file was built or extended using sequential processing
to save time and now must be converted to keyed format for further work.
3. An existing DeltaBASIC keyed data file needs rekeying, possibly with a new
key position and/or length.
Follow these steps to convert aDeltaBASIC data file to akeyed file:
ORGANIZE Question Your Reply Explanation
INPUT FILE
File name? {drv: }narne{.typ} Enter the name of the DeltaBASIC data
file
File type? DEnter I) for data
Key position? num-cnst Enter the position of the key
Key length? nim-cnst Enter the length of the key
OUTPUT FILE
File name? {drv: }narne.KEY Enter the name of the DeltaBASIC key
file
Continue? yor NEnter Yto complete the operation or N
to restart
Page 8-lO
DeltaBASIC Reference Manual UTILITY PROGRAMS
RENUM
The RENUM utility program is used to renumber lines of anon-source DeltaBASIC
program. RENUM is invoked from the operating system using the following
command:
RENLM {drv: }name.BAS {;nurn-cnst 1,nurn-cnst 2,num-cnst 3,num-cnst 4) (return key)
The parameters are defined as follows:
{drv: }name.BAS The non-source DeltaBASIC program to be renumbered.
num-cnst lNew beginning line number (default 10)
num-cnst 2Increment lines by this value (default 5)
num—cnst 3Begin renumber at this line number (default I)
num-cnst 4End renumber at this line number (default 65534)
After successful completion, the newly renumbered version will have the same
name as the original but with type REN. The original program is unchanged.
Page 8-ll
DeltaBASIC Reference Manual UTILITY PROGRAMS
SOU
SOU (Screen Design Utility) is used to create and modify formatted data entry
screens in ascreen format file. SOU is a menu driven, interactive program
with full screen editing capabilities. For agiven formatted data entry
screen, constant and data fields can be visually arranged in any way desired
so long as a blank space precedes and follows each field. Data entry and
visual attributes can be selected for each field.
The Screen Design Utility is invoked by entering:
SOU {{drv: }name) (return key)
where name refers to ascreen format file of type FRN.
SOU then displays amenu of eight options along with the name of the currently
selected format file and adirectory of associated screens. The menu options
are listed below with adetailed description of each. To select an option,
simply press the key shown in parenthesis.
(A)dd anew screen to aformat file.
The add facility will first prompt you to specify ascreen name of eight
characters or less. After the screen name has been entered you will be
given the opportunity to enter the new screen from the (K)eyboard or
retrieve it frorn the (D)isk. If you press the Dkey you will be prompted
for the format file and name of the screen to be added, after which SOU
will automatically enter the (U)pdate option of the menu for the new
screen. If you press the Kor RETURN key (K is the default), the display
will be cleared, after which you may place constant and data fields on
the screen as they will be viewed. SOU requires that the first and last
column of the display not be used and that there be aminimum of two
spaces horizontally between any two fields.
The text editing capablities of SOU can be reviewed by pressing the help
key (^1) or by referring to the table below. Note that sorne of the
editing features are not allowed when adding ascreen.
After all fields have been placed satisfactorily, aspecification
character should be placed before each field and aterminator character
after each field.
Specification characters determine the default data entry and visual
attributes for afield. The basic specification characters are:
c-- low intensity, constant field
d-- low intensity, input/output data field
C-- normal intensity, constant field
D-- normal intensity, input/output data field
Page B-12
DeltaBASIC Reference Manual UTILITY PROGRAMS
In addition, four other specification characters are user definable with
similar default values:
a-- low intensity, constant field
b-- low intensity, input/output data field
A-- normal intensity, constant field
B-- normal intensity, input/output data field
These defaults can be changed by entering "X while adding or updating a
screen.
Aterminator character ( ) must be placed to mark the end of each field.
When all fields, specification characters, and terminator characters have
been properly placed, "enter" the screen by pressing the ATTN key.
Control is automatically passed to the (U)pdate option of the menu so
that changes can be made to the attributes of each field. If no changes
are necessary, press the ATTN key again to return to the menu; otherwise,
refer to the (U)pdate option for detailed instructions (ignore the part
requesting ascreen name to update).
(U)pdate an existing screen in aformat file.
The update facility will ask you to specify the name of ascreen in the
currently selected format file. After the screen name has been entered,
the previously defined constant and data fields will be displayed and you
can then add, change, or remove fields as desired. SOU requires that the
first and last column of the display not be used and that there be a
minimum of two spaces horizontally between any two fields.
The text editing capablities of SOU can be reviewed by pressing the help
key ("I) or by referring to the table below. Note that some of the
editing features are not allowed when updating ascreen.
To add afield, enter the field on the screen with specification and
terminator characters as described in the (A)dd aScreen menu option
above. Next move the cursor to the beginning of the field (adjacent to
the specification character) and press "A. The field will then be added
and the attribute screen displayed to give you the option to modify the
defaults given by the specification character. To change the attributes
of apreviously created field, move the cursor to the beginning of the
field and press "C after which the list of attributes will be displayed
for modification. To remove a field, move the cursor to the beginning of
the field and press ^R. Note that, once removed, afield cannot be
recovered.
When finished, press the ATTN key to "enter" the screen. For
convenience, you will be offered the option of viewing or printing the
row and column positions, lengths, buffer positions, and attributes of
the screen fields. This information is very useful when writing the FORM
specification using the screen in DeltaBASIC.
Page B-13
DeltaBASIC Reference Manual UTILITY PROGRAMS
(D)elete ascreen from aformat file.
The delete facility will prompt you to specify the name of ascreen
in the currently selected format file. The screen will be permanently
deleted (erased) from the format file. Once deleted ascreen cannot be
recovered.
(C)hange the name of an existing screen.
The change facility will prompt you to specify the name of ascreen
in the currently selected format file. If the screen exists you can
optionally change the name or press the RETURN key to leave it unchanged.
(V)iew screen attributes.
The view facility"wi1! prompt you to specify the name of ascreen
in the currently selected format file. After the screen name has been
entered you can choose to list on the (S)creen or (P)rinter the row and
column positions, lengths, buffer positions, and attributes of all fields
in the specified screen.
(R)emove aformat file.
The remove facility will remove (erase) the currently selected format
file from memory and the disk. Note that removing aformat file is
final—-once removed it cannot be recovered.
(S)e1ect anew format file.
The select facility will prompt you to specify the name of aformat file.
After the name has been entered, the format file, if found, will become
the currently selected format file and its associated screens will be
displayed under the menu.
(E)xit to System.
This option will ensure that all changes to the currently selected format
file and associated screens are placed on the disk and return control to
the operating system.
Page B-14
DeltaBASIC Reference Manual UTILITY PROGRAMS
Editing Key Table
When you are adding and updatiñf' screens, aversatile set of editing keys is
available for your use. In the table below, the keys are arranged into four
groups: cursor movement, insert/delete, field, and miscellaneous. To use an
editing key, hold the CONTROL key down and press the specified key. Note the
exceptions for commonly used keys such as RETURN or ATTN. Alist of the
editing keys and their definitions follow:
Editing Key Function
(Cursor Movement) "K Cursor up
"J <LTNE FEED> Cursor down
"FI Cursor left
"L Cursor right
"" <!!0ME> Cursor to home position
"B Cursor to bottom line
"T Cursor to top line
"W Cursor word left
"I <TAB> Cursor word right
"Pi <RETURN> Cursor to new line
^S Cursor to screen left
"D Cursor to screen right
(Insert/Oelete) "F Insert mode ON/OFF toggle
"V Same as above
"N Insert blank line
"<DEL> Delete character left
"G Delete character right
"Y Delete line
"U Delete Line left
"P Delete line right
(Field) "A Add afield
"C Change afield
"R Remove afield
"X Change default attributes
(Miscellaneous) "O Abort add or update
"Q Reprint screen
"Z Clear screen
"[ <ESCAPE> Enter screen
"] <!IELP> Display help screen
Note: 'Ahen in the (A)dd mode, the Field keys may not be used. When in the
(U)pdate mode, the Insertion/Deletion and Clear Screen keys may not be used.
Page 8-lS
DeltaBASIC Reference Manual UTILITY PROGRAMS
SOU Errors
Errors can occasionally occur when using SOU. Alist of SOU error messages
with explanations follow:
Directory full: The disk directory is full. See your operating
system manual for explanation and corrective
measures.
Field overlap: An attempt has been made to force two fields to use
overlapping character positions on the screen. The
second field has been removed before the screen was
saved (this error occurs when ATTN key is pressed and
the screen is entered).
File not found: An attempt has been made to select aformat file that
was not present on the disk.
Format file full: An attempt has been made to place more than the
maximum number of twelve screens in aformat file.
Read: Disk read error. See your operating system manual
for explanation and corrective measures.
Screen duplication: An attempt has been made to add ascreen that has the
same name as a previously entered screen.
Screen not in format
file: An attempt has been rnade to update, delete, or view a
screen that does not exist in aformat file.
Page B-16
DeltaBASIC Reference Manual ERROR MESSAGES
Appendix A. ERROR MESSAGES
When an error occurs and no error trap is in effect, ashort error message is
displayed on the terminal. The message has the following form:
(error number) error code Error in Line line number
The HELP command can be used to call up an explanation of the last error
identified. The table below lists the error codes with corresponding error
numbers and explanations. If the error can be trapped, the trap condition to
use is given. (See ON...ERROR in Section 6.)
CODE NUMBER TRAP EXPLANATION
SYNTAX C)l SYNTAX ERROR: an unrecognizable command or statement
"was encountered.
SYN EDS 02 SYNTAX ERROR AT END OF STATEMENT: colon or line end
expected.
CHV EXP 03 CHARACTER VARIABLE EXPECTED: type mismatch.
NUM EXP 04 NUMERIC VARIABLE EXPECTED: type mismatch.
ARV EXP 05 ARRAY VARIABLE EXPECTED: type mismatch.
INV VAR 06 INVALID VARIABLE: an array variable was expected.
UDF VAR 07 UNDEFINED VARIABLE: the variable referenced does not
exist.
PAR MIS 08 PARENTHESIS HISSING: an open or close parenthesis is
missing.
REL EXP 09 RELATIONAL OPERATOR EXPECTED: arelational operator
(< > =)was expected.
INV CFN 10 INVALID CHARACTER FUNCTION: acharacter function was
expected.
CFN NAM li CHARACTER FUNCTION NANI': the $is missing from the
function name.
INV NFN 12 INVALID NUMERIC FUNCTION: anumeric function was
expected.
VAR EXP 13 VARIABLE EXPFCTED: avariable was expected.
Page A-l
DeltaBASIC Reference Manual ERROR MESSAGES
CODE NUXBER TRAP EXPLANATION
SYN EOL !4 SYNTAX ERROR AT END OF LTNE: line end expected.
I)UP VAR IS DUPLICATE VARIABLE: variable already defined.
DIül SZE 16 DIMENSION SIZE: array dimension exceeds maximum.
ON RNGE 17 ERROR ON RANGE: range of ON value exceeds maximum.
NUM DTA 18 NUMERIC DATA: numeric data was expected.
FOR LEV 19 FOR LEVEL: exceeds maximum allowed nesting (8 max).
FOR RlCG 20 FOR RANGE: limits and step incompatible.
OUT DTA 21 ERROR OUT OF DATA: attempt was made to READ past last data
value.
NLN RNG 22 NUMERIC RANGE: integer value maximum exceeded (255
max).
OUT MEM 23 OUT OF XEMORY: program needs more memory to execute.
lXV SIM 24 INVALID STATEMENT: statement not recognizable.
STK OVF 25 STACK OVERFLOW: expression too complex.
STK UNF 26 STACK UNDERFLOW: (System error)
ATTN 27
LNE RNG 28 LINE RANGE: beginning line number exceeds ending line
number.
UN!' LNE 29 UNKNOWN LINE: line referenced does not exist.
SUB STR 30 ERROR SUBSTRING: cannot be formed as specified.
IXV ARG 31 INVALID ARGU1'IENT: type mismatch or value excessive.
DIR STM 32 DIRECT STATEMENT: not allowed in direct execution.
IXV UFN 33 I.YVAI.IID USER-DEFINED FUNCTION: not avalid user
defined function.
SUB LVL 34 SUBROUTINE LEVEL: exceedes maximum (20 max).
INV RET 35 INVALID RETURN: encountered without acorresponding
GOSIJB.
Page A-2
DeltaBASIC Reference Manual ERROR MESSAGES
CODE NUMBER TRAP EXPLANATION
NIS FOR 36 MISSING FOR: aNEXT was encountered without a
corresponding FOR.
TAB 37 CONY TAB: argument is invalid.
INV IFN 38 INVALID INTRINSIC FUNCTION: not avaZid intrinsic
function.
UNK UFX 39 UNKNOWX USER DEFINED FUNCTION: was encountered.
40 Not used.
NUM OVR 41 OFLOW NUMERIC OVERFLOW: floating point value exceeds
maximum
NLM UNO 42 UFLOW NUMERIC UNDERFLOW: floating point value smaller than
minimum.
DIV ZER 43 ZDíV DIVISION BY ZERO: expression contains adivision by
zero.
STR LEN 44 SOFLOW STRING LENGTH: character string length exceeds
maximum for variable.
DUP KEY 45 DUPKEY DUPLICATE KEY: key file already contains this key.
NO KEY 46 NOKEY NO KEY: key specified not in key file.
EOF 47 EOF END OF FILE: cannot READ/INPUT past end of file.
48 Not used.
49 Not used.
50 Not used
PER I/O 51 IOERR PERMANENT 1/0: error encountered in disk input/output
operation.
CHG KEY 52 IOERR CHANGE KEY: attempt was made to change the key
portion of the record.
INC KEY 53 ÍOERR INCORRECT KEY:
INC DTA 54 IOERR INCORRECT DATA:
NO DTA 55 IOERR MO DATA:
Page A-3
DeltaBASIC Reference Manual ERROR MESSAGES
CODE NUMBER TRAP EXPLANATION
DSK FUL 56 IOERR DISK FULL: the disk is full.
FLE EXS 57 IOERR FILE EXISTS: attempt was made to create afile that
already exists.
NO FILE 58 IOERR NO FILE: attempt was made to access afile that does
not exist.
KEY L/P 59 IOERR KEY I.ENGTH/POSITION: specified incorrectly.
DIR FUL 60 IOERR DIRECTORY FULL: disk directory is full.
NO PRGM 61 IOERR NO PROGRAM: program file specified does not exist.
FLE TYP 62 IOERR FILE TYPE: mismatch.
PRG!Y1 LO 63 IOERR PROGRAM LOAD: an error was detected during program
load.
REC LEN 64 IOERR RECORD LENGTH: is Oor exceeds 2048.
65 Not used.
66 Not used.
FRM BUF 67 CONY FORMAT BUFFER: workstation format buffer length
exceeds record length specified in OPEN statement.
INV PRT 68 CONY INVALID PRINT: operation CUR, TAB, or SKIP not
allowed in disk or workstation files.
CHR I/O 69 CONY CHARACTER VARIABLE INPUT/OUTPUT: character variable
expected in I/O operation.
NUPI I/O 70 CONY NUMERIC VARIABLE INPUT/OUTPUT: numeric variable
expected in I/O operation.
FLO LEN 71 CONY FIELD LENGTH: attempt was made to write data into a
field that is too small.
FRPÍ PRT 72 CONY FORM PRINT: wrong FORM specification for PRINT
statement.
FRPI SPC 73 CONY FORM SPECIFICATION: incorrect FOR9Í specification.
INV FR?4 74 CONY INVALID FORMAT: invalid workstation format.
Page A-4
DeltaBASIC Reference Manual ERROR MESSAGES
CODE NUMBER TRAP EXPLANATION
FRPÍ PIDE 75 CONY FORMAT MODE: format mode error.
76 Not used.
FIJE REN 77 IOERR FILE RENAME: file must exist and not be in use by
another process.
FLE NAM 78 FILE NAME: must be 8characters or less plus optional
type.
DRY SEl. 79 DRIVE SELECT: cannot select specified disk drive.
UNKNOWN 80 UNKNOWN: system error.
HLP FLE 81 HELP FILE: DBXERR.MSG and DBXREF.MSG must be on
default disk drive.
FLE (JPN 82 FILE OPEN: file specified already open.
FIJE MOD 83 FILE MODE: open mode (or parameter) incorrect for
access attempted.
INV FI.E 84 INVALID FILE: file specified not open.
FLE NAY 86 FILE NOT AVAILABLE: in use by aNOSFIR process.
FLE CLS 87 IOERR FILE CLOSE: cannot close file.
INV REC 88 INVALID RECORD NUMBER: zero not allowed.
PR WRT 89 PREVIOUS WRITE: last access must have been awrite.
MIS REC 90 MISSING RECORD NUMBER: record number must be
specified.
MIS USI 91 MISSING USING: USING statement missing.
PR READ 92 PREVIOUS READ: last access must have been aread.
INV DEV 93 IXVALID DEVICE: not avalid device.
PR LIN 94 PREVIOUS LIKE: previous Line error.
95-100 Not used.
Page A-5
DeltaBASIC Reference Manual RESERVED WORDS
Appendix B. RESERVED WORDS
The following words are reserved for use by DeltaBASIC and cannot be used as
variable names, function names, or disk file names.
ABS AND ASC ATN ATTN
AUTO BEGIN CHAIN CHR CLEAR
CLOSE CXDKEY CNVRT CONY CUR
DATA DATE DEF DEL DIM
DUPKEY ELSE END EOF ERR
ERROR EXIT EXP FILES FN
FOR FORM FORMAT FREE CO
GOSUB GOTO HELP IF IGNORE
ÍNDIC INPUT IKT IOERR KEY
KEYED KEYL KEYP LEN LINE
LINPUT LIST LISTP LOAD LOG
LPREC NAME NEWPAGE XEXT XOKEY
NOT OFF OFLOW ON OPEN
OPTION OR OUTÍX OUTPUT PIC
POS PRINT PRTZO RANDOM READ
REC RECL RELATIVE REX RENAME
RESET RESTORE RETURN REWRITE RND
ROUND SAVE SGN SIN SKIP
SOFLOW SPREC SQR STATUS STEP
STR TAB THEM TINE TO
UFLOW USING VAL WRITE WS
ZDÍV
Page B-1
DeltaBASIC Reference Manual DISK FILE I/O
Appendix C. Disk File I/O
DeltaBASIC provides anumber of different techniques for data file management.
Each involves adifferent combination of file access method (sequential,
relative, keyed-random, and keyed-sequential) and mode (output, input, and
update). To help you compare these techniques, the descriptions that follow
include examples based on the sample data file given below:
File Name: INVMAS.DAT Record Length: 40
Field Description Variable FORM Start End
Name Spec Size Pos Pos
Part number PART$ C5l5
Description DESC$ C30 635
Quantity on hand QUAN N 4.0 36 39
Status (D=de1ete) STAT$ CI40 40
l234
Rec# ....!....o....)....o....|....o....l....o
l8120ISOCKET WRENCH 10
210202BALL PEEN HAMMER 5
3 64394PHILLIPS SCREW DRIVER 15
440121HAND SAW 8
5(end-of-file record)
Page C—l
DeltaBASIC Reference Manual DISK FILE 1/0
Sequential Access
With sequential access, records in the file are processed in order by record
number. Sequential access is selected by default when neither the RELATIVE
nor the KEYED attribute is used in the OPEN statement.
Sequential Access in Output Mode
For sequential/output access, records are added at the current end-of-file
record or--if the BEGIN parameter is used--beginning at record l. File reads
are not allowed. Sequential/output access is selected in the OPEN statement
when OUTPUT is used without either RELATIVE or KEYED as afile attribute.
If a new file is created, records are added beginning with record I, then
record 2, and so forth. For example, the sample data file above could be
created using the program below:
I
2APROGRAM ILLUSTRATING SEQUENTIAL/OUTPUT ACCESS
3
10 DIM DESC$*30
15 OPEN #1: "NA±=INVMAS.DAT,NEW,RECL=40",OUTPUT
20 STAT$=" "
25 READ N)THE NUMBER OF DATA SETS
30 FOR 1=1 TO N
35 READ PART$,DESC$,QUAN
40 WRITE #1,USING 45: PART$,DESC$,QUAN,STAT$
45 FORM C 5,C 30,N 4,C I
50 NEXT I
55 CLOSE ill:
60 STOP
65 DATA 4
70 )DATá SETS
75 DATA 81201,SOCKET WRENCH,1O
80 DATA 10202,BALL PEEN HAMMER,5
85 DATA 64394,PIIILLIPS SCREW DRIVER,15
90 DATA 40121,HAND SAW,8
The program creates a new file, INVMAS.DAT, with record length 40 (line 1-5).
The access method is sequential and the mode is output. The number of data
records to be added is read from internal data (line 25), then aFOR/NEXT Loop
is used to read the data sets and write new records to the data file (lines
30-50). Note that the records are added to the file in order, beginning with
record land continuing through record 4. The data order within the file is
determined by the order in which the records are written.
If afile already exists when sequential/output is selected, the absence or
presence of the BEGIN attribute determines where the new records are added.
These situations are illustrated by two program examples below:
In the first program, the BEGIN attribute is absent resulting in new data
being added at the current end-of-file.
Page C-2
DeltaBASIC Reference Manual DISK FILE I/O
l
2APROGRAM ILLUSTRATING SEQUEXTIAL/OUTPUT ACCESS WITHOUT BEGIN
3
10 DIM DESC$*30
15 OPEN Ill: "NAME=INVMAS.DAT",0UTPUT
20 STAT$=" "
25 READ N :THE NUMBER OF DATA SETS TO BE ADDED
30 FOR 1=1 TO N
35 READ PART$,DESC$,QUAN
40 WRITE #1,USING 45: PART$,DESC$,QUAN,STAT$
45 FORM C 5,C 30,N 4,C I
50 XEXT I
55 CLOSE #1:
60 STOP
65 )DATA SETS
70 DATA 2
75 DATA 91324,WRENCFI,5
80 DATA 68923,PLIERS,12
Line IS opens file INVMAS.DAT for sequential/output access. Since the BEGIN
attribute is absent, new data records are added at the current end-of-file.
The number of data sets to add is read from internal data (line 25), and a
FOR/NEXT loop appends the new records to the file (lines 30-50). The program
arranges the sample data file as shown below:
I234
Rec# ....|....0....)....0....)....0....|....0
181201SOCKET WRENCH 10
210202BALT. PEEN HAPNER 5
364394PHILLIPS SCREW DRIVER 15
440121HAND SAW 8
591324WRENCFI 5
6 68923PL1IERS ,12
7(end-of-file record)
The first four records are the same as before. The new data has been added in
records 5and 6, moving the end-of-file to record 7.
In the second program, the BEGIN attribute is present resulting in new data
being written beginning at record 1of the file. Data currently in the file
is lost.
1
2APROGRAM ILLUSTRATING SEQUENTIAL/OUTPUT ACCESS W1ITFI BEGIN
3
10 DIM DESC$*30
IS OPEN #1: "NAW.=INVP1AS.DAT",OUTPUT,BEGIN
20 STAT.$=" "
25 READ M!THE NUMBER OF DATA SETS TO BE ADDED
30 FOR 1=1 TO N
35 READ PART$,DESC$,QUAN
40 WRITE #1,USING 45: PART$,DESC$,QUAN,STAT$
45 F0R)'J C5,C 30,Y 4,C l
50 NEXT I
Page C-3
DeltaBASIC Reference Manual DISK FILE I/O
55 CLOSE Él:
60 STOP
65 )DATA SETS
70 DATA 2
75 DATA 9I324,WRENCH,5
80 DATA 68923,PLIERS,12
The program is identical to one immediately above except for the addition of
the BEGIN attribute (line IS). After the program is executed, the sample data
file looks like this:
I2 3 4
Rec# ....)....0....)....0....)....0....)....0
l91324WRENCH 5
268923PLIERS 12
3(end-of-file record)
Note that all the original data in the file is gone and only the new data
remains.
Sequential Access in Input Mode
For sequential/input access, records are read from the file in order by record
number beginning with record l. No file writes are allowed. Sequential/input
access is selected in the OPEN statement when INPUT is used without either
RELATIVE or KEYED as afile attribute.
The program below uses this processing technique with the original sample data
file.
I
2APROGRAM ILLUSTRATING SEQUENTIAL/INPUT ACCESS
3
10 DIM DESC$*30
15 OPEN #1: "NAM=INVMAS.DAT",INPUT
20 READ #1,USING 25: PART$,DESC$,QUAN,STAT$ EOF 40
25 FORM C 5,C 30,N 4,C I
30 PRINT PART$,DESC$,QUAN,STAT$
35 GOTO 20
40 CLOSE #1:
45 STOP
Line 15 opens the file INVMAS.DAT for sequential/input access. The program
then reads data records in record number order beginning with record I, and
prints them on successive lines (lines 20-30). When the end-of-file record is
reached (line 20), the file is closed and execution ends (lines 40-45). The
resulting printout appears below:
81201 SOCKET WRENClil 10
10202 BALL PEEN HARIER 5
64394 PHILLIPS SCREW DRIVER 15
40121 HAND SAW 8
Page C-4
DeltaBASIC Reference Manual DISK FILE I/O
Note that the file data is accessed and printed in exactly the order it
appears in the file.
Sequential Access in Update Mode
For sequential/update access, records are read and ,if desired, rewritten
(with the REWRITE statement) in record number order beginning with record I.
Existing records can be changed but new records cannot be added (the WRITE
statement is not allowed). Sequential/update access is selected in the OPEN
statement when no file attributes are used.
The program below illustrates how to update the original sample data file.
l
2A PROGRAM ILLUSTRATING SEQUENTIAL/UPDATE ACCESS
3
10 DIM DESC$*30
15 OPEN #1: "NAME=INVMAS.DAT"
20 READ #1,USING 25: PART$,DESC$,QUAN,STAT$ EOF 50
25 FORM C5,C 30,N 4,C 1
30 IF PART$>"50000" THEN 20
35 REWRITE #1,USING 40: "D"
40 FORM POS 40,C I
45 GOTO 20
50 CLOSE Ill:
55 STOP
The program opens file INVXAS.DAT for sequential/update access (line 15).
Records are then read in order as they appear in the file (line 20), and those
with part numbers less than or equal to 50000 are rewritten with the status
field changed to D(lines 30-45). When the end-of-file is reached (line 20),
the file is closed and execution ends (lines 50-55). The sample data file now
looks like this:
I23 4
Rec# ....:....O...J....O....)....0...J....O
I8120ISC)CKET WRENCH IQ
210202BALL PEEN HAMMER 5D
3 64394PHILLTPS SCREW DRIVER 15
440121HAND SAW BD
5(end-of-file record)
Records 2and 4are marked with aD. No other file changes are made.
Page C-5
DeltaBASIC Reference Manual DISK FILE I/O
Relative Access
When RELATIVF is used in the file ID of the OPEN statement, records in the
file are accessed by specifying arecord number in the REC parameter of READ
and WRITE statements. Relative access differs from sequential in that records
can be accessed in any order simply by specifying their record numbers.
Relative Access in Output Mode
For relative/output access, records are replaced or added to the file by
specifying the record number using the REC parameter in aWRÍTE statement.
File reads are not allowed. Relative/output access is selected in the OPEY
statement when both RELATIVE and OUTPUT are used as file attributes.
The program below illustrates how to replace arecord in the original sample
data file.
I·
2APROGRAM ILLUSTRATING RELATIVE/OUTPUT ACCESS
3
10 DIM DESC$*30
IS OPEN #1: "NA9fE=INVXASj)AT",RELATIVE,OUTPUT
20 READ R,PART$,DESC$,QUAN
25 WRITE #1,USING 30,REC=R: PART$,DESC$,QUAN," "
30 FORX C5,C 30,X 4,C 1
35 CLOSE #1:
40 STOP
45 DATA 2,20013,CARRIAGE BOLT -!/2 INCH,50
The program opens the file INVMAS.DAT for relative/output access (line IS).
New data is then written to record 2(lines 20-30), replacing the existing
record. The sample data file now appears as appears as shown below:
l2 3 4
Rec# ....!....o....l....o...j....o....!....o
l8120ISOCKET WRENCH IQ
220013CARRTAGE BOLT -1/2 INCH 50
364394P!IILLTPS SCREW DRIVER 15
44012I!IAND SAW 8
5(end-of-file record)
Record 2, which originally contained the BALL PEEN HAMMER record, now contains
the CARRIAGE BOLT record.
Relative Access in Input Mode
For relative/input access, records are read from the file by specifying the
record number in the REC parameter of the READ statement. File writes are not
allowed. Relative/input access is selected in the OPEN statement when
both RELATIVE and INPUT are used as file attributes.
Page C-6
DeltaBASIC Reference Manual DISK FILE I/O
The program below illustrates how to read arecord in the original sample data
file.
l
2APROGRAM ILLUSTRATING RFJ.ATIVE/INPUT ACCESS
3
10 DIM DESC$*30
15 OPEN #1: "NAME=INVMAS.DAT",RELATIVE,INPUT
20 READ #1,USING 25,REC=3: PART$,DESC$,QUAN
25 FORM C5,C 30,N 4
30 PRINT PART$,DESC$,QUAN
35 CLOSE #1:
40 STOP
The program opens file INVNAS.DAT for relative access in the input mode (line
15). Record 3is specified in the REC parameter of the READ statement,
indicating that record is to be read (line 20). The following line is then
printed (line 30):
64394 PHILLIPS SCREW DRIVER 15
Relative Access in Update Mode
For relative/update access, arecord is read by specifying the record number
using the REC parameter in aREAD statement and then, if desired, all or part
of the record can rewritten (with the REWRITE statement). Existing records
can be changed and new records can be added using the WRITE statement. Rela-
tive/update access is selected in the OPEN statement when RELATIVE is used
without either INPUT or OUTPUT as a file attribute.
The program below illustrates this type of access with the original sample
data file.
1
2A PROGRAM ILLUSTRATING RELATIVE/UPDATE ACCESS
3
10 DIM DESC$*30
15 OPEN #1: "NAME=INVMAS.DAT",REI.ATIVE
20 R=l
25 READ #1,USING 30,REC=R: PART$ EOF 55
30 FORM C 5
35 IF PART$<"50000" THEN 50
40 REWRITE #I,USING 45: "D"
45 FORM POS 40,C I
50 R=R+1: GOTO 25
55 CLOSE #1:
60 STOP
File INVMAS.DAT is opened for relative/update access in line 15, then records
are read in the order specified by the value of variable Rin line 25. Ris
initially Iand then is incremented by Ito access all records in the file
(line SO). Records with part numbers less than or equal to 50000 are
rewritten with the status field changed to D(lines 35-45). The end-of-file
error address in the READ statement ends execution after the last record is
Page C-7
DeltaBASIC Reference Manual DISK FILE I/O
read .The sample data file would then appear as follows:
I2 3 4
Rec// .... I.. ..O. ... )
....O. .. .
)
... .O. ... ).. ..C)
181201SOCKET WRENCH 100
210202BAI.L PEFN HAMMER 5
364394PFIILLIPS SCREW DRIVER 15D
440121HAND SAW 8
5(end-of-file record)
Records land 3are marked with aD. No other file changes are made.
Page C-8
DeltaBASIC Reference Manual DISK FILE I/O
Keyed Access
A"key" is part of arecord—-a word, anumber, or some other label in
character string form--used to identify that record for later retrieval
through keyed access. Keyed access is specified by using KEYED as afile
attribute in the OPEN statement. The position of the key within the record
and its length are specified at the time the keyed file is created. Each time
a new record is added to akeyed data file, key information is extracted and
added with the corresponding record number to aseparate KEY file. The KEY
file consists keys and pointers organized into two distinct lists. The first
list contains keys that have been sorted into alphanumeric order using the
KEYSORT utility. The second list contains keys added since the last use of
the KEYSORT utility in the order which they were added to the file.
The choice of the key field within the data record is application dependent.
If the sample data file above is to be keyed, it is reasonable to use the part
number as the key. In this case, the OPEN statement creating the file would
include (in the file ID) akey position (KEYP) of I and akey length (KEYL) of
5. For example, the sample data file above could be created as a keyed file
using the program below:
l
2A PROGRAM ILLUSTRATING KEYED-RANDOM/OUTPUT ACCESS
3
10 DIM DESC$*30
15 OPEN #1: "NAm=INmAs.DAT,NEw,RAND0M,KEYp=l,KEYL=5,REcL=40",KEYED,0UTpUT
20 STAT$=" "
25 READ N )THE NUMBER OF DATA SETS
30 FOR 1=1 TO X
35 READ PART$,DESC$,QUAN
40 WRITE #1,USING 45: PART$,DESC$,QUAN,STAT$
45 FORM C5,C 30,N 4,C 1
50 NEXT I
55 CLOSE #1:
60 STOP
65 DATA 4
70 )DATA SETS
75 DATA 81201,SOCKET WRENCH,1O
80 DATA 10202,BALL PEEN HAMMER,5
85 DATA 64394,PFIILLIPS SCREW DRIVER,15
90 DATA 40121,HAND SAW,8
The example is identical to the program presented earlier to create a
sequential file with the exception of the OPEN statement (line 15).
The sample data file (INVMAS.DAT) and its companion KEY file (INVMAS.KEY)--
after keysorting-- appear as given below:
Page C-9
DeltaBASIC Reference Manual DISK FILE I/O
12 3 4Key Record
Rec# ....1....0....|....0.... ....0....|....0 Pointer
18120isocket WRENCil 10 10202 2(sorted)
210202ba!j. peen hamer 540121 4
364394phili.ips scrfw driver 15 64394 3
44ói21hani) saw 8 81201 i
5(end—of-file record) (unsorted)
Note that the data file is in the order it was written; only the key entries
have been sorted.
With keyed files, two basic access methods are available: random by key and
sequential by key.
The first, random by key--activated by specifying the RANDOM parameter in the
file IO--lets you add a new record to the data file and key to the KEY file or
search for aexisting data record using the KEY file. With this access
method, new keys are added to the unsorted list in the KEY file. It should be
noted that random key searches check both the sorted and unsorted lists in the
KEY file, thus making the newly added key immediately available.
The second, sequential by key--activated by not specifying RANDOM in the file
IO--lets you process records from the data file in the order of the keys in
the sorted KEy file list. The keys in the unsorted list and their
corresponding data records are not accessed. New records cannot be added to
the file using keyed-sequential access.
These two access methods in combination with various modes are discussed
below.
Random by Key Access in Output Mode
For keyed-random/output access, new records are added to the data file using
the WRITE statement with new keys and record pointers automatically added to
the unsorted list in the KEY file. File reads are not allowed. Keyed-
random/output access is selected in the OPEN statement when RANDOM is used in
the file ID and both KEYED and OUTPUT are used as file attributes.
The program below adds two records to the original sample data file.
i
2aprogram illustrating keyed-random/output access
3
10 dim desc$*i0
15 open Él: "NAME=INV!4AS.DAT,RAND0pí",KEYED,OUTPUT
20 stat$=" "
25 read nlthe number of data sets to be added
30 for I=l to n
35 read part$,de3c$,quax
40 write #!,using 45: part$,desc$,quan,stat$
45 foru c5,c 30,n 4,c i
50 next i
Page C-lO
DeltaBASIC Reference Manual DISK FILE I/O
55 CLOSE #1:
60 STOP
65 IDATA SETS
70 DATA 2
75 DATA 91324,WRENCH,5
80 DATA 68923,PLIERS,12
In line 15, the file INVMAS.DAT is opened for keyed-randorn/output access. The
number of data sets to be added is then read from internal data (line 25).
The new records are added to INVMAS.DAT, and the part number keys and record
pointers are automatically added to the unsorted list in INVMAS.KEY (lines 30-
50). Following execution of the program, the sample data file and
corresponding KEY file look like this:
l234Key Record
Rec# ....)....0....)....0....|....0....)....0 Pointer
181201SOCKET WRENCH 10 10202 2(sorted)
210202BALL PEEN HA6C4ER 540121 4
364394PHILLIPS SCREW DRIVER 15 64394 3
4 40121HAND SAW 881201 1
591324NRENCH 5
6 68923PLIERS 12 91324 5(unsorted)
7(end-of-file record) 68923 6
Note that the KEY file now has two distinct key lists, the sorted list and the
unsorted list. As has been mentioned before, random accesses by key will
check both lists for the presence of acertain key. Sequential accesses by
key will not access the keys in the unsorted list. To ensure access to all
data, use the KEYSORT utility to sort the unsorted list and merge it into the
sorted list. After keysorting, the sample data file and KEY file would look
like this:
l234Key Record
Rec# ....!....O....)....O....!....O....)....O Pointer
18120ISOCKET WRENCH IQ 10202 2(sorted)
210202BALL PEEN HAI'MER 5 40121 4
364394PHILLIPS SCREW DRIVER 15 64394 3
4 40121F!AND SAW 868923 6
591324WRENCH 581201 I
6 68923PLIERS 12 91324 5
7(end-of-file record) (unsorted)
Note that the two originally unsorted keys now occupy their proper place in
the sorted list.
Random by Key Access in Input Mode
For keyed-random/input access, arecord in the data file is read by giving the
desired key in the KEY parameter of the READ statement. File writes are not
allowed. Keyed-random/input access is selected in the OPEN statement when
RANDOM is used in the file ID and both KEYED and INPUT are used as file
attributes.
Page C-ll
DeltaBASIC Reference Manual DISK FILE I/O
The program below accesses and prints record 6(the PLTERS) by specifying the
corresponding part number as key.
l
2APROGRAM ILLUSTRATING KEYED-RANDCM/INPUT ACCESS
3
10 DIM DESC$*30
15 OPEN #1: "NAME=INVMAS.DAT,RAND0M",KEYED,INPUT
20 READ #1,USING 25,KEY="68923": PART$,DESC$,QUAN,STAT$ NOKEY 50
25 FORM C 5,C 30,N 4,C l
30 PRINT PART$,DESC$,QUAN,STAT$
35 CLOSE #1:
40 STOP
50 PRINT "KEY NOT FOUND"
55 CLOSE #1:
60 STOP
The file INVMAS.DAT is opened for keyed-random/input access in line 15. Lines
20-30 then read and print the record with the specified key.
68923 PLIERS 12
If the key is not found, the program branches to line 50 for error processing.
Random by Key Access in Update Mode
For keyed-random/update access, arecord in the keyed data file can be
accessed by giving the desired key in the KEY parameter of the READ statement
and, if desired, the REWRITE statement then used to update the record. The
key portion of the data record must not be changed during updating, or an
error will occur. New records can be added to the file using the WRITE
statement. Keyed-random/update access is selected in the OPEN statement when
RANDOM is used in the file ID and KEYED is used without either INPUT or OUTPUT
as afile attribute.
In the example program below, record 6(the PLIERS) is read and rewritten with
the status changed.
I
2APROGRAM ILLUSTRATING KEYED-RANDOX/UPDATE ACCESS
3
10 DIM DESC$*30
15 OPEN #1: "NAm=INvMAs.DAT,RAKD0}f",KEYED
20 READ #1,USING 25,KEY="68923": PART$,DESC$,QUAN,STAT$ NOKEY 50
25 FORM C 5,C 3C),N 4,C l
30 REWRITE #1,USING 40: "D"
35 FORM POS 40,C I
40 CLOSE Él:
45 STOP
50 PRINT "KEY NOT FOUND"
55 CLOSED #1:
60 STOP
Page C-12
DeltaBASIC Reference Manual DISK FILE I/O
The program opens file TNVMAS.DAT for keyed-random/update access (line IS),
then reads the record with the specified key and rewrites with the status
field changed to D(lines 20-40). After the program is executed, the sample
data file would appear as ['iven below:
l234Key Record
Rec# ....)....0....)....0....)....0....)....0 Pointer
I81201SOCKET WRENCH 10 10202 2(sorted)
210202BAI.L PEEN HAMMER 540121 4
364394PHTLLTPS SCREW DRIVER 15 64394 3
4 40121HAND SAW 868923 6
591324WRENCII 581201 1
6 68923PLTERS 12D 91324 5
7(end-of-file record) (unsorted)
Record 6has been marked with aD.
Sequential Access by Key in Input Mode
For keyed-sequential/input access, records are read in the order of the keys
in the sorted list of the KEY file. File writes are not allowed. Processing
begins with the first key in the KEY file unless the KEY>= parameter appears
in the READ statement. In that case the first record processed is that of the
first key alphanumerically greater than or equal to the KEY>= parameter.
Keyed-sequential/input access is selected in the OPEN statement when RANDOM
is not used in the file ID and both KEYED and INPUT are used as file
attributes.
The program below prints alist of all parts in the original sample data file.
l
2APROGRAl'l ILLUSTRATING KEYED-SEQUENTÍAI./INPUT ACCESS
3
10 DIM DESC.$*30
13 OPEN #1: "NAHE=INVNAS.DAT",KF.YED,INPUT
20 READ É1,USIKG 25: PART$,DESC$,QUAN,STAT$ EOF 40
25 FORM C 5,C 30,N 4,C I
3C) PRINT PART$,DESC$,QUAN,STAT
35 GOTO 20
40 CLOSE #1:
50 STOP
Suppose the expanded sample data file has not been keysorted and appears as
given below:
Page C-13
DeltaBASIC Reference Manual DISK FILE I/O
12 3 4Key Record
Rec# ....)....0....)....0....)....0.... ....O Pointer
lM201SOCKET WRENCH 10 10202 2(sorted)
210202BALL PFEN HAMMER 540121 4
364394PHU.LIPS SCREW DRIVER 15 64394 3
4 40121HAND SAW 8 81201 1
591324WREXCH 5
6 68923PLIERS 12 91324 5(unsorted)
7(end-of-file record) 68923 6
Executing the program would produce this printout.
10202 BALL PEEN HAMMER 10
40121 HAND SAW 8
64394 PHILLIPS SCREW DRIVER 15
81201 SOCKET WRENCH 10
Note in particular two things: first, the data is accessed in the order of the
keys, not in the order the data appears in the file. Second, the unsorted
data is not accessed at all. To ensure that all data is read, the file must
be keysorted using the KEYSORT utility.
Shown below is the same program, changed slightly by including the KEY>=
parameter in the original READ statement and adding asecond READ without
KEY>=. The technique allows keyed-sequential/input access to begin with akey
other than the first.
I
2APROGRAM ILLUSTRATING KEYED-SF,QUENTIAL/INPUT ACCESS WITH KEY>=
3
10 DIM DESC$*30
15 OPEN #1: "|qAw=ÍNvxAs.DAT",KEYED,IxpUT
20 READ #1,USING 25,KEY>="50000": PART$,DESC$,QUAN,STAT$ EOF 45
25 FORM C 5,C 30,N 4,C l
30 PRINT PART$,DESC$,QUAN,STAT
35 READ #1,USING 25: PART$,DESC$,QUAN,STAT$ EC)F 45
40 GOTO 30
45 CLOSE i91:
55 STOP
After program execution, the printout would appear as shown below:
64394 PHILLIPS SCREW DRIVER 15
81201 SOCKET WRENCH 10
Processing began with the first key greater than 50000. Thus, only records
with keys greater than 50000 are printed. Note that the READ with KEY>= is
only used once. As in the previous case, the unsorted keys are not accessed.
Sequential Access by Key in Update Mode
For keyed-sequential/update access, records are read in the order of the keys
in the sorted list of the KEY file and, if desired, the REWRITE statement then
Page C-14
De1taBASIC Reference Manual DISK FILE I/O
used to update arecord. (The WRITE statement cannot be used, which means
that new records cannot be added to the file.) Processing begins with the
first key in the KEY file unless the KEY>= parameter appears in the READ
statement. In that case, the first record processed is that of the first key
alphanumerically greater than or equal to the KEY>= parameter. Keyed-
sequential/update access is selected in the OPEN statement when RANDOM is not
used in the file ID and KEYED is used without either INPUT or OUTPUT as a file
attribute.
The program below illustrates this access technique with the expanded sample
data file (after being keysorted).
1
2APROGRAM ILLUSTRATING KEYED-SEQUENTIAL/UPDATE ACCESS
3
10 DIM DESC$*30
15 OPEN #1: "NAw.=INvms.DAT",KEYED
20 READ #1,USING 25: PART$,DESC$,QUAN,STAT$ EOF 50
25 FORM C 5,C 30,N 4,C l
30 IF QUAN>1O THEN 20
35 REWRITE #1,USING 40: "I"
40 FORM POS 40,C 1
45 GOTO 20
50 CLOSE #1:
55 STOP
The program opens the file INVMAS.DAT for sequential access by key, in update
mode (line 15). The records are then processed in key order, with those
records having aquantity less than or equal to 10 changed to the rstatus
(lines 20-45). After the program is executed, the sample data file appears as
shown below:
1234Key Record
Rec# ....)....O....!....O....)....O....|....O Pointer
l81201SOCKET WRENCH 10 10202 2(sorted)
210202BALL PEEN HAMMER 51 40121 4
364394PHILLIPS SCREW DRIVER 15 64394 3
4 40121FIAND SAW 81 68923 6
591324WRENCH 51 81201 l
6 68923PLIERS 12 91324 5
7(end-of-file record) (unsorted)
Records with quantities less than 10 reflect an Istatus.
This completes the description of the various file processing techniques
available to the DeltaBASIC user. Aword of caution is in order. While the
data file is identical for all file access techniques, aproblem can arise if
you add records to akeyed file not opened as a keyed file. In this case, the
record is added to the data file but the key and pointer are not added to the
KEY file. The resulting discrepancy causes this record data to become
inaccessable later when the file is used again as a keyed file. To correct
this situation, you can use the ORGANIZE utility to rebuild the KEY file.
Page C-15
DeltaBASIC Referenece Manual FORMATTED DATA ENTRY SCREENS
Appendix D. FORMATTED DATA ENTRY SCREENS
DeltaBASIC uses formatted data entry screens created by the utility program
SOU. To access a formatted data entry screen, first awork station (WS) file
must be opened specifying the format file that contains the screen; then the
screen can be displayed and data entered using WRITE and READ statements.
Data is passed between the keyboard/screen and DeltaBASIC using an input
buffer and an output buffer. All screen fields that accept input are
associated with contiguous data fields in the input buffer. Similarly, all
non-constant output fields are associated with contiguous data fields in the
output buffer. The arrangement of the buffer data fields is in the order
left-to-right, top-to-bottom on the screen. Thus, the screen field nearest
the top left corner of the screen would appear as the first data field in the
appropriate buffer. Since output-only fields do not appear in the input
'buffer, screen fields do not necessarily occupy the same position in both
buffers. SOU provides adetailed listing of the field positions in both
buffers which can be used to develop the FORM specification needed with the
READ or WRITE statements.
.
De1taBASIC supports anumber of data entry and visual attributes. Attributes
for afield can be selected using the attribute screen of SOU. Most
attributes can be set on by choosing the Yoption or off by choosing the N
option. In some cases, other options are provided. For instance, some
.attributes can be conditionally set from DeltaBASIC using indicators. There
are 99 indicators, each of which may be set on or off using the INDIC option
in the WRITE or REWRITE statments. An attribute is set on only if its
associated indicator is on.
The available attributes are listed below. The indicator option is denoted by
xx.
(Data Entry Attributes)
Controlled Field Exit {Y,N) When set on forces the user to press akey such
as RETURN or FIELD EXIT to exit an input/output field. When set off the field
is exited when the field length is exceeded by the operator.
Adjust/Fill {N,B,Z) -- When set off no special action is taken. When set to
B, the data in the field is right justified and filled with blanks to the
left upon exit. When set to Z, the data in the field is right justified and
filled with zeros to the left upon exit.
Mandatory Entry {Y,N) When set on forces the operator to enter at least one
non-blank character before exiting the field.
Mandatory Fill {Y,N) When set on forces the operator to enter non-blank
characters throughout the field.
Field Type {N,A} When set to N, any data entered into the field must be
numeric; i.e., Othrough 9, +, -, E, or the decimal point. When set to A, all
alphanumeric characters are allowed into the field.
Input Allowed {Y,N) -- When set on allows input from the field. When set off
Page D-1
DeltaBASIC Referenece Manual FORMATTED DATA ENTRY SCREENS
input is NOT allowed--setting this attribute off creates an OUTPUT ONLY field.
Constant Output {Y,N) When set on causes aspecified constant to be output
to the screen as the screen is initially written.
Auto RETURN {Y,N} When set on indicates that the entire screen is to be
"entered" when the field is exited; i.e., the contents of all the input fields
are returned to the program. When set off the cursor will procede to the next
field unless the RETURN or afunction key is pressed.
Position Cursor {Y,N,xx) —- When set on, unconditionally or with aspecified
indicator, causes the cursor to be positioned to this field when the screen is
initially written. When more than one field on the screen has this attribute
set on, the cursor will move to the first such field. If no field is found
with the position indicator set on, the cursor defaults to the first data
entry field.
Protect {Y,N,xx} When set on, unconditionally or with aspecified
indicator, causes input to be disallowed from the field. When set off input
is allowed from the field. .
(Visual Attributes)
Low Intensity {Y,N,xx} —- When set on, unconditionally or with aspecified
indicator, causes the data in the field to be displayed in low intensity
.(dim).
Blink {y,N,xx) When set on, unconditionally or with aspecified indicator,
causes the data in the field to be displayed blinking.
Non-Oisp1ay {Y,N,xx) When set on, unconditionally or with aspecified
indicator, causes the data in the field to NOT be displayed.
Reverse Image {Y,N,xx) When set on, unconditionally or with aspecified
indicator, causes the data in the field to be displayed in reverse video.
Underline {Y,N,xx) When set on, unconditionally or with aspecified
indicator, causes the data in the field to be displayed underlined.
Output {Y,xx) When set on, unconditionally or with aspecified indicator,
allows output to the field. This attribute is the equivalent of the Protect
Attribute for output. Note that this may not be set unconditionally off.
NOTE: The implementation of visual attributes can vary depending on the
capabilites of the computer system and/or terminal on which they are being
used.
Page D-2
DeltaBASIC Reference Manual MULTI-USER INFORMATION
Appendix E. MULTI-USER INFORMATION
DeltaBasic supports multi-user file and record locking in both the PíP/X and
TurboDOS operating environments. If afile is to be shared by several
programs at the same time, then the SHR parameter must appear in the OPEN
statement of each program To gain exclusive use of afile, it is necessary
to OPEN it without the SUR parameter at atime when the file is not in use by
any other program. Once exclusive use of the file is obtained, no other
program can gain access to the file.
Record locking occurs whenever aprogram has accessed arecord and the file is
open in either the output or update mode. The program retains exclusive use
of the record during the write operation (output mode) or between the read
and rewrite operations (update mode). In standard implementations of MP/M and
TurboDOS, asecond program attemptiñf' to gain access to alocked record is
suspended until the other program releases the record. It is important to
note that all physical disk records that contain the data record accessed are
locked. The possibility therefore exists that more than one data record can
be locked when only one record is accessed. Record locking does not occur
when a program accesses the record in the input mode. Thus, two or more
programs can access the sanie record at the same time if all have the file open
in the input mode.
Page E-1
DeltaBASIC Reference Manual LANGUAGE COMPATIBILITY
Appendix F. LANGUAGE COMPATIBILITY
DeltaBASIC is based on asubset of IBl'l System/34 BASIC but is not directly
compatible with this or any other BASIC language implementation. At the same
time, most of the commands, statements, and functions are similar to those
generally considered traditional to the BASIC language. The greatest
differences will be encountered in these areas:
l) Formatted READ and WRITE
2) Disk I/O and file handling
3) Substring operations
Page F-1
L)eÁLaL)LiD-LL keLU[ejlcc í1¿ínuaí INDEX
Appendix G. INDEX
Abbreviations, 3-l DUPKEY, 6-9, 6-43, A-3
ABS, 7-2
Adjust, D-1
ASCII, 5-12, S-16 Edi-ting Keys, 4-l
ATN, 7-2 Editing Key Table, 8-lS
ATTN, 3-l, 4-l END, 4-l, 6-3, 6-8
AUTO, 5-2 EOF, 6-9, 6-33, A-3
Auto RETURX, D-2 ERR, 7-2
ERROR, 6-22, A-2
Error Codes, A-l
BEGIN, 6-26, 6-43, C-2, C-3 EXIT, 6-3, 6-9, 6-26, 6-28, 6-33,
Blink, D-2 6-39, 6-40, 6-43
EXP, 7-2
Expressions
C, 6-11, 6-29 Character, 2-2
CHAIN, 6-2 Logical, 2-2
Character expressions, 2-2 Numeric, 2-l
Character functions, 7-4 Relational, 2-2
CHR$, 7-4
CLEAR, 5-3
CLOSE, 6-3, 6-9 Features of DeltaBASIC, l-l
CMDKEY, 6-34, 7-2 Field Type, D-l
CNVRT$, 7-4 FILES, 5-5, 6-2
Command/Program edit mode, 4-l Fill, D-l
Commands, 5-l FOR/NEXT, 6-lO
Constant Output, D-2 FORM, 6-11, 6-31, 6-33, 6-34, 6-39,
Constants, 2-l 6-43, 6-44, D-l
Controlled Field Exit, D-l FORMAT, 6-44
CONY, 6-22, A-3, A-4, A-5 Format of error codes, A-l
CR, 6-12 Formatted Data Entry Screens, D-l
CUR, 6-ll FREE, 5-6
FRM, 6-28, B-12
D, 6-29
DATA, 6-4, 6-37 GENNSG, 6-34, 8-l, 8-2
Data Entry Attributes, D-l GO, 5-7, 6-42
DATE$, 7-4 GO END, 5-7, 6-3
DB, 6-12 GOSUB, 6-15, 6-38
DEF FN, 6-S GOTO, 6-16
DEL, 5-4, 6-34
Descriptions
Commands, 5-l !IFJ.P, 5-8, B-17
Disk File 1/0, C-l
Formatted Data Entry
Screens, D-l TF/THEN/ELSE, 6-17
Intrinsic Functions, 7-l INDIC, 6-40, 6-44, D-l
Statements, 6-l INPUT, 6-18, 6-26, 6-34
Utility Programs, 8-l Input Allowed, D-l
DIM, 2-l, 6-7
Disk File T/O, C-l
Page G-l
DeltaBÁSIC Reference Manual INDEX
Input Mode ON ATTN GOTO, 6-21
Keyed access-Random, C-ll ON ATTN IGNORE, 6-21
-Sequential, C-13 ON Error Condition, 6-22
Relative access, C-6 ON GOSUB, 6-23
Sequential access, C-4 OK GOTO, 6-24
INT, 7-2 ON RESTORE, 6-25
Intrinsic Functions OPEN-disk file, 6-9, 6-26, 6-43,
Character, 7-4 C-2, E-l
Numeric, 7-1 -work station file, 6-28
Introduction, 1-l OPTION, 6-29
I/O, 3-l ORGANIZE, 8-6
IOERR, 6-3, 6-9, 6-26, 6-28, 6-33, Output, D-2
6-39, 6-40, 6-43, A-3, A-4, A-5 Output Mode
Keyed access-Random, C-lO
Relative access, C-6
KEY, 6-33 Sequential access, C-2
KEYED, 6-26
Keyed Access, C-9
KEYL, 6-26 PO, 6-11, 7-4
KEYP, 6-26 PIC, 6-11, 7-4
KEYSORT, 8-l, 8-5 POS, 7-2
Position Cursor, D-2
PRINT-forrnatted, 6-11, 6-30, 6-34
Language Compatibility, F-l -unformatted, 6-31
LEN, 7-2 Printer Mode Control, 6-29
LET, 6-19 Program Execution Mode, 4-l
LIB, 8-2 Protect, D-2
LINE, 7-2 PRTSET, 6-29
LINPUT, 6-20 PRTZO, 6-29
LIST, 5-lO
LISTP, 5-ll
LOAD, 5-12 RANDOM, 6-26
LOG, 7-2 READ-internal data, 6-32
Logical Expressions, 2-2 -disk file, 6-11, 6-33, D-I
Low Intensity, D-2 -work station file, 6-34, 6-40,
LPREC, 6-29 6-44
REC, 6-33, 6-43
RECL, 6-26, 6-28
Mandatory Entry, D-l REDO, 6-18
Mandatory Fill, D-l Relational Expression, 2-2
Multi-User Information, E-1 Relative Access, 6-43, C-6
REM, 6-35
RENAME, 5-14
X, 6-11, 7-4 RENIM, 8-l, 8-ll
NAME, 6-26, 6-28 RESET, 6-36
NEW, 6-26 Reserved Words, B-l
NEWPAGE, 6-30 RESTORE, 6-37
NOKEY, 6-9, 6-33, A-3 RETURN, 3-l, 4-l, 6-38
Yon-Display, D-2 Reverse Image, D-2
Numeric Expressions, 2-l REWRTTE-disk file, 6-9, 6-11, 6-39
-work station file, 6-40
ROUND, 7-3
OFF, 4-l, 5-13, 6-3, 6-29 RND, 7-3
OFLOW, 6-22, A-3 RUN, 4-l
ON, 6-29
Page G-2
UeÁLaDADLg ReLeLellLe nanüdj- -liyl/lji\
SAVE, S-16
Screen Design Utility, B-12
SOU, 8-l, 8-12, D-l
"-"" Sequential Access, C-2
SGN, 7-3
SHR, 6-26, E-l
SIN, 7-3
SKIP, 6-13
SOFLOW, 6-22, A-3
Spooler, 6-29
SPREC, 6-29
SQR, 7-3
Statements, 6-l
STATUS, 7-3
STOP, 4-1, 5-7, 6-3, 6-42
STR$, 7-4
TAB, 6-30
TIME$, 7-4
U, 6-29
UFLOW, 6-22, A-3
Underline, D-2
Update Mode
Keyed access-Random, C-12
-Sequential, C-14
Relative access, C—7
Sequential access, C—5
User number, 7-3
USING, 6-31, 6-33, 6-34, 6-39, 6-40
6-43, 6-44
VAL, 7-3
Variables, 2-l
Visual Attributes, D-2
WRITE-disk file, 6-9, 6-11, 6-43, D-l
-work station file, 6-44
WS, 6-28
X, 6-13
ZD, 6-13
ZDIV, 6-22, A-3
Page G-3

Navigation menu