OPEN (O.)
This command will open a designated channel for input or output
to a peripheral, or to the screen itself. A code number is used
to determine the operation to take place. The 0 is usually a dummy.
Example: OPEN #2,8,0,"D:FILENAME"
The second parameter is as follows:
4=INPUT
6=DISK DIRECTORY INPUT
8=OUTPUT
9=END OF FILE (allows input from screen editor)
12=INPUT AND OUTPUT
OR
A logical operator. It will return 1 if any one of certain conditions
are true.
Example:
A=(B=2) OR (C=3):
REM *** A=1 if either bracketed statement is true, else A=0
PADDLE
This will read the (numbered) paddle controller and return a number
between 0 and 228. The paddles can be read directly from locations
624-631, which are the shadow locations for 53760-53767. They can
be used with conditional statements (IF/THEN).
Example: ? PADDLE(0)
PEEK
Used to look into a memory locations without changing what is
stored there. The location asked for can be an expression or a decimal
number (0-65535). A decimal number (0-255) will be returned.
Example: 10 P=PEEK(764):
REM *** Last key pressed
PLOT (PL.)
Used to display a point on the graphic mode screen. The X-coordinate
is given first followed by the Y-coordinate. The colour of this
point is determined by the last COLOR statement, which is changed
by using a suitable SETCOLOR. It is normally used with DRAWTO.
Example: PLOT 10,10
POINT (P.)
Used with NOTE in disk operations to read a file into RAM, in
effect giving random access to the user. The first variable is the
IOCB#, the second is the sector, and the third is the byte within
the sector. More details can be found in the DOS manual.
Example: POINT #2,320,12
POKE (POK.)
Associated with PEEK. It will store a given number (0-255) in
the specified (RAM) memory location. System Reset will restore memory
locations to their default positions.
Example: POKE 710,32
POP
The Atari stores the number of loops to be executed by a FOR/NEXT
command, the return address for a GOSUB etc. in what is termed a
STACK. If a GOSUB does not have a RETURN, for instance, the stack
will still hold the return address. This can be cleared with a POP
so as not to cause confusion later. It must be used in the execution
path of the program, and must follow a GOSUB not using a RETURN.
It is normally the sign of a badly designed program, but is useful
in debugging.
Example: 100 POP
POSITION (POS.)
This will set the cursor (on or off) to the coordinates X, Y
on any of the graphics modes. It is normally used with PRINT, but
can be used with PUT and GET.
Example: POS. X,Y
PRINT (PR. or ?)
Can be used in direct or deferred mode. The command will print
exactly what is in between the quotation marks (entering quotation
marks within quotation marks will cause an error), or the value
of a variable at the time of asking. When used with an I/O it will
print from the file designated (i.e. #). Print statements can be
spread over several command lines yet the writing will appear continuous
when a semi-colon (;) is used to denote that the next PRINT is a
continuation of the last line. Commas will cause tabbing to the
next TAB position. The screen margins may need to be changed by
POKE 82 and 93 to accommodate the tab positions (these can be reset
by POKEing location 201 to set the TAB width). PRINT by itself will
skip a line.
The normal screen editing functions
can be used to move the print statements around the screen. For
instance, ? "ESC-TAB ESC-TAB PAGE6", will print PAGE6
at the second tab position. The functions can themselves be printed
by preceding then with the ESCAPE character. For example, PRINT
"ESC-ESC ESC-TAB", will print the tab sign. For more details
about this, please refer to 'FIRST STEPS', PAGE 6, issues 9 and
12.
Example:
10 ? "THIS IS";
20 ? "ONE LINE"
30 ? "COMMAS", "CAUSE", "TABBING"
40 POKE 82,0:FOR N=1 TO 20: ? N:NEXT N
49 REM ***Try this without the POKE to change the margin
50 ? "VALUE="
60 ? #3, A$
PTRIG
This returns the value of the designated paddle trigger (0=pressed,
1=not pressed). Can be PEEKed from locations 636-643, the first
four are shadows for 54016 and the last four are 54017.
Example: 10 IF PTRIG(0)=1
THEN ? "NO"
PUT (PU.)
Opposite of GET. This will place a byte (0-255) in the file
designated by #. If it is #6, then the byte will be placed on the
screen and appear as a character in the text modes, and a colour
in the graphics modes. In this case PUT is normally used with POSITION.
Example: PUT #6,ASC("A")
RAD
Opposite of DEG, will set the computer to radian mode.
READ (REA.)
Used with DATA. The number of READs must not be more than the
amount of DATA, which can be in the form of numbers or words (strings).
READ must have an associated variable or string (previously dimensioned)
to place the data into. If used in the direct mode, the data must
be directly associated with the program, i.e. on the same command
line.
Example:
10 DIM A$(6):FOR D=1 TO 5:READ
A$:? A$;:NEXT D
50 DATA READ, AND, PRINT, THE, DATA
REM (R. or .space)
Used to place statements or remarks in the program for easier
understanding. They do take up space and, if RAM is critical, they
can be left out. Good programmers tend to use REMs on lines ending
in non-zero, usually 9 (i.e. 9, 19, 28, 29 etc). Never, ever send
a GOTO or a GOSUB to a REM! They are usually starred, or have a
single REM on the line before and after, to make them more noticeable.
Anything after REM will not be executed, so you can add commands
that will be valid later in the life of the program, i.e. after
debugging.
Example:
9 REM *** DELETE 'REM' IN LINE
10 AFTER DEBUGGING
10 REM RUN "D:NEWPROG"
RESTORE (RES.)
Used with READ/DATA. The current position of the data to be
read us noted by the computer. This can be reset to another line
number by using RESTORE. This means that DATA need not be read sequentially.
This, if you have several bits of data to place into a player, they
can be read in any order to suit the program. Unfortunately this
is too often used when not needed, i.e. bad programming.
Example:
10 RESTORE 100: READ A
20 RESTORE 90: READ B
RETURN (RET.)
Used with GOSUB to return to the main program from a subroutine.
The return address is held on the program stack. Trouble can occur
if a subroutine is not exited correctly. See GOSUB and POP.
RND
Returns a randomly generated number between, but not including,
0 and 1. To get other ranges, just use a multiplier or divider.
INT will delete the numbers after the decimal point to give a whole
number. The number in brackets is a dummy and must be used. You
can also PEEK (53770) to give a random number in the range 0-255,
which is far better than INT(RND(0)*256).
Examples:
X=RND(0)
X=INT(100*RND(0))
RUN (RU.)
This will begin the execution of a program at the first line.
It can be used in deferred or direct modes. It will zero all variables,
close all files and channels (including sound), and eliminate all
strings, arrays, and matrices. However, if the program is rerun
you may find that the arrays may contain spurious data, i.e. garbage.
This may have to be cancelled or the proper data re-input. If a
file is named, it will load and run that file. To run a program
from some other entry point use GOTO with the required line number,
although this can cause errors such as a file not opened yet, no
GR. mode, etc.
Examples:
RUN
RUN "D:NEWPROG"
SAVE (S.)
Similar to CSAVE but used with a drive. If only one drive is
used then the drive identifier can be left out. Unfortunately, this
type of save will not clear out unused variables, so lockups can
still occur.
Examples:
SAVE "D:NEWPROG"
10 SAVE "D2:NEWPROG"
Concludes Next Issue
top