Atari ST BASIC Sourcebook Part1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 58

ST BASIC'· Sourcebook

)llATARr

Every effort has been made to ensure the accuracy of the product documentation in this manual. However, because we are constantly improving and updating our computer software and hardware, Atari Corp. is unable to guarantee the accuracy of printed material after the date ot publication and disclaims liability for changes, errors, and omissions.

ATARI, ST, ST BASIC, and 520ST are trademarks or registered

trademarks Atari GEM is a trademark Digital

Research Inc.

No reproduction of this document or any portion of its contents is allowed without the specific written permission of Atari Corp., Sunnyvale, CA 94086.

~ATARI®

1985 Atari Corp. All Rights Reserved.

BASIC

SHEET

System Disk and a 1 ted amount

from memo

re are two me

to enhance the ava

e memo

space:

1. Turni ff B fer Graphics option will ovide an

a itional 32,000 bytes of memory. Point at the Run Menu on

BASIC Desktop and see whether there is a check mark in front of Buf Graphics. If the check mark is present, select Buf Graphics. When the Dialog Box appears, click on the Ok button to turn off the Buffer Graphics option.

Note: If you turn off the Buffer Graphics option while you have a program in memory, the program will be lost.

2. Disabling the GEM desk accessories will provide 30,000 additional bytes of memory_ Refer to page 17 of the ~ BASIC SQurcebook for instructions.

Reseryed NQLd lists

The following words should be added to the reserved word list in the manual:

ALL INTOUT
AND MOD
AS NEXT
BASE NOT
CDBL OCT$
CSNG
DEF OPEN
ELSE OPENW
OPTION
FIELDi OR
GB OUT
# PCIRCLE
PTSIN
IMP PTSOUT
INKEY$ SYSDBG
INTIN THEN
USING INTRODUCT

BAS is the most commonly language. It is easy-to-learn,

ogramm tool. BASICH.! is

mainstream ects of BASIC,

windows, op-down menus, and Desktop. This version of BASI speed and gr ic capabilities

computer PI' ramming

still a rful

very similar to the advantage the so takes advantage of of the 520ST™Computer

~ BASIC Sourcebook is set up for easy access to all

information a programmer needs. For the first-t BAS

programmer, work through the examples in Section I of the manual. The special characteristics of the language and the BASIC Desktop are demonstrated.

Sect 2 is the reference section of the manual, conta

comprehensive Appendices on every aspect of the language. A description of each reserved word, logical operators and order of precedence, Error Message listing, and sample programs are all provided.

Whether you are a beginni programmer or an expert, it is

important that you make a kup copy of the ST Language disk

before you begin programming. Refer to the ~20ST Owner~ Manual for detailed instructions on making a backup disk.

TABLE OF CONTENTS

SECTION 1: GETTING STARTED WITH ST BASIC ••.•......••...•. 1

Loading ST BASIC 1

Touring the ST BASIC Desktop ..........•.......•.••..•.. 2

Windows .••.......•.•.•.......•......•..•..••.....•• 2 Menus .••••••.••.••.••...••.•.•..••••.••••.•••....••. 5

Dialog Boxes and Error Messages .••...••..•.••...••. S

Special Features 5

Writing an ST BASIC Program .•...••...••..•.•.••.•...•.. 6

Entering A Program .......•..••....•..•...........•• 7 Running A Program ••..•.......•..••.........•...•••. 8

Editing A Program 8

Debugging A Program •..•••••.•..••...••••••.•.•.... 12 Saving A Program ..•....•.•.•.•.•.•..••••...••.•.•• 14

Loading A Program 15

Merging Programs ...•....•.....•.•••••.•..•••....•• 1S Deleting A program •.•..•....•••..••.•..•.•.•.••.•• 16 Leaving ST BASIC .••..•...•.•••••••.•••••.••••...•• 16 Typing Commands ••••••.•.•.•••.••••••.••••••••••••• 16 Buffered Graphics ....•.....•.•....•.••..••......•• 17

SECTION 2: APPENDICES

Appendix A:
Appendix B:
Appendix C:
Appendix D:
Appendix E:
Appendix F:
Appendix G:
Appendix H: CUSTOMER SUPPORT

