home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 2 / amigaformatcd02.iso / demos / mmexperience / arexxscripts / quiz.rexx < prev   
OS/2 REXX Batch file  |  1996-05-20  |  2KB  |  66 lines

  1. /*
  2.   MME AREXX SCRIPT - A QUIZ APPLICATION
  3.  
  4.   Copyright (c) 1995 Optonica Limited
  5.   Written by Kevin Stevens
  6.  
  7.  This script is called by MME from a media clip to increment
  8.  the users score held in a result file
  9.  Enter these arguments in the MME Program arguments area
  10.     1 NEW     (first time CORRECT)
  11.     0 NEW     (first time WRONG)
  12.    1         (second & subsequent times CORRECT)
  13.    0         (second & subsequent times WRONG)
  14.    1 DONE (last time CORRECT)
  15.    0 DONE (last time WRONG)
  16.  You can set the good and merit variables below to set the pass marks
  17.  You will also need to create the required media clips in MME
  18. */
  19.  
  20. /* get the callers argument(s) */
  21. parse upper arg increment option
  22.  
  23. good = 10                        /* quiz pass mark */
  24. merit = 15                       /* quiz merit pass mark */
  25.  
  26. value = 0                        /* initialise the result variable */
  27. resultFileName = "T:MME_Result"  /* name of the result file to use */
  28.  
  29.  
  30. /* read a result from an existing result file (if its NOT a new user) */
  31. if option ~= "NEW" then do
  32.    if open( ResultFile, resultFileName, Read) ~= 0 then do
  33.       value = ReadLn( ResultFile )
  34.       close( ResultFile )
  35.       end
  36.    end
  37.  
  38. /* increase the result and write out the NEW result */
  39. value = value + increment
  40. if open( ResultFile, resultFileName, Write) ~= 0 then do   
  41.    WriteLn( ResultFile, value)
  42.    close( ResultFile)
  43.    end
  44.  
  45. /* test if it's the last time this script is called - if so show an mclip */
  46. if option = "DONE" then do
  47.    ADDRESS COMMAND ('C:Delete '||resultFileName||' QUIET')
  48.    if show('P',"TOMMEPORT") then do
  49.       if value >= merit then do
  50.          ADDRESS TOMMEPORT MEDIACLIP "s/quizMerit.mclip"
  51.          end
  52.       else if value >= good then do
  53.          ADDRESS TOMMEPORT MEDIACLIP "s/quizPass.mclip"
  54.          end
  55.       else do
  56.          ADDRESS TOMMEPORT MEDIACLIP "s/quizFail.mclip"
  57.          end
  58.       end 
  59.    else do
  60.         say "MME not running. Score = "||value
  61.         end
  62.    end
  63.  
  64. /* all done */
  65. exit
  66.