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

  1. ##########################################################
  2. # GDIdb demo script (c) 1997 Global Data Industries
  3. #
  4. # This script will time the time it takes you to evaluate
  5. # an arithmetic expression, and test the answer to see if
  6. # it's correct.
  7. ##########################################################
  8.  
  9.  
  10.  
  11.  
  12. ##########################################################
  13. # declare variables used by script
  14.  
  15. &defvar(?var1?,?timeval?,?oldtime?,?time?)
  16.  
  17.  
  18.  
  19.  
  20. ##########################################################
  21. # Print the information screen
  22.  
  23. &cls
  24. &print("Calculation Test Demo Script")
  25. &print("------------------------------------------")
  26.  
  27.  
  28.  
  29.  
  30. ##########################################################
  31. # start script main execution loop
  32.  
  33. &do
  34. {
  35.     # get the current time in seconds
  36.     &assign(?oldtime?,?gdidbtime.h?*60*60+?gdidbtime.m?*60+?gdidbtime.s?)
  37.  
  38.     # get the user's answer to the problem
  39.     &assign(?var1?,"quit")
  40.     &input(?var1?,"What's 2+6*8\?")
  41.  
  42.     # get the new time (in seconds)
  43.     &assign(?timeval?,?gdidbtime.h?*60*60+?gdidbtime.m?*60+?gdidbtime.s?)
  44.  
  45.     # calculate the time taken to respond (in seconds)
  46.     &assign(?time?,?timeval?-?oldtime?)
  47.  
  48.     # check that ?var1? does not equal "quit"
  49.     &strtrim(?var1?,"?var1?")
  50.  
  51.     &if("?var1?",ne.nc,"quit",AND,"?var1?",ne,"")
  52.     {
  53.         &if(?var1?==2+6*8)
  54.         {
  55.             &print("Correct!")
  56.             &if(?time?<4)
  57.             {
  58.                 &print("You took ?time? seconds to answer- that was quick!")
  59.             }
  60.             &else
  61.             {
  62.                 &print("You were a bit slow though. (?time? seconds)")
  63.             }
  64.  
  65.             # user got it right, so end script
  66.             &print
  67.             &break
  68.         }
  69.         &else
  70.         {
  71.             &print("Wrong!")
  72.         }
  73.     }
  74.     &else
  75.     {
  76.         &print("What's wrong- too complicated for you\? ;-)")
  77.         &print("You took ?time? seconds to think about that.")    
  78.     }
  79.  
  80.     &msgbox(?var1?,"Do you want another go\?",yesno|iconquestion)
  81.     &cls
  82.  
  83. } &while (?var1?==6)
  84.