ST BASIC Reserved Words .•••.•••.....•••. A-l

Logical Operators, Order of Precedence,

and ST BASIC Functions .....••••••.•..... B-l

Commands, Functions, and Statements .••••. C-l

ST ASCII Character Set •.••••..••.•...•.• E-l

Assembly Language Modules •••..•••...•..• F-l

De r ived Functions .••.........•••......•• G-l

Sample Programs .•...•....•......•....... H-l

1

BASIC

works r stem.

t

ts:

sk

am

BASIC, you should

Having a backup erasing or

ATARI 520ST making a backup

language instructions shown

a one e ,

One Di Dr Iv e ... instructions 1

If led,

the GEM Desktop on the
on the Disk B icon.
to Di B into
disk A and press
D ick on the
1 on the video ST Di

Des on the

sk into Drive

1

2. When the Floppy Disk B window opens, double-cl k on the BASIC.PRG icon. The BASIC Desktop will appear on the video display screen.

The BASIC Desktop is the main point of reference for all your work with ST BASIC. The next two parts of this section show how to write a simple program in ST BASIC and how the BASIC Desktop works with the programming language.

TOURING THE ~ BASIC DESKTOP

ST BASIC uses the standard operating procedures of the GEM Desktop. The procedures for accessing menu items, selecting options, manipulating windows, and loading applications are explained in detail in the ATARI 520ST Owner~ Manual.

WINDOWS

The ST BASIC programming environment includes four windows:

Command, Output, List, and Editor. After you load the ST BASIC program and the BASIC Desktop appears on the screen, the Command Window is active, and all four windows are available. (The Edit Window is available, but only a small part is visible under the List and Output Windows.)

The procedures for sizing, moving, opening, closing, scrolling, and managing multiple windows are identical to the

2

r

f

er

ix D.

f

PRINT 2

or use an f

? [Ret

answer 4,

You

?

4

in

D

t

PRINT "11M

R FAITHFUL ATARI COMPUTER" [Return]

memo To stop the AUTO

[Contr ], then press

in the Command Window. Type LIST

1 is too long for the List

Size Box at the lower right edge of the the window until it is long enough to am list

ST BASIC s a RENUM command that allows you to renumber your

am automatical RENUM uses your disk drive, so be

sure have a sk in it.

Note: s function will not work with a write-protected

• To use the RENUM function, push the write-protect tab

on the to the unprotected position. For more

r r to Chapter 6 of the ATARI 520ST Owner's

Type

RENUM 30,10,5

urn]

Ok prompt reappears, list old line 10 has become line r rement is 5, so the next line number command is explained in detail in Appendix

is c.

Labels

so lows to ~se labels to help identify

s For example, using a statement like GO TO DONE GOTO 300 makes for more readable listings and

easier to i i each program line does for

am

PROGRAM

This section shows you how to write and use simple

pr ramming techniques within the GEM Desktop environment.

ow instruct carefully.

6

Note: You can wri letters or upper-

ST BASIC pro lowercase 1

i ei rs.

1

ta

ENTERING A PROGRAM

If there is anything in

List W

ear it

CLEARW 1

Then type NEW [Return]

This clears any current

ogram from memory. Type

LIST [Return]

The LIST Window will now be blank. Type AUTO [Return]

and enter the following program. numbers are provided by ST BASIC. the numbers.

Notice that the line You QQ llQt have to

10 REM COUNT.BAS 20 C=O

30 COUNT: I INCREMENT THE VARIABLE C 40 C=C+l

50 PRINT Ci

60 IF C=5 THEN PRINT "AGAINl":GOTO 20 70 GOTO COUNT

Now you have the COUNT. BAS program in memory.

Type [Control] [G] to stop the AUTO program.

This simple program

ustrates a few ST BAS

features.

Line 10 has a REMark t pari its fUnct on.

REMark ST BASIC You can gin REMar

single , as line 30.

Line 30 if

same label in a GOTO statement. A

a on (:) first f

reserved word; it must a

any s in the 1 1 name.

s

to use r line

on a

you want one 1

and the 1 ne s

as n

colons

RUNNING A PROGRAM

menu from the Menu Bar ill see

cl

on the

pr nt cont nuo program, cIon message -- Break -- ine stopped running~ Type STOP When your ogram commands.

