Controls of Stack
Rob Cozens
rcozens at pon.net
Sat Nov 23 10:58:01 EST 2002
>How does one parse all the controls of a stack ensuring that those in a
>background only get parsed once unless they are fields with the sharedText
>set to false... etc
Hi Again Monte,
This could be too little or too late, but following is a handler used
by the HyperTalk version of OenoLog to capture all translatable
fields in a text file, identified by card & control ids. If one put
the background logic inside a repeat loop, it should work for
Revolution stacks. It only deals with fields, as OenoLog has no
menuBar, named icons, or tool tips. I'm too lazy to parse it this
AM, so here it is for what it's worth:
on mouseUp -- 4/21/01
global cancelTranslated,gimmieTime,myLanguage,okTranslated,whatFileTranslated
put the optionKey into optionState
if the icon of me > 20000 then exit mouseUp
speakup
set the hilite of me to false
allOff
put card field "Language" into saveLanguage
get myLanguage
put myFolder()&"OeNotes"&&it&":OeHelp"&&it&".txt" into fileName
delete the last char of it -- ")"
delete the first char of it -- "("
put it into card field "Language"
-- ask file whatFileTranslated with fileName
-- if it is empty then
-- put saveLanguage into card field "Language"
-- allOn
-- exit mouseUp
-- end if
-- put it into fileName
if optionState is up then
answer (field "Can't Quit Field Help") with cancelTranslated or
okTranslated
speakUp
else get okTranslated
if it is cancelTranslated then
put saveLanguage into card field "Language"
allOn
exit mouseUp
end if
open file fileName
if the result is not empty then
answer the result
ohOh
answer the result
answer (card field "Open Error Alert Help")&&fileName&"!"
speakUp
put saveLanguage into card field "Language"
allOn
exit mouseUp
end if
push card
put return&numToChar(215) into theDelimiter
put empty into backgroundList
set the cantAbort of this stack to true
lock screen
lock messages
go first
repeat
if "Image" is in the short name of this card then exit repeat
put true into doShared
put the short id of this card into cardId
get the short id of this background
if it is in backgroundList then
repeat with x = 1 to number of lines of backgroundList
if it = line x of backgroundList then put false into doShared
end repeat
end if
if doShared then put it&return after backgroundList
repeat with x = 1 to the number of background fields
set cursor to busy
put the short name of field x into fieldName
if fieldName is "Help" or "Result" is in fieldName then next repeat
if ("Help" is not in fieldName and "About" is not in fieldName
and "Title" is not in fieldName) or "Page Title" is in fieldName then
next repeat
if fieldName is in "Title,Index Title" then put line 2 of field
x into theMessage
else put field x into theMessage
if (theMessage <= " " and length(theMessage) < 2) then next repeat
put the sharedText of field x into shareMe
if doShared or not shareMe then
put the short id of field x into itemID
write
cardId&&itemID&&"BF"&&fieldName&return&theMessage&theDelimiter to
file fileName
end if
end repeat
repeat with x = 1 to the number of card fields
set cursor to busy
put the short name of card field x into fieldName
if "Help" is not in fieldName and "Title" is not in fieldName
then next repeat
put card field x into theMessage
if (theMessage <= " " and length(theMessage) < 2) or "Result"
is in fieldName then next repeat
put the short id of card field x into itemID
write
cardId&&itemID&&"CF"&&fieldName&return&theMessage&theDelimiter to
file fileName
end repeat
if cardId is 36080 then -- report format
put the short id of button "Type" into itemId
write cardId&&itemID&&"PB Type"&return&(button
"Type")&theDelimiter to file fileName
end if
go next
end repeat
close file fileName
pop card
set the cantAbort of this stack to false
put saveLanguage into card field "Language"
allOn
unlock screen
unlock messages
end mouseUp
Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode
mailing list