BBC BASIC for Windows
« (graphics text editor)improved :April 19 2016 »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:05pm



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: (graphics text editor)improved :April 19 2016  (Read 732 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
laugh (graphics text editor)improved :April 19 2016
« Thread started on: Mar 20th, 2016, 3:19pm »

NOTE: I have modified this AFTER the later posts..

*** In BBC BASIC OPTIONS :Make sure lower case keywords is off ***
*** if it is on.. restart the IDE after you turn it off **

Simplified and LOCALS added...

A note: if you look carefully you will see a need for decimals for the text box area length for fill.. The first example of the need for special variables (decimal to whole numbers)

This is the core text tool.. It has more potential as a non windows based tool.. (but now it looks like a windows text input.)
And notice I have basically made a replica of the gray color around the text area, borderline, and text background color.
Try changing its location and length.. Its useful now.

Of course I cant really post this without the color tool... As I have become attached to it
But it is simplified (just the bare bones..of what is needed to use it.

The command:
PROC_input(H,V,TEXTLIMIT)
example:
PROC_input(10,610,125)
To make it simple:
- 10,610, is the location of the input
- 125, is the text limit for input (useful for special input areas

I am thinking I may make the settings default.. Or.. Maybe I could create a group of special commands to give the global color settings for text foreground and background to eliminate some complexity.
Any ideas are appreciated.

The return string is MESSAGE$

Instructions..
1) Type a message until you can no longer type any more
2) Use your mouse and left mouse button to click on your message in different locations.
3) Press enter
4) look at the message.

Code:
      REM gbx% and gby% NEED to be whole numbers and need to be global ( they hold shared text input location )
      gbx%=0:gby%=0:split%=0:cursor%=0 :REM GLOBAL VARIABLES
      REM split% holds the divide location of the string so edits can be made. ( this is where it gets technical)
      tempstr$=""
      lx=0:ly=0:lh=0:lv=0
      REM define my line position
      li=0
      MODE 22
      COLOUR 1,225,225,225 REM Set background color to windows common color gray (my custom RGB 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:PROC_color("F",255,255,255)
      REM H,V,TEXTLIMIT (getting simpler?)
      PROC_input(10,610,50):REM **************************END OF PROGRAM ****************************
      PROC_color("f",0,0,0)
      PRINT :PRINT "":PRINT:PRINT "Your message is:";MESSAGE$
      PRINT "Program done . Waiting for you to close the window. Please do it"
      END
      REM H,V,TEXTLIMIT (simpler?)
      DEF PROC_input(bx,by,textlimit)
      LOCAL rback%,gback%,bback%
      rback%=255:gback%=255:bback%=255
      LOCAL rfore%,gfore%,bfore%,fill
      rfore%=0:gfore=0:bfore=0
      gbx%=bx:gby%=by:initialx%=0:sl%=0:key$="":MESSAGE$="":MES$=""
      initialx%=textlimit*16.2
      FOR fill=1 TO 58
        PROC_color("f",255,255,255):LINE bx+3,by+20-fill,bx+initialx%,by+20-fill
      NEXT fill
      PROC_color("f",0,0,0):LINE bx+3,by+20,bx+initialx%,by+20:LINE bx+3,by+20-fill,bx+initialx%,by+20-fill
      REPEAT
        REPEAT
          key$ =INKEY$(1)
          PROC_color("F",rfore%,gfore%,bfore%)
          MOVE bx,by:PRINT MESSAGE$;"_"
          sl%=LEN(MESSAGE$)
          remains%=sl%-cursor%
          lstring$=LEFT$(MESSAGE$,cursor%):rstring$=RIGHT$(MESSAGE$,remains%)
          PROC_moubox
        UNTIL key$ <>""
        sl%=LEN(MESSAGE$)
        IF INKEY(-48) sl%=LEN(MESSAGE$)-1:key$=""
        REPEAT UNTIL INKEY(0)=-1
        IF MESSAGE$<> MESSAGE$ OR sl%<LEN(MESSAGE$) THEN
          PROC_color("F",rback%,gback%,bback%)
          MOVE bx,by
          PRINT MESSAGE$;"_"
        ENDIF
        MES$=MID$(MESSAGE$,0,sl%)
        MESSAGE$=MES$
        PROC_color("F",rback%,gback%,bback%):MOVE bx,by:PRINT MESSAGE$;"_"
        IF LEN(key$) = 1 THEN
          IF LEN(MESSAGE$)<textlimit THEN PROC_color("F",rback%,gback%,bback%):MOVE bx,by:PRINT MESSAGE$;"_": MESSAGE$=MESSAGE$+key$
          REM (jump)
        ENDIF
      UNTIL INKEY(-74)
      ENDPROC
      DEF PROC_moubox
      REM MOUSE b-- 1-rightbttn  2-mid bttn  4-left bttn
      MOUSE x,y,b
      LOCAL templen$,tempstr$,strlen%,resposx%,lv%,rr%,gg%,bb%
      strlen%=LEN(MESSAGE$)*16
      strlen%=strlen%+gbx%
      IF y>gby%-35 AND y<gby%+20 THEN
        lv%=gbx%
        FOR checkx%=lv% TO strlen% STEP 16
          IF x>checkx%-13 AND x<checkx%+3 THEN resposx%=checkx%-gbx%
        NEXT checkx%
      ENDIF
      split%=resposx%/16
      templen$=STR$(LEN(MESSAGE$))
      tempstr$= "X : "+STR$(x)+" Y : "+STR$(y)+"   "+"String length : "+templen$+" Text Split%= "+STR$(split%)+" Char: ("+MID$(MESSAGE$,split%,1)+ ") LEFT ("+lstring$+ ")Count:"+STR$(cursor%)+" RIGHT ("+rstring$+") "
      cursor%=split%
      REPEAT
        tempstr$=tempstr$+" "
      UNTIL LEN(tempstr$)>60
      IF b=4 OR b=1 THEN PROC_pr(30,905,15,15,tempstr$,100,100,200)
      IF x<500 AND y<500 THEN
        REM PROC_color("F",100,100,100):LINE lx,ly,lh,lv
        IF b=4 THEN lx=x:ly=y
        IF b=1 THEN lh=x:lv=y
        rr%=RND(255)
        gg%=RND(255)
        bb%=RND(255)
        IF x<500 AND y<500 THEN PROC_color("F",rr%,gg%,bb%):LINE lx,ly,lh,lv
      ENDIF
      ENDPROC
      REM ***********************this is my super custom text box tool ***********************
      REM X,Y,text color,boarder color,message,r,g,b
      REM ************************************************************************
      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
      REM WORD extractor ****************************************Because I dont want to need any other library?*********************************************************
      DEF FNew(txt$,coun)
      DIM wl$(255)
      LOCAL chk$,ps%,sl%,wc%,getword$
      FOR x=0 TO 255
        wl$(x)=""
      NEXT x
      chk$="":wc%=0
      sl%=LEN(txt$):ps%=1
      REPEAT
        chk$=MID$(txt$,ps%,1):ps%=ps%+1
        IF chk$=" " THEN chk$="":getword$="yes"
        wl$(wc%)=wl$(wc%)+chk$
        IF getword$="yes" THEN wc%=wc%+1:getword$="no":chk$=""
      UNTIL ps%>sl%
      =wl$(coun)
 
« Last Edit: Apr 19th, 2016, 07:34am by michael » User IP Logged

I like making program generators and like reinventing the wheel
hinckleyj
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 14
laugh Re: (graphics text editor)improved :April 3 2016
« Reply #1 on: Apr 8th, 2016, 07:24am »

Hi Michael,

This didn't work for me (on 6.02a anyway).

I'm getting a bad FOR here:-

for fill=1 to 58
line X+3,Y+20-fill,X+initialx%,Y+20-fill
next fill

Even if I rename this, the program loads but nothing seems to work.

Its probably me, but what am I missing?

John.
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
laugh Re: (graphics text editor)improved :April 3 2016
« Reply #2 on: Apr 8th, 2016, 2:50pm »

Sorry.. I really thought you were trolling me.. Scroll down and read solutions bellow.
« Last Edit: Apr 8th, 2016, 11:42pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
hinckleyj
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 14
laugh Re: (graphics text editor)improved :April 3 2016
« Reply #3 on: Apr 8th, 2016, 6:21pm »

Hi Michael,

Still getting "Bad FOR variable"

Is this because 'fill' is a Basic statement and its expecting a variable?

BTW, I'm not laughing. You are street's ahead of me. I'm still on the nursery slopes, but still having fun with basic (after 37 years).

Thanks

John
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
laugh Re: (graphics text editor)improved :April 3 2016
« Reply #4 on: Apr 8th, 2016, 9:23pm »

( oh sorry John, I thought you were trolling me. )
I guess you cant use fill as a variable because of the auto correct.. and you cant use lower case on BBC BASIC commands..
Code:
      REM SET MODE TO 8 USING VDU
      VDU 22,8
      REM SET LINE THICKNESS TO 3
      VDU 23,23,3|
      REM OFF
      GCOL 15
      fi%=0:Y%=0:X%=0:initialx%=0
      X%=500:Y%=500
      FOR fi%=1 TO 58
        LINE X%+3,Y%+20-fi%,X%+initialx%,Y%+20-fi%
      NEXT fi%
      WAIT 0 : REM just wait, nothing to do !
 


And also try this program:
I actually made it to help me understand how the different types of variables are used.
I need to make modules as I learn, and I reference the modules as I have difficulties remembering things. (part of why I code, to help me improve my memory and function)
Code:
      A%=3.14
      PRINT "A% is a Global variable that only holds whole numbers. So A% was 3.14 but now is: ";A%
      A%=-1000
      PRINT "A% also will hold a negative number ";A%
      A%=+100000
      PRINT "A% also will hold a postitive number ";A%
      PRINT "***************************************************************"
      a=3.14
      a#=3.14
      PRINT "a  will hold a decimal number ";a
      PRINT "a# will also hold a decimal number ";a#
      a#=-500
      PRINT "If a# is given -500 then you will see ";a#
      PRINT "***************************************************************"
      a%=-200000
      b%=+200000
      PRINT "a% will hold a negative number ";a%
      PRINT "b% will hold a positive number ";b%
      a%=3.14
      PRINT "If a% is assigned 3.14 you will see ";a%
      PRINT "***************************************************************"
      a&= 256
      PRINT "if a& is assigned a value of 256 then a&= ";a&;" Your limit is 255, so 256 wont work"
      PRINT
      PRINT "So the undisputed champion is : a or a#.. BUT they are not global variables."
 








« Last Edit: Apr 9th, 2016, 12:11am by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
laugh Re: (graphics text editor)improved :April 3 2016
« Reply #5 on: Apr 8th, 2016, 11:22pm »

Quote:
In BBC "fill" can be used as a variable because it is lower case.. (just to straighten that out)


This statement is only half true. It works if you don't use the lower case keywords option, but as John was using lower case that totally messed him up. But you can't change to upper case now because the "fill" will change to "FILL" and still not work.

John, make sure that the code coloring is on and you will see that keywords are highlighted to the color of your choice. You will see that fill is colored as a keyword.

If you are a beginner it is good to get familiar with the Cross Reference Utility that is on the Utilities menu of the IDE. If you run that you will get warnings, and one of those is about variable names that are not safe to use when case lower case keywords are switched on by the user. It is recommended that it is left in Upper case setting as many, many programmers don't stick to those variable naming rules and you might just end up with a program that won't work with lower case set. The clash comes because the convention is that LOCAL variables are all lower case so you have to step carefully not to have the odd "for" or "fn" or "on" or "or" and so on as the start of your variable names or the program may fail for other users who choose lower case keywords.
If you run the Cross Reference on Michael's programs you will get lots of warnings about variable names as he is not quite in sync with BB4W conventions yet.

User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
laugh Re: (graphics text editor)improved :April 3 2016
« Reply #6 on: Apr 9th, 2016, 12:56am »

Sorry
John, I am here for you.
If you want to team up to learn and make code I will help you the best I can.
If you check in later, Ill make some templates to help you do your code work easier and I will have explanations on how those templates work.

I am looking for those who want to make a community. I do care about how my code is structured, but I will only help improve your strategy and we can work together to become better.
I do look at programming as my MMO.. Sorry if that sounds weird..
User IP Logged

I like making program generators and like reinventing the wheel
hinckleyj
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 14
laugh Re: (graphics text editor)improved :April 3 2016
« Reply #7 on: Apr 9th, 2016, 06:31am »

Hi Zaphod,

Yes, it was the lowercase setting in options which was messing things up!

I did consider this setting before setting it and decided on using lowercase out of laziness more than anything as I didn’t want to be holding shift (or setting CAPS lock on) for each Basic Statement or Command.

However, I can now see that it is more common to enter these in uppercase so I will make the switch before it messes any more code up.

Thank you for putting me right here.

Appreciate the help.

John
User IP Logged

hinckleyj
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 14
laugh Re: (graphics text editor)improved :April 3 2016
« Reply #8 on: Apr 9th, 2016, 06:36am »

Hi Michael,

Trolling you.....no. I look up to you guys smiley

It seems it was the "Lowercase Keywords" setting in my options which totally messed up everything. I've changed this back now and tried your original code, and it all works like a charm. Sorry for the duff steer here. My fault!

I really appreciate your help and learn more from code like this than any book could do.

Thanks

John
User IP Logged

hinckleyj
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 14
xx Re: (graphics text editor)improved :April 3 2016
« Reply #9 on: Apr 9th, 2016, 06:40am »

on Apr 9th, 2016, 12:56am, michael wrote:
Sorry
John, I am here for you.
If you want to team up to learn and make code I will help you the best I can.
If you check in later, Ill make some templates to help you do your code work easier and I will have explanations on how those templates work.

I am looking for those who want to make a community. I do care about how my code is structured, but I will only help improve your strategy and we can work together to become better.
I do look at programming as my MMO.. Sorry if that sounds weird..



Thanks Michael, I really appreciate the offer here.

I'm all for teamwork and using the forum to improve my coding skills.

Some forums (not this one wink) have some members who just poke fun and complain. I'm not one of those. I just want to learn, and help others where I can.

Thank you for your support

John
User IP Logged

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