move}

i • tells [Return] in Break

am

mode you can

use

1 at a time by

menu.

press that are

[Ret urn 1

to

ion.

EDIT NG

has an easy-to~use editor that al you to

in your program w thout having to re-enter an entir

8

program line. To

cl the start

program, select the Edit menu and (or

edit, want cont ) on

Cu:::sor Cont

in the word IiAGAINiI word "AGAIN". Type s to present lines Press

s to put rsor on

in line 60. You can now type over MORE. Notice that the type style

st line". Ifghost linesft show

edited put into

You st to discar

am

e going further select the Help

it option in

Edit

menu.

Desk fUe Run fdit Debug
, UST OUTPUT
I
NflP EDIT: I
I
I
I
Insert Spin - F1 I
I
Ddrtr Clt.r - Ft I
I
Insert Lint - f1 I
,
Dlhtt lint - F4 I
".1 Up -F5
Plgt Da .... -n
laid Tnt - f7 '. =:
SiIIl Tlllt - F8
II
11111 Buffer -n
Exit Edit -F1I ~
I Ok I

I~
<>1 t J-:-I!J Edit Di with

describes

ction

e

conti

allowing am. However f the Edit menu options.

use the prefer,

keys to

use the mouse

9

IT SOME

60 IF

I'

New B

er

Insert L

L

Move from Ie.

ete

ss correct

Move

s

t L

Now

s

h is 80 characters. If

e text

see what you i r e t

max

you of

the screen wil move to n you attempt to acte , the printed on the line

il be included ac

edit the line

se

so you can enter them as

s.

Leave s s i nq (FlO)

ng

Exi

t unct on or

DEBUGGING A PROGRAM

oce s. Two is doing and e ce

menu, debugging a ogram is a simple

u a

what the problem might be These

Tron.

2

k on the Trace ion.

on the Ok

" ..

" ..

Ii ..

" ;0

'" II

10

• • • •

Ii 5 ...

ox . Ie MtEl I

on

the Di

e

enti

xit the Trace , stop

menu, and click on Untrace option.

button in the Trace Dialog Box.

am, sele Click on

on the Tron

menu.

ion in the

TROI:

13

isplays the prog am's ea pr am ine i

in the

Click on the Ok button in the

Box.

Run on

am is executed,

sine

opt on, stop your program, select the Debug on the Troff option Click the Ok button in

To exit menu, and

TRACE and TRON are explained in

SAV NG

tai

x C

save your program to disk, select the File menu from the

Bar ikon Save As opt on.

l)irettliry: \*,BAS_~_

~lia::r:~~!~~_

I ==::=

1--,-

L.~ .~

COUNT BASIC appends a tells ST BASIC store f e s

ce f name The e BASIC program ile To button. When the Ok

iIe is an isk, click the s

You can also save the program by typing

SAVE

n

ST BASIC

1 save the program as COUNT BAS

14

ST Ie

To

ST BAS

on

ronment,

ect

ST are

e

POS PRINT

<

ST

ow

;:

HI

C

Items cannot

s, e ar

case are ST BASIC

ASC 1% = ASC $)

Syntax: 1% = ASC «std,nge

FUNCTION: Ret string*

the ASCII

Explanation:

ASCreturns. an integex: tween 0 contain at lea one character. a null string, an error numberS occurs.

Example:

OklO A$ = "Murppy,James" Ok 2 0 PRINT ASC(A$)

Ok RUN

77 Ok

ices

The CRRS function is the inverse of ASC. for a list of ASCII characcer svand co rr.eanonc values .•

ATN 1 == ATN

"" ATN( <nume r

es

Syntax:

e

FUNCT

Explana

The ATN ion r

angle radians

function is the

ns a ranges om se of ATN.

Example:

a

2

s

Ok 10 RADIANSl :: ATN ( 0 • 9 9 9 9 9 )
Ok 20 PRINT HThe angle in radians a;RADIANS!
Ok 30 PRINT
Ok 40 PI :: 3.14159
Ok 50 DEGREES:: RADIANS! * lBO/PI
Ok 60 PRINT liThe e degrees is" iCINT (DEGREES)
Ok RUN
The angle in radians is .7853
The angle in degrees is 45
Ok AUTO

[<start

1

[,<incr

)]

A

time you press the

off. A line number Command

a executed

anation:

r to generate and the number line number. If you do not r, AUTO starts at line 10. If , AUTO uses either 10 or the AUTO command.

ready exists, prints two asterisks

r a new program line, it will you press [Return]. If you

d program line will remain

A [Contr function as am 1

s urn] • it w

AUTO. But it does not perform the same A [Control] [G] does not enter a

1 not an eXisting line.

Ex

e:

10

3

OK

50

r

25

BREAK

4

1

UNBREAK

ex

am executi st

or END

ter next

, 2

BSAVE Saves

f

Ex

o

23,6

r

IN CHAIN

r

The progr or I na.l sometimes part of the new file name.

The MERGE

stead of r type MERGE newly statements in o r i nal PI'

You can a

indicati Otherwise, statement.

am are CHAIN MERGE.

i

See:

Ex

e

ins to

BAS

am can

ov 1

ine

MERGE

r

0, DELETE 900 0 0

AS :::: CHR

$ :::::

s

e

ue.

anation:

CHR returns a

act r

ri

numeric e

mu

uate to a

r

ASCII value 256. This means number 0 256 r it w 256.

racter retur

is

MOD

$ converts r

rs.

Use the CHR fUnct to

line feeds or carriage returns,

CHR$ function is inverse f

as

e:

10 PRINT s ( ) 20 PRINT CHR$(lOO

30 PRINT $(3

RUN

S d d

e:

5

68 to 3

e:

e clears am

eras

EAR

i

1

from

am

<numeric express >

EARW

ears BASIC w

ears ifi w The w are as
ows
0 :::::
1 :::::
2
3 :::::
Ex e: 10 CLEARW 2

OK 20 PRINT "HELLO" OK RUN

# 1

in commas.

f # f

e f

t

Note: NEW, END, RUN, LOAD, OLD, f e s aut i f es.

E e:
ow statement ose
0 CLOSE
f sta
as i
60 #3 d

CLOSEW CLOSEW 1

Syntax: CLOSEW <window number>

STATEMENT:

ose one basic window.

Explanation: Used to close one of four basic windows. This call has tc be made separately to close each window. <Window number> specifies windows as follows:

o - The Edit Window. 1 - The List Window.

2 - The Output Window. 3 - The Command Window.

Note: CLOSEW does certain bookkeeping chores internal to the BASIC interpreter that allow the system to keep track of the window status. Therefore, do not c~ose basic windows using direct calls to AES.

C 9

COLOR

1, ,I r

text,
Explanation:
COLOR sets
the output
color of lines
color
subsequent PRINT
color text or
The chart below
resol
NUMBER LOW MED HI
0 X X X
1 X X X
2 X X
3 X X
4 X
5 X
6 X
7 X
8 X
9 X
10 X
11 X
12 X
13 X
14 X
15 X 1

e

r s for

s in

fer

The following numbers 4

o

6

00, (

MOD

0) MOD 3600

COMMON COMMON A$, COUNT, N

Syntax: COMMON <variable),<variable)

STATEMENT: Declares the variables that a program can pass to a chained program.

Explanation:

ST BAS treats all COMMON statements in a program as one consecutive list of variables. A program can contain any number of COMMON statements.

COMMON statements can appear anywhere in a program. It is good practice to place them at the beginning of a program.

Use COMMON with CHAIN.

See: CHAIN

Example:

The following example chains to a program named EMPLOYEE and passes the variables VAL!, NAME$, and the array variable SCALE() •

Ok 350 COMMON VAL!, NAME$, SCALE() Ok 360 CHAIN "EMPLOYEE-

2

i f

In BREAK ate

se

GOTO

to direct

e 30

x = COS(y)

( <nume r

e

e

Syntax: X =

ns the cosine

a

on:

returns a

ic functions :r

ST BAS

angles in s.

Example:

Ok 10 PI = 3.14159 Ok 20 DEGREES = 180

Ok 30 RADIANS = DEGREES * 11

Ok 40 ANS! = (RADIANS)

Ok 50 PRINT COSINE IS ";

RUN

THE COSINE IS -1 Ok

4

r

re

c

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy