home *** CD-ROM | disk | FTP | other *** search
/ Passport / passport.iso / pc / passport / inputbox.dxr / 00005.ls < prev    next >
Encoding:
Text File  |  1998-01-26  |  2.1 KB  |  107 lines

  1. on ReturnValue
  2.   global RetHandler
  3.   set x to Replace(the text of field "Enter", QUOTE, QUOTE & ""E&" & QUOTE)
  4.   do("tell the stage to" && RetHandler && QUOTE & x & QUOTE)
  5.   if the result then
  6.     tell the stage
  7.       doSound("0Giusto" & random(2))
  8.       ClearBlue()
  9.       set the cursor of sprite 29 to -1
  10.     end tell
  11.     close(window "InputBox")
  12.     forget(window "InputBox")
  13.     forget(window "Symbols")
  14.   else
  15.     tell the stage
  16.       doSound("0Errore" & random(2))
  17.     end tell
  18.   end if
  19. end
  20.  
  21. on startMovie
  22.   set the cursor of sprite 5 to [50, 51]
  23.   set the cursor of sprite 6 to [50, 51]
  24.   tell the stage
  25.     set the cursor of sprite 29 to [50, 51]
  26.   end tell
  27.   set the foreColor of field "Symbols" to GetColor("Black")
  28. end
  29.  
  30. on stopMovie
  31.   tell the stage
  32.     set the cursor of sprite 29 to -1
  33.   end tell
  34. end
  35.  
  36. on insert ch
  37.   set x to the selStart
  38.   if x > 0 then
  39.     put ch after char x of field "Enter"
  40.   else
  41.     put ch before field "Enter"
  42.   end if
  43.   set the selEnd to x + 1
  44.   set the selStart to x + 1
  45. end
  46.  
  47. on openWindow
  48.   symbolsoff()
  49. end
  50.  
  51. on closeWindow
  52.   set the visible of sprite 2 to 0
  53. end
  54.  
  55. on doSymbols
  56.   if the visible of sprite 9 then
  57.     symbolsoff()
  58.   else
  59.     symbolsOn()
  60.   end if
  61. end
  62.  
  63. on symbolsOn
  64.   set R to the rect of window "InputBox"
  65.   set x to getAt(R, 4) + 35
  66.   set x1 to getAt(R, 2)
  67.   set xMax to getAt(getAt(the deskTopRectList, 1), 4)
  68.   if x > xMax then
  69.     setAt(R, 2, x1 - x + xMax)
  70.     setAt(R, 4, xMax)
  71.   else
  72.     setAt(R, 4, x)
  73.   end if
  74.   set the visible of sprite 10 to 1
  75.   set the visible of sprite 9 to 1
  76.   set the rect of window "InputBox" to R
  77. end
  78.  
  79. on symbolsoff
  80.   set R to the rect of window "InputBox"
  81.   setAt(R, 4, getAt(R, 4) - 35)
  82.   set the rect of window "InputBox" to R
  83.   set the visible of sprite 9 to 0
  84.   set the visible of sprite 10 to 0
  85. end
  86.  
  87. on Replace Src, Fnd, rep
  88.   set ret to EMPTY
  89.   set n to the number of chars in Fnd - 1
  90.   repeat while 1
  91.     set x to offset(Fnd, Src)
  92.     if x = 0 then
  93.       exit repeat
  94.       next repeat
  95.     end if
  96.     if x > 1 then
  97.       put char 1 to x - 1 of Src after ret
  98.     end if
  99.     delete char 1 to x + n of Src
  100.     put rep after ret
  101.   end repeat
  102.   return ret & Src
  103. end
  104.  
  105. on AdjustSize
  106. end
  107.