BBC BASIC for Windows
« The resizable text input tool »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:06pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: The resizable text input tool  (Read 312 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
thumbup The resizable text input tool
« Thread started on: Mar 22nd, 2016, 11:38am »

This tool now has the following traits:

1) you can place a text input anywhere on the screen

2) you can control the size of the text input

3) Backspace will work as it does in a normal editor

4) Your input is stored in MESSAGE$ (so you can use it or use ASC(MESSAGE$) to extract numbers

5) ENTER finishes your entry and goes back to main program and tells you that you are out of the procedure

There is a foreground/background color tool and a super customizable text display tool with box.. Instructions included.

Problem :Escape should exit the procedure but I don't want it to do what it is doing.. Hmmmm

Anyways... I hope it will be useful
This is the light gray background with white text look:
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
      REM PROC_pr(HORIZONTAL,VERTICAL,TEXTCOLOR 0-15,BORDERCOLOR 1-15,"MESSAGE",r,g,b)   *r,g,b is custom RGB color
      PROC_pr(30,900,15,15,"I have set the text length to 30. Press ENTER when done",200,100,100)

      REM EXAMPLE PROC_input(horizontal,verticle,customtextlength)  You can specify how long your message can be
      PROC_input(40,500,30)

      REM **************************END OF PROGRAM ****************************
      WAIT 0
      PRINT
      PRINT "done input procedure"
      PRINT
      PRINT "Your message is:";MESSAGE$
      PROC_pr(30,50,15,15, "Program done . Waiting for you to close the window. Please do it",100,100,200)
      END
      REM *******************THIS IS THE TEXT INPUT CONTROL (needs work) ****************************

      DEF PROC_input(bx,by,textlimit)
      initialx%=0
      sl%=0
      key$=""
      MESSAGE$=""
      MES$=""
      (mou)
      (check)
      IF INKEY(-113) REPEAT UNTIL INKEY(0)=-1:GOTO (endit) REM escape from program
      key$ =INKEY$(1)
      PROC_color("F",255,255,255)
      MOVE bx,by:PRINT MESSAGE$;"_"
      IF key$="" THEN GOTO (check)
      sl%=LEN(MESSAGE$)
      IF INKEY(-48) sl%=LEN(MESSAGE$)-1:key$=""
      IF INKEY(-74) GOTO (endit)
      PROC_color("F",100,100,100)
      MOVE bx,by
      PRINT MESSAGE$;"_"
      MES$=MID$(MESSAGE$,0,sl%)
      MESSAGE$=MES$
      PROC_color("F",255,255,255):MOVE bx,by:PRINT MESSAGE$;"_"
      IF LEN(key$) = 1 THEN
        REM IF INKEY(-48) THEN (jump)
        IF LEN(MESSAGE$)<textlimit THEN PROC_color("F",100,100,100):MOVE bx,by:PRINT MESSAGE$;"_": MESSAGE$=MESSAGE$+key$
        (jump)
      ENDIF
      GOTO (mou)
      (endit)
      ENDPROC
      REM ***********************this is my super custom text box tool ***********************
      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:reduction%=0
      reduction%=initialx%/2
      reduction%=reduction%*6
      IF initialx%<20 THEN reduction%=reduction%/2
      initialx%=initialx%*22-reduction%
      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
      REM ******************this is a custom Foreground and Background control tool (too much?) *****************
      REM color "F"or"B", r,g,b
      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
 

And this is the more realistic text interface look : White background and black text.
Code:
   
   MODE 20
      COLOUR 1,240,240,240 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 (white)
      VDU 5 : REM Treat text as graphics (transparent background)
      OFF
      CLG
      REM PROC_pr(HORIZONTAL,VERTICAL,BORDERCOLOR 0-15,TEXTCOLOR 1-15,"MESSAGE",r,g,b)   *r,g,b is custom RGB color
      PROC_pr(30,900,4,3,"I have set the text length to 75. Press ENTER when done",200,100,100)

      REM EXAMPLE PROC_input(horizontal,verticle,customtextlength)  You can specify how long your message can be
      PROC_input(40,500,75)

      REM **************************END OF PROGRAM ****************************
      WAIT 0
      PRINT
      PRINT "done input procedure"
      PRINT
      PRINT "Your message is:";MESSAGE$
      PROC_pr(30,50,2,6, "Program done . Waiting for you to close the window.",100,100,200)
      END
      REM *******************THIS IS THE TEXT INPUT CONTROL (needs work) ****************************

      DEF PROC_input(bx,by,textlimit)
      initialx%=0
      sl%=0
      key$=""
      MESSAGE$=""
      MES$=""
      (mou)
      (check)
      IF INKEY(-113) REPEAT UNTIL INKEY(0)=-1:GOTO (endit) REM escape from program
      key$ =INKEY$(1)
      PROC_color("F",0,0,0)
      MOVE bx,by:PRINT MESSAGE$;"_"
      IF key$="" THEN GOTO (check)
      sl%=LEN(MESSAGE$)
      IF INKEY(-48) sl%=LEN(MESSAGE$)-1:key$=""
      IF INKEY(-74) GOTO (endit)
      PROC_color("F",240,240,240)
      MOVE bx,by
      PRINT MESSAGE$;"_"
      MES$=MID$(MESSAGE$,0,sl%)
      MESSAGE$=MES$
      PROC_color("F",0,0,0):MOVE bx,by:PRINT MESSAGE$;"_"
      IF LEN(key$) = 1 THEN
        REM IF INKEY(-48) THEN (jump)
        IF LEN(MESSAGE$)<textlimit THEN PROC_color("F",240,240,240):MOVE bx,by:PRINT MESSAGE$;"_": MESSAGE$=MESSAGE$+key$
        (jump)
      ENDIF
      GOTO (mou)
      (endit)
      ENDPROC
      REM ***********************this is my super custom text box tool ***********************
      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:reduction%=0
      reduction%=initialx%/2
      reduction%=reduction%*6
      IF initialx%<20 THEN reduction%=reduction%/2
      initialx%=initialx%*22-reduction%
      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
      REM ******************this is a custom Foreground and Background control tool (too much?) *****************
      REM color "F"or"B", r,g,b
      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
 
« Last Edit: Mar 23rd, 2016, 03:05am by michael » User IP Logged

I like making program generators and like reinventing the wheel
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls