beautypg.com

Rpbasic-52 programming guide, Clear clear s – Remote Processing BASIC 52 User Manual

Page 32

background image

RPBASIC-52 PROGRAMMING GUIDE

2-13

CLEAR
CLEAR S

Syntax:

C L E A R
C L E A R S

Function:

Sets variables to zero, clears stacks

Mode:

Comm and, run

Use:

C L E A R
C L E A R S

Cards:

All

D E S C R IP T I ON

The CLEA R instruction sets all variables to 0 and resets all Basic stacks. ONER R is cleared. Error trapping
must be redeclared after a CLEAR. CLEAR is generally used to clear all variables. CLEAR does not de-
alloca te me mory alloca ted to st rings by the ST RIN G inst ruction . It does c lear the conte nts of th e string s.
Data put to the stack by PU SH is cleare d. CLEA R also resets an y FOR -NEX T loops. A C -STAC K error is
returned when a NE XT is performed after a C LEAR . CLEAR also resets any GOSU B return addresses.

Use CLEA R to perform a soft reset of a program. Keep in mind that multi-tasking routines are not cleared or
r e se t us i ng t hi s co m m a n d. H o w ev e r, if C L E A R is u se d a s p a rt o f a m u lt i -t a sk i ng p ro g ra m ( O N C O M $ , O N
LINE, etc .), a RETU RN w ill cause a C-S TAC K error.

CLE AR S resets the control stac k (C-STA CK) only . This stack is used in loops and subrou tines to tell it
w h e re t o r e tu r n t o . U s e th i s c o m m a nd t o b r an c h (G O T O ) o ut o f F O R - N E X T , G O S U B - R E T U R N, D O -
UNTIL type structures. It can be used in emergency stop situations where nesting of loop structures is not
known. Variables are not cleared using CLEAR S.

RELATED none

EXAMPLE

10 CLEAR TICK(0)
20 ONTICK 1,1000
25 ONERR 500
30 IF TICK(0)<2.5 THEN 30
40 A=TICK(0)/0
50 IF TICK(0) < 3.3 THEN 50
60 CLEAR
70 PRINT "CLEARED"
80 GOTO 80
500 PRINT "IN ERROR"
510 ONERR 500
520 GOTO 50
1000 PRINT TICK(0),A
1010 A=A+1
1020 RETI

>RUN
1 0
2 1
IN ERROR
3 2
4 0
5 1
6 2