michael
Senior Member
member is offline


Posts: 335
|
 |
The first length limit text interface (graphics)
« Thread started on: Mar 22nd, 2016, 07:56am » |
|
This took some figuring... How does one effectively limit a text or numbered input from a user in graphics?
Well I am proud to introduce the next generation text box style interface!
1) I now have the option to get input from a user that only allows numbers or text of a certain length (with decimals if it allows)
2) (text box or editor) Or I might get one line of text at a time and also keep other lines updated, depending on active line
Keep in mind my dialog box is just a rough example and is not my final solution.. I really want to make it look professional.
Also my use of variables is not proper yet either. This uses bad programming techniques. ( I am working on that too)
My aim is for beginners..( a quick and easy solution).. BUT this is not it yet.. because I need to make it more presentable... It is complex for a beginner to understand my code and it doesn't have a proper layout... Its a mess.
I plan to eventually learn how to do the proper WINDOWS Graphics interface too..
Code:
MODE 8
COLOUR 1,100,100,100 REM Set palette color 1 to RGB triplet (my custom text background color)
GCOL 0 : REM Set graphics foreground to palette color 0 (BLACK)
GCOL 128+1 : REM Set graphics background to palette color 1
VDU 5 : REM Treat text as graphics (transparent background)
OFF
CLG
initialx%=0
PROCborder(10,305,560,620,21,225,225,225,10)
PROC_pr(22,985,7,1,"THE REPLACEMENT WINDOW",240,240,240)
PROC_pr(520,985,1,15,"X ",200,50,50)
PROC_pr(50,100,1,2,"Maximum 30 characters. Isolated text interface!!",150,150,3)
MOVE 0,0 REM move the > out of view
key$=""
textlimit=0
MESSAGE$=""
MES$=""
sl%=0
(mou)
(check)
key$ =INKEY$(1)
PROC_color("F",255,255,255)
MOVE 35,900:PRINT MESSAGE$;"_"
IF key$="" THEN GOTO (check)
IF INKEY(-113) THEN GOTO (endit) REM escape from program
sl%=LEN(MESSAGE$)
IF INKEY(-48) sl%=LEN(MESSAGE$)-1:key$=""
PROC_color("F",100,100,100)
MOVE 35,900
PRINT MESSAGE$;"_"
MES$=MID$(MESSAGE$,0,sl%)
MESSAGE$=MES$
PROC_color("F",255,255,255):MOVE 35,900:PRINT MESSAGE$;"_"
IF LEN(key$) = 1 THEN
REM IF INKEY(-48) THEN (jump)
IF LEN(MESSAGE$)<30 THEN PROC_color("F",100,100,100):MOVE 35,900:PRINT MESSAGE$;"_": MESSAGE$=MESSAGE$+key$
(jump)
ENDIF
GOTO (mou)
(endit)
PRINT "done"
END
DEF PROCborder(x%, y%, dx%, dy%, wide%, r%, g%, b%, grade%)
LOCAL midx%, midy%, I%
midx%=x%+wide%/2
midy%=y%+wide%/2
FOR I% =1 TO wide%/2
PROC_color("f",r%,g%,b%)
RECTANGLE midx%-I%,midy%-I%, dx%+2*I%, dy%+2*I%
RECTANGLE midx%+I%,midy%+I%, dx%-2*I%, dy%-2*I%
r%-=grade%
g%-=grade%
b%-=grade%
IF r%<2 THEN r%=2
IF g%<2 THEN g%=2
IF b%<2 THEN b%=2
NEXT
ENDPROC
REM X,Y,text color,boarder color,message,r,g,b
DEF PROC_pr(X,Y,C,CT,msg$,r,g,b)
initialx%=LEN(msg$)
COLOUR 0,r,g,b
GCOL 0
LET tx= X+initialx%+25
LET ty= Y
initialx%=initialx%*22
FOR fill=1 TO 58
LINE X+3,Y+20-fill,X+initialx%,Y+20-fill
NEXT fill
GCOL CT
MOVE tx,ty
PRINT msg$
GCOL C
LINE X,Y+20,X+initialx%,Y+20
LINE X,Y+20,X,Y-40
LINE X,Y-40,X+initialx%,Y-40
LINE X+initialx%,Y-40,X+initialx%,Y+20
LINE X-5,Y+25,X+initialx%+5,Y+25
LINE X-5,Y+25, X-5,Y-45
LINE X+initialx%+5,Y+25,X+initialx%+5,Y-45
LINE X-5,Y-45,X+initialx%+5,Y-45
MOVE 0,0 REM hide that thing
ENDPROC
DEF PROC_color(fb$,r,g,b)
IF fb$="f" OR fb$="F" THEN COLOUR 0,r,g,b : GCOL 0
IF fb$="b" OR fb$="B" THEN COLOUR 1,r,g,b : GCOL 128+1
ENDPROC
|