home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / basic / fastp12.zip / XYPLOT.BAS < prev   
BASIC Source File  |  1993-04-21  |  2KB  |  57 lines

  1. '***********************************************************************
  2. '                           Fast Parser 1.2
  3. '              Copyright (C) 1992, 1993 by Daniel Corbier
  4. '                         All rights reserved.
  5. '
  6. ' This example will plot user defined equations in the regular
  7. ' cartesian coordinate system.
  8. '
  9. ' It features:
  10. '
  11. ' VarName$()    Allows Fast Parser to recognize the variable name
  12. '               'x' in the user expressions.
  13. '
  14. ' EqParse%()    Parses the expression before the loop is started.
  15. '
  16. ' VarValue##()  Allows Fast Parser to make the connection between
  17. '               the name 'x' and the actual value x.
  18. '
  19. ' Evaluate##()  Evaluates the user expression.
  20. '***********************************************************************
  21.  
  22. $Include"calc.inc"
  23.  
  24. Screen 9            '  Use screen 1 if you don't have EGA
  25. Window (-10,-7.5)-(10,7.5)
  26.  
  27. Print "To accept the default equations, press [enter]"
  28. Print
  29.  
  30. Input "Please input equation 1 of 3:  [sin(x)] ", Equation1$
  31. If Equation1$="" then Equation1$ = "sin(x)"
  32.  
  33. Input "Please input equation 2 of 3:  [tan(x)] ", Equation2$
  34. If Equation2$="" then Equation2$ = "tan(x)"
  35.  
  36. Input "Please input equation 3 of 3:  [x^2*sin(x)] ", Equation3$
  37. If Equation3$="" then Equation3$ = "x^2*sin(x)"
  38.  
  39.  
  40. '***  Here's the meat of this example  ***
  41.  
  42. VarName$(0) = "x"        ' Defines  x  as a recognized variable name.
  43.  
  44. Eq1% = EqParse%( Equation1$ )    ' You can parse several equations,
  45. Eq2% = EqParse%( Equation2$ )   ' and then use them any time later
  46. Eq3% = EqParse%( Equation3$ )   ' in your program.
  47.                 '
  48.                 ' Eq1, 2 and 3 are simply pointers
  49.                 ' to the parsed expressions.
  50.  
  51. For x=-10 to 10 step .05
  52.     VarValue##(0) = x
  53.  
  54.     Pset(x, Evaluate##(Eq1%) ),9
  55.     Pset(x, Evaluate##(Eq2%) ),10
  56.     Pset(x, Evaluate##(Eq3%) ),11
  57. Next