Wow, you shout in code too?
Here's a slightly shorter version of the same thing
set cursor 0,100
print BoxInput("Hello", 40, 0, 0, rgb(255,0,0))
wait key
end
function BoxInput(UserText as string, Size as integer, X as integer, Y as integer, BG as dword)
local Key as string
local LastKey as string
local CursorPos as integer
local CursorWidth as integer
local TextWidth as integer
local TextHeight as integer
local CursorTick as integer
local Tick as integer
CursorPos=len(UserText)
CursorWidth=text width(" ")
TextWidth=CursorWidth*Size
TextHeight=text height(" ")
CursorTick=timer()+500
repeat
repeat
box X, Y, X+TextWidth, Y+TextHeight, BG, BG, BG, BG
text X,Y,UserText
if timer() > CursorTick
inc CursorTick,500
Tick=1-Tick
endif
if Tick
if CursorPos < Size then line X+(CursorWidth*CursorPos), Y+TextHeight-1, X+(CursorWidth*(CursorPos+1)),Y+TextHeight-1
endif
sync
Key=GetKey$()
if Key = LastKey
Key=""
else
LastKey=Key
endif
until Key <> ""
if len(Key) > 1 or asc(Key) < 32 or asc(Key) > 126
if Key="delete" and CursorPos < len(UserText)
UserText=left$(UserText, CursorPos) + right$(UserText, len(UserText)-CursorPos-1)
endif
if Key="bs" and CursorPos > 0
UserText=left$(UserText, CursorPos-1) + right$(UserText, len(UserText)-CursorPos)
dec CursorPos
endif
if Key="left" and CursorPos > 0 then dec CursorPos
if Key="right" and CursorPos < len(UserText) then inc CursorPos
if Key="home" then CursorPos=0
if Key="end" then CursorPos=len(UserText)
else
if len(UserText) < Size
UserText=left$(UserText, CursorPos) + key + right$(UserText, len(UserText)-CursorPos)
inc CursorPos
endif
endif
until Key="enter"
endfunction UserText
function GetKey$()
local Key as string
Key=inkey$()
if Key=""
Code=scancode()
if Code > 0
select Code
case 200 : Key="up" : endcase
case 203 : Key="left" : endcase
case 208 : Key="down" : endcase
case 205 : Key="right" : endcase
case 199 : Key="home" : endcase
case 207 : Key="end" : endcase
case 211 : Key="delete" : endcase
endselect
endif
else
select asc(Key)
case 8 : Key="bs" : endcase
case 9 : Key="tab" : endcase
case 13 : Key="enter" : endcase
endselect
endif
endfunction Key
I've cut it down from a working but prettier example - you really don't need all the graphical stuff I've wrapped around it or the many functions they need. Oh, and I've added the blinking cursor too - just for you