Some of my projects remain and are kept uncompiled, that is, as editable stacks. These stacks contain in some cases thousands of cards with text fields. I frequently search them using the Message Box and a simple "search textToFind" which does a fine job of locating a word and finding subsequent instances with each press of the Return key. However, when I attempt to script this action by putting directly to the Message Box, as in:
put "Find" && quote & textToFind & quote -- (that is, in the message box)
my line is placed into the Result Area of the Message Box, not the Command Area.
CAN SOMEONE EXPLAIN TO ME WHY IT IS NOT POSSIBLE TO PUT DIRECTLY INTO THE COMMAND AREA VIA SCRIPT?
Likewise, I have tried the following as a way to create an easily executed serial-search for a word:
on commandKeyDown theKey
if theKey is not "F" then exit commandKeyDown
ask "Find:"
if it is not empty then find it
if the result is "Not found" then
answer the result
exit commandKeyDown
end if
put it into mySearch
repeat forever
answer "Find next " & mySearch & "?" with "Cancel" or "Next"
if it is "Cancel" then exit commandKeyDown
else
find mySearch
if the result is "Not found" then
answer the result
exit commandKeyDown
end if
end if
end repeat
end commandKeyDown
BUT THIS FAILS TO SUCCESSFULLY FIND ANY BUT THE FIRST INSTANCE!
Any ideas are appreciated. I want an easy search function (a la HyperCard and it's simpler Message Box) in order to casually flip thru a stack for a term.
Message Box question
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Message Box question
“You do what you do out of your own private passion for the thing itself”
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)
Re: Message Box question
Hi.
I have not looked at your script, but the "find" command keeps an internal record of the "finds" it makes, and continues searching the cards of a stack based on an index created from the last successful found text. In other words, it will continue to find additional instances, card by card.
If there are other instances on the same card, it will find those before moving on.
So you might try making a stack of a handful of cards containing a bg field on it with some text that appears on several of those cards. IF you start at card 1 and execute the "find" command for that text, you will see that LC navigates to the card that has the next instance. The question becomes, then, what is different about your stack?
Craig Newman
I have not looked at your script, but the "find" command keeps an internal record of the "finds" it makes, and continues searching the cards of a stack based on an index created from the last successful found text. In other words, it will continue to find additional instances, card by card.
If there are other instances on the same card, it will find those before moving on.
So you might try making a stack of a handful of cards containing a bg field on it with some text that appears on several of those cards. IF you start at card 1 and execute the "find" command for that text, you will see that LC navigates to the card that has the next instance. The question becomes, then, what is different about your stack?
Craig Newman
Re: Message Box question
Thank you. Where, and how, does the Find command keep track of it's hits? And perhaps more important to me, HOW does one place a line of script into the Command Area of the Message Box (via script)? If I write:
put "Find" && quote & "Bozeman" & quote into message box
..it goes into the Result Area of the Message Box and will not respond as I expect to:
do message box
..and thus it is useless (for example, in Hypercard one can send a "do" command to the Message Box and any valid line in there will execute)
put "Find" && quote & "Bozeman" & quote into message box
..it goes into the Result Area of the Message Box and will not respond as I expect to:
do message box
..and thus it is useless (for example, in Hypercard one can send a "do" command to the Message Box and any valid line in there will execute)
“You do what you do out of your own private passion for the thing itself”
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)
Re: Message Box question
Hi.
You are an experienced HC user?
The "find" command works the same as in HC. The index is internally stored. The only way to find out where the most recent found text is located is under script control (or, I suppose, with the "recent" keyword)
The msg box in LC is complex, as you likely know. But you can;
put "sometext" into fld "message field" of stack "message box"
Craig
EDIT:
But do you need to worry about this? Try, in a button script:
You are an experienced HC user?
The "find" command works the same as in HC. The index is internally stored. The only way to find out where the most recent found text is located is under script control (or, I suppose, with the "recent" keyword)
The msg box in LC is complex, as you likely know. But you can;
put "sometext" into fld "message field" of stack "message box"
Craig
EDIT:
But do you need to worry about this? Try, in a button script:
Code: Select all
on mouseUp
put "answer PP"
put "answer kk" into fld "message field" of stack "message box"
do msg
end mouseUp