Frequent corruption of Revolution program?

Stephen McNutt mcnuttsp at bellsouth.net
Mon Jul 19 20:10:05 CDT 2004


On 7/19/04 7:48 PM, "Richard Gaskin" <ambassador at fourthworld.com> wrote:

> Sarah Reichelt wrote:
> 
>> On 19 Jul 2004, at 12:06 pm, Stephen Paul McNutt wrote:
>>>   My program is nonfunctional.  Reinstalling Revolution fixes the
>>> problem.  It can happen several times a day.  Does anyone know
>>> anything about this?
>> 
>> It's hard to tell without any more info, but it sounds like one of your
>> scripts might deleting one of the Rev components. I did this once
>> accidently using the delete command when setting the default folder had
>> failed (the folder didn't exist) so instead of deleting my temporary
>> files, I deleted parts of the Revolution folder instead.
>> 
>> The only corruption of the program I have heard of is when revolution
>> fails to complete it's startup, getting stuck at the splash screen where
>> it says "Loading plugins". This is fixed by replacing the "Saves" folder
>> inside the "Components" folder, but it sounds like you are getting
>> beyond this stage.
>> 
>> I would check your scripts for any "delete" commands and check very
>> carefully to make sure what you are deleting.
> 
> Good idea, Sarah.
> 
> There have been cases where unexpected behavior has occured when
> referring to stacks by number rather than by name.  While numbers refer
> to specific windows (the equivalent of Rev "stacks") in a SuperCard
> file, in Revolution it's used very differently.  I don't know if Stephen
> comes from a SuperCard background, but if so it might help explain
> what's going on.
> 
> For more information on the relationship between numeric stack
> references and the unexpected results that might superficially appear to
> be corruption, see:
> <http://lists.runrev.com/pipermail/use-revolution/2004-January/029635.html>
> 
> Of course the best diagnosis can only come from seeing the script.
> Stephen, if the problem persists could I trouble you to post the portion
> of the code that's doing the deleting?

First, thank you so much to both you, Richard, and Sarah for taking the time
to give such detailed help.  It's wonderful to have a place like this list
to find answers.

I come from a HyperCard background.  I read your explanation (following your
links) of things that can cause behavior you might mistake for corruption.
I agree that my problem probably isn't corruption.  I used that word without
knowing exactly what it meant.

Below is the script of my main stack.  I'm sure it's a mess.

Thanks again,
Stephen McNutt

global CQCustomer
global CQProductKey
global repeatRunStopper -- this is to keep the preOpenStack script from
running except once when the app first opens
global teamBeingChanged
global team1name
global team1members -- an array variable containing the names of players on
team 1
global theHatForTeam1 -- a copy of team1members from which names will be
pulled
global team2name
global team2members
global theHatForTeam2
global questionSetName
global questionSet -- an array containing the questions in the selected set
global theHatForQuestions -- a copy of questionSet from which questions will
be pulled
global questionOrder -- can have values "sequential", "randomWithRepeats",
or "randomWithoutRepeats"
global contestantOrder -- can have same values as questionOrder
global timerTime
global isAnswerCorrect
global textForSample
global questionDisplayTextSize
global questionDisplayTextFont
global theGame
global TTTgamesToWin

on PreOpenStack
  
  if repeatRunStopper is empty then
    put 1 into repeatRunStopper
    
    set the loc of me to the screenLoc

    local lFileName
    local lItemDelimeter
    local ldefaultFolder
    if the environment is "development" then --Sets the default folder to
the folder containing this stack file.
      put the fileName of me into lFileName
      put the itemDelimiter into lItemDelimiter
      set the itemDelimiter to "/"
      put "" into the last item of lFilename
      set the defaultFolder to lFileName
      set the itemDelimiter to lItemDelimiter
    end if
    if the environment is not "development" then
      if the platform is "MacOS" then --Sets the default folder to the
correct folder within a Mac OSX bundle (package).
        put defaultFolder into ldefaultFolder
        put "/CQ.app/Contents/MacOS" after lDefaultFolder
        set the defaultFolder to lDefaultFolder
      end if
    end if
    if the platform is "MacOS" then
      set the height of stack "Classroom Quizshow" to 450
    end if
    
    set the visible of stack "data/Settings Saver.edb" to false
     
    put field "team1name" of card 1 of stack "data/Settings Saver.edb" into
team1name
    put team1name into field "team1nameDisplay" of card "Setup" of stack
"Classroom Quizshow"
    put team1name into field "loadedTeam1Display" of card "Teams" of stack
"Classroom Quizshow"
    put field "team1members" of card 1 of stack "data/Settings Saver.edb"
into team1members
    put team1members into theHatForTeam1 --from which names are drawn,
leaving the complete list, team1members, intact
     
    put field "team2name" of card 1 of stack "data/Settings Saver.edb" into
team2name
    put team2name into field "team2nameDisplay" of card "Setup" of stack
"Classroom Quizshow"
    put team2name into field "loadedTeam2Display" of card "Teams" of stack
"Classroom Quizshow"
    put field "team2members" of card 1 of stack "data/Settings Saver.edb"
into team2members
    put team2members into theHatForTeam2 --from which names are drawn,
leaving the complete list, team2members, intact
     
    put field "questionSetName" of card 1 of stack "data/Settings Saver.edb"
into questionSetName
    put questionSetName into field "questionSetNameDisplay" of card "Setup"
of stack "Classroom Quizshow"
    put questionSetName into field "loadedQuestionSetDisplay" of card
"Questions" of stack "Classroom Quizshow"
    put field "questionSet" of card 1 of stack "data/Settings Saver.edb"
into questionSet
    put questionSet into theHatForQuestions --from which questions are
drawn, leaving the complete list, questionSet, intact
     
    createFontMenu
     
    put field "textForSample" of card 1 of stack "data/Settings Saver.edb"
into textForSample
    put textForSample into field "textSampleText" of card "Font" of stack
"Classroom Quizshow"
    put textForSample into field "textSample" of card "Font" of stack
"Classroom Quizshow"
    put field "questionDisplayTextSize" of card 1 of stack "data/Settings
Saver.edb" into questionDisplayTextSize
    if questionDisplayTextSize is "auto" then
      global optimizedTextSize
      put 48 into optimizedTextSize
      set the disabled of button "chooseTextSize" of card "Font" of stack
"Classroom Quizshow" to true
      set the selected of button "autoTextSize" of card "Font" of stack
"Classroom Quizshow" to true
      set the textSize of field "textSample" of card "Font" of stack
"Classroom Quizshow" to optimizedTextSize
    else
      set the textSize of field "textSample" of card "Font" of stack
"Classroom Quizshow" to questionDisplayTextSize
      set the selected of button "autoTextSize" of card "Font" of stack
"Classroom Quizshow" to false
    end if
    set the label of button "chooseTextSize" of card "Font" of stack
"Classroom Quizshow" to questionDisplayTextSize
    put questionDisplayTextSize into field "sizeDisplay" of card "Setup" of
stack "Classroom Quizshow"
    put field "questionDisplayTextFont" of card 1 of stack "data/Settings
Saver.edb" into questionDisplayTextFont
    set the label of button "chooseTextFont" of card "Font" of stack
"Classroom Quizshow" to questionDisplayTextFont
    set the textFont of field "textSample" of card "Font" of stack
"Classroom Quizshow" to questionDisplayTextFont
    put questionDisplayTextFont into field "fontDisplay" of card "Setup" of
stack "Classroom Quizshow"
    -- Setup for radio buttons on Setup card...
    put field "questionOrder" of card 1 of stack "data/Settings Saver.edb"
into questionOrder
    put field "contestantOrder" of card 1 of stack "data/Settings Saver.edb"
into contestantOrder
    switch questionOrder
    case "sequential"
      set the hilitedButtonName of group "questionOrderRadioButtons" of card
"Setup" of stack "Classroom Quizshow" to "questionOrderRadio1"
      break
    case "randomWithoutRepeats"
      set the hilitedButtonName of group "questionOrderRadioButtons" of card
"Setup" of stack "Classroom Quizshow" to "questionOrderRadio2"
      break
    case "randomWithRepeats"
      set the hilitedButtonName of group "questionOrderRadioButtons" of card
"Setup" of stack "Classroom Quizshow" to "questionOrderRadio3"
      break
    end switch
    switch contestantOrder
    case "sequential"
      set the hilitedButtonName of group "contestantOrderRadioButtons" of
card "Setup" of stack "Classroom Quizshow" to "contestantOrderRadio1"
      break
    case "randomWithoutRepeats"
      set the hilitedButtonName of group "contestantOrderRadioButtons" of
card "Setup" of stack "Classroom Quizshow" to "contestantOrderRadio2"
      break
    case "randomWithRepeats"
      set the hilitedButtonName of group "contestantOrderRadioButtons" of
card "Setup" of stack "Classroom Quizshow" to "contestantOrderRadio3"
      break
    end switch
    -- Setup for timer...
    put field "timerTime" of card 1 of stack "data/Settings Saver.edb" into
timerTime
    set the label of button "timerSetButton" of card "Setup" of stack
"Classroom Quizshow" to timerTime
    put field "TTTgamesToWin" of card 1 of stack "data/Settings Saver.edb"
into TTTgamesToWin
    set the label of button "TTTgamesToWin" of card "Game" of stack
"Classroom Quizshow" to TTTgamesToWin
    put field "theGame" of card 1 of stack "data/Settings Saver.edb" into
theGame
    put theGame into field "theGameDisplay" of card "Setup" of stack
"Classroom Quizshow"
    switch theGame
    case "Tic Tac Tournament"
      set the hilitedButtonName of group "theGameButtonGroup" of card "Game"
of stack "Classroom Quizshow" to "Tic Tac Tournament"
      break
    case "Dots"
      set the hilitedButtonName of group "theGameButtonGroup" of card "Game"
of stack "Classroom Quizshow" to "Dots"
      break
    end switch
     
    put field "CQCustomer" of card 1 of stack "data/Settings Saver.edb" into
CQCustomer
    put field "CQProductKey" of card 1 of stack "data/Settings Saver.edb"
into CQProductKey
    local inputProductKey
    repeat with n=1 to 6
      put charToNum(char n of CQCustomer) after inputProductKey
    end repeat
    multiply inputProductKey by 2
    subtract 123456789 from inputProductKey
    if inputProductKey = CQProductKey then
      set the lockText of field "cardName" of stack "data/Questions.edb" to
false
      set the lockText of field "cardContents" of stack "data/Questions.edb"
to false
      put "User" && CQCustomer & return & "Key" && CQProductKey into field
"registrationInfo" of card "Setup" of stack "Classroom Quizshow"
      global CQPurchased
      put "yes" into CQPurchased
    else
      set the lockText of field "cardName" of stack "data/Questions.edb" to
true
      set the lockText of field "cardContents" of stack "data/Questions.edb"
to true
      put "Thanks for trying the Classroom Quizshow demo!" into field
"registrationInfo" of card "Setup" of stack "Classroom Quizshow"
      open stack "Splash Screen"
      set the visible of stack "Classroom Quizshow" to false
      global CQPurchased
      put "no" into CQPurchased
    end if
    
  end if
   
end preOpenStack

on createFontMenu
  get the fontNames -- list of installed fonts
  sort lines of it
  put it into button "chooseTextFont" of card "Font" of stack "Classroom
Quizshow"
end createFontMenu

-- The function below is called like this:
thePicker(theHatForTeam1,contestantOrder) or
thePicker(theHatForQuestions,questionOrder)
function thePicker whichArray,whichOrder
  put whichArray into theHat
  switch whichOrder
  case "sequential"
    put line 1 of theHat into thePick
    delete line 1 of theHat
    break
  case "randomWithoutRepeats"
    put the random of (the number of lines in theHat) into theNumber
    put line theNumber of theHat into thePick
    delete line theNumber of theHat
    break
  case "randomWithRepeats"
    put the random of (the number of lines in theHat) into theNumber
    put line theNumber of theHat into thePick
    break
  end switch
  switch whichArray
  case theHatForTeam1
    put theHat into theHatForTeam1
    if theHat is empty then put team1members into theHatForTeam1
    break
  case theHatForTeam2
    put theHat into theHatForTeam2
    if theHat is empty then put team2members into theHatForTeam2
    break
  case theHatForQuestions
    put theHat into theHatForQuestions
    if theHat is empty then put questionSet into theHatForQuestions
    break
  end switch
  return thePick
end thePicker

on presentQuestion
  put thePicker(theHatForQuestions,questionOrder) into field
"questionDisplay"
  put "" into field "timerDisplay"
  global isAnswerCorrect
  put "" into isAnswerCorrect
  --optimize text size to fit field...
  global questionDisplayTextSize
  if questionDisplayTextSize is "auto" then
    set the visible of field "questionDisplay" to false
    set the visible of field "optimizingFontSize" to true
    global optimizedTextSize
    put "Optimized font size:" && optimizedTextSize && "Pts." into field
"optimizingFontSize"
    set the visible of group "questionDisplayGroup" to true
     
    repeat while the formattedHeight of field "questionDisplay" < the height
of field "questionDisplay"
      add 24 to optimizedTextSize
      set the textSize of field "questionDisplay" to optimizedTextSize
      put "Optimized font size:" && optimizedTextSize && "Pts." into field
"optimizingFontSize"
    end repeat
     
    repeat while the formattedHeight of field "questionDisplay" > the height
of field "questionDisplay"
      subtract 12 from optimizedTextSize
      set the textSize of field "questionDisplay" to optimizedTextSize
      put "Optimized font size:" && optimizedTextSize && "Pts." into field
"optimizingFontSize"
    end repeat
    add 12 to optimizedTextSize
    set the textSize of field "questionDisplay" to optimizedTextSize
    put "Optimized font size:" && optimizedTextSize && "Pts." into field
"optimizingFontSize"
     
    repeat while the formattedHeight of field "questionDisplay" > the height
of field "questionDisplay"
      subtract 4 from optimizedTextSize
      set the textSize of field "questionDisplay" to optimizedTextSize
      put "Optimized font size:" && optimizedTextSize && "Pts." into field
"optimizingFontSize"
    end repeat
  else
    set the visible of field "optimizingFontSize" to false
  end if
   
  set the visible of field "questionDisplay" to true --if it isn't already
  set the visible of group "questionDisplayGroup" to true --if it isn't
already
  global startingTime
  global timerTime
  put the seconds into startingTime
  put timerTime into field "timerDisplay"
  startTimer
end presentQuestion

on startTimer
  global timerTime
  global startingTime
  global timeRemaining
  global isAnswerCorrect
  global theGame
  
  if isAnswerCorrect is empty then
    put timerTime - (the seconds - startingTime) into timeRemaining
    if timeRemaining > 0 then
      put timeRemaining into field "timerDisplay" of card "game screen" of
stack theGame
      send startTimer to me in 10 ticks
    end if
    if timeRemaining <= 0 then
      put "incorrect" into isAnswerCorrect
      put timeRemaining into field "timerDisplay" of card "game screen" of
stack theGame
      set the visible of group "clickToContinueGroup" of card "game screen"
of stack theGame to true
    end if
  end if
end startTimer

on closeStack
  global team1name
  put team1name into field "team1name" of card 1 of stack "data/Settings
Saver.edb"
  global team2name
  put team2name into field "team2name" of card 1 of stack "data/Settings
Saver.edb"
  global team1members
  put team1members into field "team1members" of card 1 of stack
"data/Settings Saver.edb"
  global team2members
  put team2members into field "team2members" of card 1 of stack
"data/Settings Saver.edb"
  global contestantOrder
  put contestantOrder into field "contestantOrder" of card 1 of stack
"data/Settings Saver.edb"
  global questionSetName
  put questionSetName into field "questionSetName" of card 1 of stack
"data/Settings Saver.edb"
  global questionSet
  put questionSet into field "questionSet" of card 1 of stack "data/Settings
Saver.edb"
  global questionOrder
  put questionOrder into field "questionOrder" of card 1 of stack
"data/Settings Saver.edb"
  global timerTime
  put timerTime into field "timerTime" of card 1 of stack "data/Settings
Saver.edb"
  global TTTgamesToWin
  put TTTgamesToWin into field "TTTgamesToWin" of card 1 of stack
"data/Settings Saver.edb"
  global theGame
  put theGame into field "theGame" of card 1 of stack "data/Settings
Saver.edb"
  global textForSample
  put textForSample into field "textForSample" of card 1 of stack
"data/Settings Saver.edb"
  global questionDisplayTextFont
  put questionDisplayTextFont into field "questionDisplayTextFont" of card 1
of stack "data/Settings Saver.edb"
  global questionDisplayTextSize
  put questionDisplayTextSize into field "questionDisplayTextSize" of card 1
of stack "data/Settings Saver.edb"
  global CQCustomer
  put CQCustomer into field "CQCustomer" of card 1 of stack "data/Settings
Saver.edb"
  global CQProductKey
  put CQProductKey into field "CQProductKey" of card 1 of stack
"data/Settings Saver.edb"
  
  save stack "data/Settings Saver.edb" as "data/Settings Saver.edb"
  close stack "data/Settings Saver.edb"
  pass closeStack
  set the visible of stack "Classroom Quizshow" to true --Just in case
someone clicked Quit on the Splash Screen
end closeStack




More information about the use-livecode mailing list