home *** CD-ROM | disk | FTP | other *** search
- on getLastLinePos theStr,startLine,endLine,charPos,theChar
- global endLinePtr,nextChar,gErrGlobal
- put 0 into gErrGlobal
- if startLine = endLine then exit
- put integer((startLine + endLine)/2) into testLine
- if char charPos of line testLine of theStr = theChar then
- if char charPos of line (testLine + 1 ) of theStr > theChar then
- put testLine into endLinePtr
- put char charPos of line testLine+ 1 of theStr into nextChar
- exit
- else if testLine = endLine then
- put testLine into endLinePtr
- exit
- end if
- else if char charPos of line testLine +1 of theStr = theChar then
- if char charPos of line (testLine + 2 ) of theStr > theChar then
- put testLine+1 into endLinePtr
- put char charPos of line testLine+ 2 of theStr into nextChar
- exit
- else if (testLine +1) = endLine then
- put testLine+1 into endLinePtr
- exit
- end if
- end if
- put startLine && testLine && endLine
- if startLine =testLine then
- -- theChar not found
- put 1 into gErrGlobal
- exit
- end if
- if char charPos of line testLine of theStr > theChar then
- getLastLinePos theStr,startLine,testLine,charPos,theChar
- else if char charPos of line testLine of theStr <= theChar then
- getLastLinePos theStr,testLine,endLine,charPos,theChar
- end if
- end
-
- on getFirstLinePos theStr,startLine,endLine,charPos,theChar
- global offsetPtr,nextChar,gErrGlobal
- put 0 into gErrGlobal
- put integer((startLine + endLine)/2) into testLine
- if startLine = endLine then -- only one line with current string
- if char charPos of line startLine of theStr <> theChar then
- put 1 into gErrGlobal
- end if
- exit
- end if
-
- if char charPos of line testLine of theStr < theChar then
- if char charPos of line (testLine + 1) of theStr = theChar then
- -- line where sought char first occurs
- put testLine+1 into offsetPtr
- put char charPos of line testLine+ 1 of theStr into nextChar
- exit
- else if char charPos of line (testLine + 1) of theStr >theChar then
- -- char not found next line contains another char
- put 1 into gErrGlobal
- exit
- else if (testLine + 1) = endLine then -- char not found at all
- put 1 into gErrGlobal
- exit
- end if
- end if
- -- put startLine && testLine && endLine
- if startLine = testLine then
- -- theChar not found
- -- put 1 into gErrGlobal
- exit
- end if
- if char charPos of line testLine of theStr >= theChar then
- getFirstLinePos theStr,startLine,testLine,charPos,theChar
- else if char charPos of line testLine of theStr < theChar then
- getFirstLinePos theStr,testLine,endLine,charPos,theChar
- end if
- end
-
- on keyDown
- global menuText,tempText,displayLines,indexText
- global CR,endLinePtr,offsetPtr,LinePtrs
- put the number of chars of field 442 into fldLen
- if not integerP(fldLen) then put 0 into fldLen
- put 0 into dontAdd
- dontpassEvent
- put the Key into theKey
- if charToNum(theKey) = 13 then
- exit
- else if charToNum(theKey) = 8 then --delete key
- delete char the number of chars of field 442 of field 442
- put char the number of chars of field 442 of field 442 into theChar
- put fldLen - 1 into fldLen
- put value(item 1 of line fldLen + 1 of LinePtrs) into offsetPtr
- put value(item 2 of line fldLen + 1 of LinePtrs) into endLinePtr
- put item 3 of line fldLen of LinePtrs into theChar
- delete line fldLen + 1 of LinePtrs
- put 1 into dontAdd
- else if charToNum(theKey) < 32 then
- exit
- end if
- if fldLen = 0 then
- if dontAdd <> 1 then
- set offsetPtr to 0
- put capitalise(theKey) into theChar
- put theChar after field 442
- put the number of lines of indexText into endLine
- --linePtrs is used to regenerate prev list configs when chars are deleted in text entry field
- put 1 & "," & endLine & "," & theChar into linePtrs
- getFirstLinePos indexText,1,endLine,1,theChar
- if testError()= 1 then
- exit
- end if
- put endLine into endLinePtr
- getLastLinePos indexText,offsetPtr,endLinePtr,1,theChar
- if testError()= 1 then exit
- end if
- else
- if dontAdd <> 1 then
- put theKey into theChar
- put theChar after field 442
- put CR & offsetPtr & "," & endLinePtr & "," & theChar after linePtrs
- -- put offsetPtr&&endLinePtr&& theChar
- put offsetPtr into oldOffsetPtr
- put endLinePtr into oldEndLinePtr
- getFirstLinePos indexText,offsetPtr,endLinePtr,fldLen + 1,theChar
- if testError()= 1 then
- delete char the number of chars of field 442 of field 442
- exit
- end if
- -- put offsetPtr&&endLinePtr&&fldLen + 1&&theChar
- getLastLinePos indexText,oldOffsetPtr,oldEndLinePtr,fldLen + 1,theChar
- put offsetPtr&&endLinePtr&&fldLen + 1&&theChar
-
- if testError()= 1 then
- exit
- end if
- end if
- end if
-
- if offsetPtr > 0 then
- put line offsetPtr to (offsetPtr +displayLines - 1)of menuText into tempText
- put tempText into field 441
- if the locH of sprite 48 < 1000 then
- put the locV of sprite 48 into theLocV
- set the visible of sprite 48 to 0
- put theLocV + the textHeight of field 441*offsetPtr into theLocV
- set the locV of sprite 48 to theLocV
- if theLocV < the bottom of sprite 39 and theLocV >= the top of sprite 39 then
- set the visible of sprite 48 to 1
- end if
- end if
- exit
- end if
- end
-
- on testError
- global gErrGlobal
- if gErrGlobal = 1 then
- put 0 into gErrGlobal
- return 1
- else
- return 0
- end if
- end
-