Forgive me for i'm tired and didn't completely go through your code. I tend to try to keep all my gui elements in one function, just to make it easier to code my main loop. I'll post here what i have for mine, it has no cursor | but when a textbox is active the box border turns red, delete clears text.
dim textboxstring$(1000)
global character$
function textbox(textboxx as integer,textboxy as integer,charperline as integer,numberoflines as integer,formID as integer)
if charperline=>50 then charperline=50
if numberoflines=>20 then numberoflines=20
textboxstart:
ink rgb(1,1,1),0:box textboxx,textboxy,textboxx+(charperline*8)+5,textboxy+(numberoflines*15)+2
ink rgb(255,255,255),0:box textboxx+1,textboxy+1,textboxx+(charperline*8)+4,textboxy+(numberoflines*15)+1
remainingcharacters=len(textboxstring$(formID))
print$=left$(textboxstring$(formID),charperline)
ink rgb(1,1,1),0:text textboxx+1,textboxy+1,print$
ysupplement=1
charlinesupplement=0
for dummy =1 to 19
ysupplement=ysupplement+15
charlinesupplement=charlinesupplement+1
remainingcharacters=len(textboxstring$(formID))
if numberoflines>dummy
print$=right$(textboxstring$(formID),remainingcharacters-(charperline*charlinesupplement))
print$=left$(print$,charperline)
ink rgb(1,1,1),0:text textboxx+1,textboxy+ysupplement,print$
endif
next dummy
if mouseclick()=1 and mousex()=>textboxx and mousex()<=textboxx+(charperline*8)+4 and mousey()=>textboxy and mousey()<=textboxy+(numberoflines*15)+1
mouseclick()=0
do
ink rgb(255,0,0),0:box textboxx,textboxy,textboxx+(charperline*8)+5,textboxy+(numberoflines*15)+2
ink rgb(255,255,255),0:box textboxx+1,textboxy+1,textboxx+(charperline*8)+4,textboxy+(numberoflines*15)+1
if mouseclick()=1
if mousex()<textboxx or mousex()>textboxx+(charperline*8)+4 or mousey()<textboxy or mousey()>textboxy+(numberoflines*15)+1 then goto textboxstart
endif
remainingcharacters=len(textboxstring$(formID))
print$=left$(textboxstring$(formID),charperline)
ink rgb(1,1,1),0:text textboxx+1,textboxy+1,print$
ysupplement=1
charlinesupplement=0
for dummy =1 to 19
ysupplement=ysupplement+15
charlinesupplement=charlinesupplement+1
remainingcharacters=len(textboxstring$(formID))
if numberoflines>dummy
print$=right$(textboxstring$(formID),remainingcharacters-(charperline*charlinesupplement))
print$=left$(print$,charperline)
ink rgb(1,1,1),0:text textboxx+1,textboxy+ysupplement,print$
endif
next dummy
character$=""
if scancode()=28 or scancode()=156
clear entry buffer
goto textboxstart
endif
if scancode()=14
clicksound()
dummy=len(textboxstring$(formID))
textboxstring$(formID)=left$(textboxstring$(formID),dummy-1)
wait 100
clear entry buffer
goto skipentrybuf
endif
if scancode()=211
textboxstring$(formID)=""
clear entry buffer
goto skipentrybuf
endif
character$=entry$()
clear entry buffer
skipentrybuf:
if character$<>""
textboxstring$(formID)=textboxstring$(formID)+character$
endif
if len(textboxstring$(formID))> (numberoflines*charperline) then textboxstring$(formID)=left$(textboxstring$(formID),numberoflines*charperline)
loop
endif
endfunction
you should be able to just call that function in any loop and it'll self update, feel free to add as many as you want, up to 1000, it'll keep each and every string. here's what i mean:
textbox(100,100,40,5,1)
at x 100 and y 100, a textbox 40 characters wide by 5 lines high will appear. it multiples the 5 lines by the 40 characters wide to create a max string length of 200 characters. i did this because i didn't want to have to hide text that wouldn't appear plus i was just lazy lol.
feel free to use this or play around with it.
edit: check the download if you want its sort of a demo of what i've been tinkering around with and shows my textbox as well. I'm not the best programmer so please go easy on me lol
edit2: come to think of it instead of having it calculate a maximum string length and stopping, i could just have it not print to the box after the max length occurs and find a way to just have it scroll right after every character added to the string... i'm still too lazy for that tho.