home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / sharewar / gdidbpro / data1.cab / Example_Files / projects / default / calculator.scp < prev    next >
Text File  |  2000-05-26  |  1KB  |  59 lines

  1. ##########################################################
  2. # GDIdb demo script (c) 1998 Global Data Industries
  3. #
  4. # This script works as a simple calculator program.
  5. ##########################################################
  6.  
  7.  
  8.  
  9.  
  10. ##########################################################
  11. # declare variables used in script
  12.  
  13. &defvar(?var1?,?var2?)
  14.  
  15.  
  16.  
  17.  
  18. ##########################################################
  19. # Print the information screen
  20.  
  21. &cls
  22. &print("Calculator Demo Script")
  23. &print("---------------------------------")
  24. &print("Press cancel or enter \"quit\" to terminate script.")
  25.  
  26.  
  27.  
  28.  
  29. ##########################################################
  30. # the following  loop will be evaluated until the user
  31. # presses cancel (or enters quit)
  32.  
  33. &loop(TRUE)
  34. {
  35.     # ?var1? will contain "quit" unless the user
  36.     # actually enters a value
  37.     &assign(?var1?,"quit")
  38.  
  39.     # get expression from user
  40.     &input(?var1?,"Enter Arithmetic expression")
  41.  
  42.     # check that ?var1? does not equal "quit"
  43.     &if("?var1?",ne,"quit")
  44.     {
  45.         # calculate string as arithmetic expression using the
  46.         # assign function
  47.         &assign(?var2?,?var1?)
  48.  
  49.         # and print the results
  50.         &print("?var1?=?var2?")
  51.     }
  52.  
  53.     # if ?var1? equals "quit", jump out of the loop
  54.     &else
  55.     {    
  56.         &break
  57.     }
  58. }
  59.