home *** CD-ROM | disk | FTP | other *** search
/ PC Home 49 / PC_Home_Issue_49.iso / winprogs / childenc / oecdemo / shared.dir / 00391.ls < prev    next >
Encoding:
Text File  |  1996-07-24  |  2.8 KB  |  92 lines

  1. on keyDown
  2.   global menuText, tempText, displayLines, indexText, CR, endLinePtr, offsetPtr, LinePtrs
  3.   set fldLen to the number of chars in field 442
  4.   if not integerp(fldLen) then
  5.     set fldLen to 0
  6.   end if
  7.   set dontAdd to 0
  8.   dontPassEvent()
  9.   set theKey to the key
  10.   if charToNum(theKey) = 13 then
  11.     exit
  12.   else
  13.     if charToNum(theKey) = 8 then
  14.       delete char the number of chars in field 442 of field 442
  15.       set theChar to char the number of chars in field 442 of field 442
  16.       set fldLen to fldLen - 1
  17.       set offsetPtr to value(item 1 of line fldLen + 1 of LinePtrs)
  18.       set endLinePtr to value(item 2 of line fldLen + 1 of LinePtrs)
  19.       set theChar to item 3 of line fldLen of LinePtrs
  20.       delete line fldLen + 1 of LinePtrs
  21.       set dontAdd to 1
  22.     else
  23.       if charToNum(theKey) < 32 then
  24.         exit
  25.       end if
  26.     end if
  27.   end if
  28.   if fldLen = 0 then
  29.     if dontAdd <> 1 then
  30.       set offsetPtr to 0
  31.       set theChar to capitalise(theKey)
  32.       put theChar after field 442
  33.       set endLine to the number of lines in indexText
  34.       set LinePtrs to 1 & "," & endLine & "," & theChar
  35.       getFirstLinePos(indexText, 1, endLine, 1, theChar)
  36.       if testError() = 1 then
  37.         exit
  38.       end if
  39.       set endLinePtr to endLine
  40.       getLastLinePos(indexText, 1, endLinePtr, 1, theChar)
  41.       if testError() = 1 then
  42.         exit
  43.       end if
  44.     end if
  45.   else
  46.     if dontAdd <> 1 then
  47.       set theChar to theKey
  48.       put theChar after field 442
  49.       put CR & offsetPtr & "," & endLinePtr & "," & theChar after LinePtrs
  50.       set oldOffsetPtr to offsetPtr
  51.       set oldEndLinePtr to endLinePtr
  52.       getFirstLinePos(indexText, offsetPtr, endLinePtr, fldLen + 1, theChar)
  53.       if testError() = 1 then
  54.         delete char the number of chars in field 442 of field 442
  55.         exit
  56.       end if
  57.       getLastLinePos(indexText, oldOffsetPtr, oldEndLinePtr, fldLen + 1, theChar)
  58.       if testError() = 1 then
  59.         exit
  60.       end if
  61.     end if
  62.   end if
  63.   if offsetPtr > 0 then
  64.     set the castNum of sprite 47 to 604
  65.     updateStage()
  66.     set tempText to line offsetPtr to offsetPtr + displayLines - 1 of menuText
  67.     put tempText into field 441
  68.     set totLines to the number of lines in menuText
  69.     if the locH of sprite 48 < 1000 then
  70.       set theLocV to the locV of sprite 48
  71.       set the visible of sprite 48 to 0
  72.       set theLocV to theLocV + (the textHeight of field 441 * offsetPtr)
  73.       set the locV of sprite 48 to theLocV
  74.       if (theLocV < the bottom of sprite 39) and (theLocV >= the top of sprite 39) then
  75.         set the visible of sprite 48 to 1
  76.       end if
  77.     end if
  78.     setScroll(47, offsetPtr, totLines, 441)
  79.     set the castNum of sprite 47 to 449
  80.   end if
  81. end
  82.  
  83. on testError
  84.   global gErrGlobal
  85.   if gErrGlobal = 1 then
  86.     set gErrGlobal to 0
  87.     return 1
  88.   else
  89.     return 0
  90.   end if
  91. end
  92.