home *** CD-ROM | disk | FTP | other *** search
/ Mind Games (Tessera) / MindGames.iso / mind_games / Files / quiz.dxr / Internal_4_CheckingForTheDatabase.ls < prev    next >
Encoding:
Text File  |  2002-11-22  |  1.9 KB  |  95 lines

  1. global osdir, TotalPoints, QuestionsAsked, HalfWayThere, lastscore, QuestionsList, TheDB, TheTable, gIsPaused_flag, gMiaw_flag, gxronos, gMaxTime, gKrataTime
  2.  
  3. on KrataTime
  4.   if gIsPaused_flag or gMiaw_flag then
  5.     gKrataTime = gMaxTime - gxronos
  6.   else
  7.     startTimer()
  8.   end if
  9. end
  10.  
  11. on prepareMovie
  12.   the windowList = []
  13.   gKrataTime = 0
  14.   gMaxTime = 15
  15.   gxronos = 0
  16.   gMiaw_flag = 0
  17.   HalfWayThere = 0
  18.   funcs = baRegister("Gaide Sofia", 2831852)
  19.   osdir = getOSDirectory()
  20.   DBExists = baFileExists(osdir & "\Quiz.4db")
  21.   if not DBExists then
  22.     Ok = baCopyFile(the moviePath & "Quiz.4db", osdir & "\quiz.4db", "always")
  23.   end if
  24.   if Ok <> 0 then
  25.     alert("DATABASE ERROR ", Ok)
  26.   end if
  27.   SetInitialValues()
  28.   MakeRandomListOfQuestions()
  29. end
  30.  
  31. on stopMovie
  32.   member("Highscoreuser").text = EMPTY
  33.   closeDB()
  34. end
  35.  
  36. on SetInitialValues
  37.   HalfWayThere = 0
  38.   TotalPoints = 0
  39.   QuestionsAsked = 0
  40.   setlastscore()
  41. end
  42.  
  43. on MakeRandomListOfQuestions
  44.   QuestionsList = []
  45.   EmptyList = []
  46.   repeat with i = 1 to 35
  47.     QuestionsList[i] = 0
  48.   end repeat
  49.   repeat with i = 1 to 181
  50.     EmptyList[i] = i
  51.   end repeat
  52.   repeat with i = 1 to 35
  53.     ValuePassed = 0
  54.     repeat while not ValuePassed
  55.       TransferVar = EmptyList[random(181)]
  56.       if getPos(QuestionsList, TransferVar) = 0 then
  57.         QuestionsList[i] = TransferVar
  58.         ValuePassed = 1
  59.       end if
  60.     end repeat
  61.   end repeat
  62. end
  63.  
  64. on setlastscore
  65.   OpenDB()
  66.   LoadScores()
  67.   closeDB()
  68. end
  69.  
  70. on OpenDB
  71.   if TheDB <> 0 then
  72.     closeDB()
  73.   end if
  74.   TheDB = new(xtra("V12DBE"), osdir & "\Quiz.4db", "ReadOnly", "t3223ra")
  75.   TheTable = new(xtra("V12Table"), mGetRef(TheDB), "credits")
  76. end
  77.  
  78. on LoadScores
  79.   mOrderBy(TheTable, "Score", "descending")
  80.   mSelect(TheTable)
  81.   mGo(TheTable, 6)
  82.   lastscore = mGetField(TheTable, "Score")
  83. end
  84.  
  85. on closeDB
  86.   TheTable = 0
  87.   TheDB = 0
  88. end
  89.  
  90. on CheckSound
  91.   if not soundBusy(1) then
  92.     sound playFile 1, "../sound/ark.mp3"
  93.   end if
  94. end
  95.