You need to make *very* sure that the stack is cleared from memory. I did
the same sort of thing when evaluating Metacard, I ended up scripting a
button on the Home stack to:

    1)  open/go the stackInQuestion
    2) set the destroyStack of stack stackInQuestion to true (don't worry
does not delete but removes from memory instead)
    3) set the destroyWindow of stack stackInQuestion to true (might as
well)

You can then keep the HyperCard stack open - edit the scripts and save them
and click on the button in the Metacard Home stack to open it in Metacard to
check the changes. Closing the Metacard stack will then properly flush the
stack from memory.

NB you could do with some handlers for cleaning the HyperCard scripts. I
think this does a lot of what is needed (if you improve any of the functions
mail an update back off-list?):

function replaceWords someWord, someText, newWord, evenWithinQuotes,
startCharNum
  -- version replaceWords 9.1, 2/2/00
  
  put space & someText & space into testText
  put the number of chars of someWord into someWordLength
  repeat
    set the cursor to busy
    put offsetAfter(someWord, testText, startCharNum) into startCharNum
    put startCharNum + someWordLength - 1 into endCharNum
    put endCharNum + 1 into charNumAfterWord
    put startCharNum - 1 into charNumBeforeWord
    put wordDelim(char charNumAfterWord of testText) and wordDelim(char
charNumBeforeWord of testText) into wholeWord
    if startCharNum is 0 then
      delete char 1 of testText
      delete last char of testText
      return testText
    else if wholeWord is false then
      next repeat
    else
      if evenWithinQuotes is not true then
        get charToChunk(startCharNum, testText)
        put item 1 of it into wordNum
        put item 2 of it into itemNum
        put item 3 of it into lineNum
        put item 4 of it into charNumOfline
        put line lineNum of testText into testLine
        get char charNumOfline of testLine
        if withinQuotes(charNumOfline, testLine) is true then
          next repeat
        else
        end if
      else
      end if
      put newWord into char startCharNum to endCharNum of testText
      if newWord is empty then
        if char startCharNum of testText is in " " then
          delete char startCharNum of testText
        end if
      end if
    end if
  end repeat
end replaceWords

function charToChunk wordOrCharNum, someText
  -- version charToChunk 9.1
  if wordOrCharNum is not a number then put offset(wordOrCharNum, someText)
into wordOrCharNum
  put char 1 to wordOrCharNum of someText into container
  put the number of lines of container into lineNum
  put the number of items of line lineNum of container into itemNum
  put the number of words of item itemNum of line lineNum of container into
wordNum
  put the number of chars of line lineNum of container into charNumOfline
  return wordNum & "," & itemNum & "," & lineNum & "," & charNumOfline
end charToChunk

function offsetAfter string, someText, startChar
-- version 9.0
if startChar < 0 then put 0 into startChar
delete char 1 to startChar of someText
get offset(string,someText)
if it is 0 then return 0
else return it + startChar
end offsetAfter

function withinQuotes textOrOffset, someContainer
-- version latest, 2/2/00

put item 1 of textOrOffset into startCharNum
put item 2 of textOrOffset into endCharNum
if endCharNum is empty then put startCharNum into endCharNum
if startCharNum is a number and endCharNum is a number then
else
put offset(textOrOffset, someContainer) into startCharNum
put startCharNum + the length of textOrOffset - 1 into endCharNum
end if

if startCharNum is 0 then
return "Not Found"
else
put char 1 to (startCharNum - 1) of someContainer into textBefore
put countStrings(quote, textBefore) into quotesBefore
put the number of chars of someContainer into lastCharNum
put char (endCharNum + 1) to lastCharNum of someContainer into textAfter
put countStrings(quote, textAfter) into quotesAfter
if isOdd(quotesBefore) and quotesAfter >= 1 then
return true
else
return false
end if
end if
end withinQuotes

function wordDelim someChar
  -- version 9.0
  -- could be much better!
  put quote & space & return & "!?':;()[]{}<>,." into test
  if someChar is in test then
    return true
  else return false
end wordDelim

function replaceReservedWords
  -- version original,29/1/01
  put the script of this card into oldScript
  put oldScript into newScript
  put  
"format,commandNames,commandName,showName,max,question,container,object"
into reservedWords
  repeat with ii = 1 to the number of items of reservedWords
    put item ii of reservedWords into oldWord
    put "some" & initialCaps(oldWord) into replacement
    put replaceWords(oldWord, newScript, replacement) into newScript
  end repeat
  
  put "Title" into reservedWords
  repeat with ii = 1 to the number of items of reservedWords
    put item ii of reservedWords into oldWord
    put "opn_" & initialCaps(oldWord) into replacement
    put replaceWords(oldWord, newScript, replacement) into newScript
  end repeat
  
  return newScript
end replaceReservedWords

function initialCaps someText
  -- version 9.0
  
  repeat with wordNum = 1 to the number of words of someText
    put word wordNum of someText into someWord
    put charToNum(char 1 of someWord) into someCharNum
    if someCharNum >= 97 and someCharNum <= 122 then
      subtract 32 from someCharNum
      put numToChar(someCharNum) into char 1 of someWord
      put someWord into word wordNum of someText
    end if
  end repeat
  return someText
end initialCaps



Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to