When I select a line on a field with a list, I can hilite the line. But if I go to another card, then return to the original card, the field is no longer hilited. What am I doing wrong? I would be grateful for any advice.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Code: Select all
-- script local variables are declared outside of any handler in
-- the script. They persist between calls and can be accessed by
-- any handler in the script. They are not stored when closing the stack
local tLastHilite
on closeCard
put "" into tTest
put "" into tLastHilite
repeat with i = 1 to the number of fields
put the hilitedLines of field i into tTest
-- if tTest is not empty then put it into an array
-- the array is created by using array notation
-- like put something into myArray[anIndex]
if tTest <> "" then put tTest into tLastHilite[i]
put "" into tTest
end repeat
end closeCard
on openCard
-- if tLastHilite is not an array then it was not
-- filled on closecard so passing opencard
-- ends the opencard handler here, same as exit opencard
-- except other handlers further in the message hierarchy
-- can still handle a opencard message. If you say 'exit opencard'
-- the message is not passed
if not tLastHilite is an array then pass opencard
-- we get the keys = indexes of the array. In this case the index
-- is the field number so we can address that field by the number
put the keys of tLastHilite into tmyKeys
repeat for each line aKey in tmyKeys --aLine contains the text of one line of the keys
-- the array stores the hilitedLines (can be more than one) as a comma separated list
-- and we select this comma separated list of field
set the hilitedLines of field aKey to tLastHilite[aKey]
end repeat
-- the array is cleared by putting empty into it
-- and is no longer an arry, just a ordinary local variable
put "" into tLastHilite
end openCard
Code: Select all
set the _tHilitedLines of this card to tHilitedLines
Code: Select all
put the _thilitedLines of this card into tHilitedLines