HP 39gs_40gs_Mastering The Graphing Calculator_English_E_F2224-90010

The
DISPXY command is a hugely useful command to programmers. It appears in the Prompt section of the
MATH menu. It allows you to place a string of text at any position on the screen using two different fonts and
has the syntax:
DISPXY <x-position>;<y-position>;<font#>;<object>:
For example, suppose
M=2 & C=3. Then the command
will display the text “y=2x+3” using font number 1 (small) at the top (Ymax), left (Xmin) of the screen.
Positions are given in terms of the current screen coordinates as defined in the
PLOT SETUP view.
The next line places a label on the y axis (offset slightly) to mark the y-intercept. A check is then done to see if
an x-intercept exists and, if it does, a label is placed to mark it. Any labels off the edge of the screen will be
ignored by the calculator so you don’t need to check for that in the program. This is a very nice feature of the
HP. Many calculators have problems with objects plotted off the screen, particularly if they start on the screen
and end off the edge. The HP does not and this simplifies your programming task considerably at times.
Finally the line itself is drawn. Even though part of the line extends off the screen there is no problem - the
excess is clipped by the calculator.
The next section of code below waits until the user presses a key (
GETKEY) and stores the key’s code into the
variable
K.
A
CASE statement is then used to check for the use of the arrow keys. Notice the lack of colons (:) after each
END in the CASE statement. Normally every command ends in a colon but the code within a CASE
statement is one of the few times where this is not true.
If the left or right arrows have been pressed (keys 34.1 or 36.1) then the line is ‘twisted’ by changing the
value of
M. If the up or down arrows have been pressed (keys 25.1 or 35.1) then the line is raised or
lowered by changing the value of
C. See the manual for more information on the GETKEY and CASE
commands and on the meanings of the key values.
279