|
|
Label Search code
Added on 12/10/1999
|
It creates a search engine that searches your labels for a word, then lists it. The user then types in the label they want to go to, then hit a "go to" button to be taken there.
--It creates a search engine that searches your labels for a word, then lists it. The user then types in the label they want to go to, then hit a "go to" button to be taken there. You need two fields and two buttons. "Search Field" is a fixed, editable field where the user types in the search word or phrase. "Output" is a fixed, non-editable field where the results of the search are placed. The Search button should call the searchText on mouseUp. The Go To button should call jumpLoc on mouseUp. The "on keyDown me" bit of code should be put in the "Search Field" sprite lingo.
--Copyright © 1999 Deborah White
on searchText
set searchWord = the text of field "Search Field"
set returnList = [:]
set the text of field "Output" to ""
set numList = (the number of lines of the labelList) - 1
if searchWord = "" then
alert "Please enter a word"
else
repeat with i = 1 to numList
set testWord to line i of the labelList
set theOffset = offset(searchWord, testWord)
if theOffset <> 0 then
put testWord into returnList
put returnList after member "Output"
put RETURN after member "Output"
end if
end repeat
if returnList = [:] then
alert "This word was not found."
end if
end if
end
on jumpLoc
set searchWord = the text of field "Search Field"
set numList = (the number of lines of the labelList) - 1
repeat with i = 1 to numList
set testWord to line i of the labelList
if testWord = searchWord then
set goWord = the text of field "Search Field"
go to frame goWord
set the text of field "Output" to ""
set the text of field "Search Field" to ""
end if
end repeat
if goWord <> SearchWord then
alert "The page does not exist. Check to make sure you entered the ¬
complete page title correctly"
end if
end
on keyDown me
if the key = return then
searchText
else
pass
end if
end
|
|