Appendix
F/ Defining
Your
Own
Menu
Commands
The Menu Demonstration
Program
uses the boxes along
the top margin for commands and
the
boxes
along the
bottom margin for color selection.
Rather
than let the
boxes
along the right and left side go to waste,
let's
add a
short subprogram
using
those boxes.
To control a Computer you must somehow
input
data
into
it.
X-Pad
inputs
data
through
the position of the Pen. By
positioning the Pen
into
one of
the
boxes along the right
margin, we are going to
put a
number
into a variable. The
program
can then use that number to
decide
what to do
next.
The new routine puts the number
of the box
the Pen is in
into
a variable called BX« Then it
branches
to one
of
5
subroutines
based
on the value of BX. Each subroutine
draws a schematic symbol
on
the screen. You can use
boxes
5-9
to branch to your
own
subroutines to draw other
symbols.
Symbol
Represents
Program Line
>W\
horizontal resistor 3010
I
vertical
resistor 3150
HH
horizontal
capacitor
3300
i
vertical capacitor
transistor
3410
3530
Putting
a number into BX really involves locating the
Pen
Point, which
is
done in several steps:
•
Is the Pen
on the paper at one of the Side Margins?
(Line
30)
•
Is the Pen at the Right
Margin?
(Line
40)
•
How far down the right side is the Pen?
(Line
50)
There are 192 increments along the
vertical
(Y)
axis,
divided into 10 boxes, so every 19.2
increments down
equals
1
box.
Look at
line
50 and suppose Y
is
102. 102/19.2
=
5,3125.
The result
is
between 5 and 6 so
we know
we are in box 5,
INT (Y/19.2) will
give
just the whole number
part,
which
is the box number.
•
Is the Pen
up? (Line
60)
Line
60
says "Keep executing
this line
until the Pen
comes up from
the
Template". This
makes the
program
wait first for a
Pen
Down
and then a Pen Up to
procede.
Without
this line,
the
program
would continue printing
the
box
number as long as
you
hold
the pen down. (Try it!)
Line
70
GOSUBs
to the
specified routine. This is the point
you will want to add
your
own
lines, using BX to GOSUB
or
GOTO
to your own routines.
Finally
Line 80 jumps
back
to the beginning to repeat the
whole
program until you
stop
it
with
(BREAK).
This
is a listing of the
Subprogram
to use the boxes along
the right
side
to draw schematic
symbols. You must
change
Line
380 of the Main Program,
to
GOSUB
to the
new Subprogram
when
S
=
7. This is done by changing
the
seventh number after
the
GOSUB from 2900 to 3630:
Note:
An FC Error will occur if
you
select
a User
Definable Box
which
has not been assigned
a
value
after
previously selecting a
Command
Box.
3000
REM
***********************
1010
REM
ROUTINE
TO DISPLAY
3020
REM HORIZONTAL
RESISTOR
3030
REM
***********************
3040
GOSUB
2870:
IF
SO 3
THEN
GOSUB
540
:
GOTO
3040
3050
SN=6:A=5
3060
LIME(X,Y)-[X+A,Y)
r
PSET;X=X+A
3070
FOR
1=1 TO
10
3080
Xl=X:Yl=YrX=X+4
3090
IF I MOD
2=JJTHEN
SN=-SN
3100
Y=Y+SN
3110
LINEEX1,Y1)-(X,Y},PSET
3120
NEXT I
3130
LINE CX
f
¥)-EX+A,Y)
,PSET
3140
RETURN
3150 REM
*********** ************
55