bas7ex.hlp (Topic list)
SQR Function Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'The following program uses the SQR function to plot the graph of
'y = sqr(abs(x)) for -9 <= x <= 9.
 
SCREEN 1 : COLOR 1           'Low-resolution color graphics mode.
WINDOW (-9,-.25)-(9,3.25)    'Convert screen to Cartesian coordinates.
LINE (-9,0)-(9,0)            'Draw X-axis.
LINE (0,-.25)-(0,3.25)       'Draw Y-axis.
FOR X = -9 TO 9
    LINE(X,.04)-(X,-.04)     'Put tick marks on X-axis.
NEXT X
FOR Y = .25 TO 3.25 STEP .25
    LINE (-.08,Y)-(.12,Y)    'Put tick marks on Y-axis.
NEXT Y
PSET (-9,3)                  'Plot the first point of function.
FOR X = -9 TO 9 STEP .25
    Y = SQR(ABS(X))          'SQR argument cannot be negative.
    LINE -(X,Y),2            'Draw a line to the next point.
NEXT X