BBC BASIC for Windows
« RETROLIB 10 + REFERENCE MOD March 2018 »

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



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 2 3  Notify Send Topic Print
 veryhotthread  Author  Topic: RETROLIB 10 + REFERENCE MOD March 2018  (Read 2416 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
lamp Re: RETROLIB 6- here is your Christmas tree
« Reply #15 on: Dec 24th, 2016, 02:57am »

LOL.. ill make the next modification.. I'm just multitasking
It doesn't seem to have a problem.. I will test it.

HMMM.. now m$="" when the loop returns to top..
Now try it


OH and I just barely saved it again in case I forgot to save it

Try it now.. It should be flawless.
« Last Edit: Dec 24th, 2016, 03:13am by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
lamp Re: RETROLIB 6- here is your Christmas tree
« Reply #16 on: Dec 24th, 2016, 03:47am »

No, it only works for a one button press and exits as you are doing. Clearing m$ does nothing new. m$ gets given the data from the PRIVATE variable as soon as any button is pressed and stays that way.

Try to generate a loop where you can repeatedly select one of two buttons as in my example. It may take a while.....

Anyway I think I have contributed all I can on this project. There is so much code that needs cleaning up before you go any further. And please delete that extra ENDIF that screws up the indent formatting. Where? Use the Cross reference utility, that will tell you about that and so much more.
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
lamp Re: RETROLIB 6- here is your Christmas tree
« Reply #17 on: Dec 24th, 2016, 03:58am »

Yeah.. I fixed the ENDIF issue..

I also went through the unused variables and cleaned them up except for 2 because they were needed..

As for the lowercase keyword issues.. I know about that..
It is designed for Uppercase keywords..

I like the keywords the way they are.

I will look to see if there is any possible issues with the button use.. It has worked well for me on my other project. But perhaps I haven't provided a real test worthy of buttonz..

Ill try a few tests.
« Last Edit: Dec 24th, 2016, 05:52am by michael » User IP Logged

I like making program generators and like reinventing the wheel
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
lamp Re: RETROLIB 6- here is your Christmas tree
« Reply #18 on: Dec 24th, 2016, 06:14am »

Here is a Buttonz example. This is the original test.
It functions well and is in a constant loop. So a person can switch back and forth between responses.. And this is the old version (RETROLIB 2). (with lots of code removed to make it fit )
Code:
      PROCgraphics(1000,600)
      ON ERROR END
      REPEAT
        a$= FNbuttonz(300,300,"Limitless buttons and no need for complexity !!")
        a$= FNbuttonz(100,100,"This is a button TEST")
        IF a$<>"" THEN PROCpr(200,200,"you clicked on "+a$+"","255,255,255")
        WAIT 10
      UNTIL FALSE
      END
      REM RETROLIB 2
      DEF PROC_button(H,V,BEGIN,SIZE,X,C,A,DI)
      PROCcolor("f","000,000,000")
      LOCAL R,G,B,P
      R=X
      G=C
      B=A
      P=SIZE-BEGIN
      P=P/2
      P=BEGIN+P
      FOR Y=P TO SIZE
        COLOUR 1,X,C,A :GCOL 1
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X-DI
        C=C-DI
        A=A-DI
        IF X<2 THEN X=2
        IF C<2 THEN C=2
        IF A<2 THEN A=2
      NEXT Y
      P=SIZE-BEGIN
      P=P/2
      P=BEGIN+P
      FOR Y=BEGIN TO P
        COLOUR 1,X,C,A :GCOL 1
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X+DI
        C=C+DI
        A=A+DI
      NEXT Y
      COLOUR 1,R,G,B:GCOL 1
      FILL H,V
      PROCresetrgb
      ENDPROC
      DEF PROC_block(H,V,SIZE,X,C,A,DI)
      LOCAL P,Y
      P=SIZE/2
      FOR Y=1 TO SIZE
        COLOUR 0,X,C,A:GCOL 0
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X-DI
        C=C-DI
        IF X<2 THEN X=2
        IF C<2 THEN C=2
        IF A<2 THEN A=2
        P=P-1
      NEXT Y
      ENDPROC
      DEFPROCdotsize(n)
      VDU 23,23,n|
      ENDPROC
      REM COLORMIX object mixer
      DEFFNcolormix(x,y)
      PRIVATE rgb$,r%,g%,b%,switch%
      LOCAL h%,v%,click%
      MOUSE h%,v%,click%
      IF click%=4 THEN
        IF h%>x AND h%<x+50 AND v%>y AND v%<y+255 THEN r%=v%-y
        IF h%>x+49 AND h%<x+90 AND v%>y AND v%<y+255 THEN g%=v%-y
        IF h%>x+99 AND h%<x+140 AND v%>y AND v%<y+255 THEN b%=v%-y
      ENDIF
      IF switch%=0 OR click%=4 THEN
        PROCsbox(x-5,y-5,x+150,y+265,"255,255,255")
        PROCsbox(x,y+r%,x+40,y+r%+10,"200,000,000")
        PROCsbox(x+50,y+g%,x+90,y+g%+10,"000,200,000")
        PROCsbox(x+100,y+b%,x+140,y+b%+10,"000,000,200")
        switch%=1
        rgb$=FNnumstr(r%)+","+FNnumstr(g%)+","+FNnumstr(b%)
        PROCsbox(x-5,y+265,x+150,y+295,rgb$)
      ENDIF
      =rgb$
      REM  GRAPHICS(x,y)
      DEF PROCgraphics(x,y)
      VDU 23,22,x;y;8,15,16,1
      OFF
      VDU 5
      REM these variables are temporary
      N%=0
      N%=20
      DIM X(20),Y(20),H(20),V(20)
      ENDPROC
      DEFFNkey
      response$=INKEY$(0)
      =response$
      REM SBOX **********************
      DEF PROCsbox(x%,y%,w%,h%,c$)
      LOCAL ry%,sx%,sy%
      sx%=x%:sy%=y%
      IF x%>w% THEN x%=w%:w%=sx%
      IF y%>h% THEN y%=h%:h%=sy%
      ry%=y%
      PROCcolor("f",c$)
      REPEAT
        LINE x%,y%,w%,y%
        y%=y%+1
      UNTIL y%=h%
      y%=ry%
      IF c$<>"0" THEN PROCcolor("f","000,000,000") ELSE PROCcolor("f","white")
      LINE x%+2,y%+2,w%-2,y%+2
      LINE w%-2,y%+2,w%-2,h%-4
      LINE w%-2,h%-4,x%+2,h%-4
      LINE x%+2,h%-4,x%+2,y%+2
      PROCresetrgb
      ENDPROC
      REM RECT **********************
      DEFPROCrect(x%,y%,w%,h%)
      LOCAL sx%,sy%
      sx%=x%:sy%=y%
      IF x%>w% THEN x%=w%:w%=sx%
      IF y%>h% THEN y%=h%:h%=sy%
      LINE x%,y%,w%,y%
      LINE w%,y%,w%,h%
      LINE w%,h%,x%,h%
      LINE x%,h%,x%,y%
      ENDPROC
      REM pixel *******************
      DEFPROCpixel(x%,y%,c$)
      IF c$<>"" THEN PROCcolor("f",c$)
      MOVE x%,y%:DRAW x%,y%
      ENDPROC
      REM SET  c$ can be colors like blue or 1 or a R,G,B color
      DEF PROCset(x%,y%,c$)
      LOCAL h%
      PROCcolor("f",c$)
      FOR h%=0 TO 20
        LINE x%+h%,y%,x%+h%,y%+20
      NEXT
      MOVE 0,0
      ENDPROC
      REM restore default color palettes
      DEFPROCresetrgb
      COLOUR 0,0,0,0 :COLOUR 1,200,0,0 :COLOUR 2,000,200,000
      COLOUR 3,200,200,000:COLOUR 4,000,000,200:COLOUR 5,200,000,200
      COLOUR 6,000,200,200:COLOUR 7,200,200,200:COLOUR 8,056,056,056
      COLOUR 9,248,056,056:COLOUR 10,056,248,056:COLOUR 11,248,248,056
      COLOUR 12,056,056,248:COLOUR 13,248,056,248:COLOUR 14,056,248,248
      COLOUR 15,248,248,248
      ENDPROC
      DEF PROCcolor(fb$,rgb$)
      PRIVATE assemble$,br%,bg%,bb%
      IF rgb$="0" OR rgb$="black" THEN rgb$="000,000,000"
      IF rgb$="1" OR rgb$="red" THEN rgb$="200,000,000"
      IF rgb$="2" OR rgb$="green" THEN rgb$="000,200,000"
      IF rgb$="3" OR rgb$="yellow" THEN rgb$="200,200,000"
      IF rgb$="4" OR rgb$="blue" THEN rgb$="000,000,200"
      IF rgb$="5" OR rgb$="magenta" THEN rgb$="200,000,200"
      IF rgb$="6" OR rgb$="cyan" THEN rgb$="000,200,200"
      IF rgb$="7" OR rgb$="white" THEN rgb$="200,200,200"
      IF rgb$="8" OR rgb$="grey" THEN rgb$="056,056,056"
      IF rgb$="9" OR rgb$="light red" THEN rgb$="248,056,056"
      IF rgb$="10" OR rgb$="light green" THEN rgb$="056,248,056"
      IF rgb$="11" OR rgb$="light yellow" THEN rgb$="248,248,056"
      IF rgb$="12" OR rgb$="light blue" THEN rgb$="056,056,248"
      IF rgb$="13" OR rgb$="light magenta" THEN rgb$="248,056,248"
      IF rgb$="14" OR rgb$="light cyan" THEN rgb$="056,248,248"
      IF rgb$="15" OR rgb$="light white" THEN rgb$="248,248,248"
      assemble$=rgb$
      br%=VAL(MID$(assemble$,1,3)):bg%=VAL(MID$(assemble$,5,3)):bb%=VAL(MID$(assemble$,9,3))
      IF fb$="f" OR fb$="F" THEN COLOUR 0,br%,bg%,bb% : GCOL 0
      IF fb$="b" OR fb$="B" THEN COLOUR 1,br%,bg%,bb% : GCOL 128+1
      ENDPROC
      DEFFNnumstr(num)
      LOCAL cov$,l%
      cov$=STR$(num)
      l%=LEN(cov$)
      IF l%=1 THEN ret$="00"+cov$
      IF l%=2 THEN ret$="0"+cov$
      IF l%=3 THEN ret$=cov$
      =ret$
      DEFPROCpaint(x%,y%,co$)
      PROCcolor("b",FNrgb(x%,y%)):PROCcolor("f",co$)
      FILL x%,y%
      ENDPROC
      REM dotrgb ********************************
      DEFPROCdotrgb(x%,y%,r%,g%,b%)
      COLOUR 0,r%,g%,b% : GCOL 0
      MOVE x%,y%:DRAW x%,y%
      ENDPROC
      REM *****SPECIAL RGB tools (color extraction) has use with PROCdotrgb
      DEF PROCrgbret(x%,y%,RETURN r%,RETURN g%,RETURN b%)
      LOCAL rgb%
      rgb%=TINT(x%,y%)
      b%=INT(rgb%/(256*256))
      g%=INT((rgb%-b% *256*256)/256)
      r%=INT(rgb%-b%*256*256-g%*256)
      ENDPROC
      REM experimental
      DEFFNrgb(x%,y%)
      LOCAL r$,g$,b$,join$,r,g,b
      rgb%=TINT(x%,y%)
      b=INT(rgb%/(256*256))
      g=INT((rgb%-b *256*256)/256)
      r=INT(rgb%-b*256*256-g*256)
      r$=FNnumstr(r):g$=FNnumstr(g):b$=FNnumstr(b)
      join$=r$+","+g$+","+b$
      =join$
      REM  "INTERFACE" -library - for graphics text input and other tools
      REM X,Y,message,r,g,b
      DEF PROCpr(X,Y,msg$,c$)
      PRIVATE trackx,tracky,trackmsg$,trackc$
      LOCAL initialx%,fi%,reduction%,tx,ty
      IF trackx=X AND tracky=Y AND trackmsg$<>msg$ THEN PROCprsub(trackx,tracky,trackmsg$,"000,000,000")
      IF trackx<>X OR tracky<>Y OR trackmsg$<>msg$ OR trackc$<>c$ THEN
        initialx%=LEN(msg$)
        PROCcolor("f",c$)
        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 fi%=12 TO 48
          LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
        NEXT
        COLOUR 0,0,0,0
        GCOL 0
        MOVE tx,ty
        PRINT msg$
        MOVE 0,0
      ENDIF
      trackx=X:tracky=Y:trackmsg$=msg$:trackc$=c$
      ENDPROC
      DEFPROCprsub(X,Y,msg$,c$)
      LOCAL initialx%,fi%,reduction%,tx,ty
      initialx%=LEN(msg$)
      PROCcolor("f",c$)
      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 fi%=12 TO 48
        LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
      NEXT
      COLOUR 0,0,0,0
      GCOL 0
      MOVE tx,ty
      PRINT msg$
      MOVE 0,0
      ENDIF
      ENDPROC
      DEFFNbuttonz(X,Y,msg$)
      LOCAL initialx%,fi%,reduction%,tx,ty,mx%,my%,mb%,ad%,ady%,c$
      PRIVATE st$
      initialx%=LEN(msg$)
      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%
      MOUSE mx%,my%,mb%
      ad%=initialx%+8:ad%+=X:ady%=Y-28
      IF mx% >X AND mx%<ad% AND my%<Y+8 AND my%>ady% THEN
      c$="255,255,255"
      IF mb%=4 THEN st$=msg$
      ELSE c$="200,200,200"
      ENDIF
      IF FNrgb(X,Y)="000,000,000" THEN c$="200,200,200"
      PROCcolor("f",c$)
      IF FNrgb(X,Y)<>c$ THEN
      FOR fi%=12 TO 48
        LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
      NEXT
      PROCcolor("f","000,000,000")
      MOVE tx,ty
      PRINT msg$
      ENDIF
      MOVE 0,0 REM hide that thing
      =st$
 
« Last Edit: Dec 24th, 2016, 06:15am by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
lamp Re: RETROLIB 6- here is your Christmas tree
« Reply #19 on: Dec 25th, 2016, 12:15pm »

Try this as an example program instead. It has the same basic code just does something slightly different from printing in the same spot each time.
Code:
      PROCgraphics(1000,600)
      ON ERROR END
      REPEAT
        a$= FNbuttonz(300,300,"Limitless buttons and no need for complexity !!")
        a$= FNbuttonz(100,100,"This is a button TEST")
        IF a$="This is a button TEST" THEN  GCOL RND(15)-1: RECTANGLE FILL RND(800),RND(600),RND(800),RND(600)
        IF a$="Limitless buttons and no need for complexity !!" THEN GCOL RND(15)-1: CIRCLE FILL RND(800), RND(600), RND(200)
        WAIT 10
      UNTIL FALSE
      END
 


Once you get it started it is difficult to stop. I don't think that is the intended behaviour of FNbuttonz.
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
lamp Re: RETROLIB 6- here is your Christmas tree
« Reply #20 on: Dec 25th, 2016, 2:06pm »

It is the first test of FNbuttonz..

It doesn't have the changes I made. But there is one thing PROCpr has as a protection..

It checks to see if the same message and location is repeated and if it is then nothing changes..

If a different message overlays the location, then the old message is erased and replaced with the new.

Ill do this same test you provided with the new version of FNbuttonz..
« Last Edit: Dec 26th, 2016, 02:08am by michael » User IP Logged

I like making program generators and like reinventing the wheel
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
lamp Re: RETROLIB 6- here is your Christmas tree
« Reply #21 on: Dec 25th, 2016, 3:16pm »

Ok it actually is simpler than I made it before.. Now it should be flawless as long as this kind of structure is maintained.
I admit I was multitasking too much.. I will try to stress test my works more when they are being questioned for stability..

RETROLIB 6 has this test inserted in a program segment
and it is in the first link for RETROLIB 6
Code:
      PROCgraphics(1000,600)
      ON ERROR END
      REPEAT
        a$= FNbuttonz(300,300,"clearitall")
        a$= FNbuttonz(300,300,"Limitless buttons and no need for complexity !!")
        a$= FNbuttonz(100,100,"This is a button TEST")
        IF a$="This is a button TEST" THEN  GCOL RND(15)-1: RECTANGLE FILL RND(800),RND(600),RND(800),RND(600)
        IF a$="Limitless buttons and no need for complexity !!" THEN GCOL RND(15)-1: CIRCLE FILL RND(800), RND(600), RND(200)
        WAIT 10
      UNTIL FALSE
      END
      REM RETROLIB 2
      DEF PROC_button(H,V,BEGIN,SIZE,X,C,A,DI)
      PROCcolor("f","000,000,000")
      LOCAL R,G,B,P
      R=X
      G=C
      B=A
      P=SIZE-BEGIN
      P=P/2
      P=BEGIN+P
      FOR Y=P TO SIZE
        COLOUR 1,X,C,A :GCOL 1
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X-DI
        C=C-DI
        A=A-DI
        IF X<2 THEN X=2
        IF C<2 THEN C=2
        IF A<2 THEN A=2
      NEXT Y
      P=SIZE-BEGIN
      P=P/2
      P=BEGIN+P
      FOR Y=BEGIN TO P
        COLOUR 1,X,C,A :GCOL 1
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X+DI
        C=C+DI
        A=A+DI
      NEXT Y
      COLOUR 1,R,G,B:GCOL 1
      FILL H,V
      PROCresetrgb
      ENDPROC
      DEF PROC_block(H,V,SIZE,X,C,A,DI)
      LOCAL P,Y
      P=SIZE/2
      FOR Y=1 TO SIZE
        COLOUR 0,X,C,A:GCOL 0
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X-DI
        C=C-DI
        IF X<2 THEN X=2
        IF C<2 THEN C=2
        IF A<2 THEN A=2
        P=P-1
      NEXT Y
      ENDPROC
      DEFPROCdotsize(n)
      VDU 23,23,n|
      ENDPROC
      REM COLORMIX object mixer
      DEFFNcolormix(x,y)
      PRIVATE rgb$,r%,g%,b%,switch%
      LOCAL h%,v%,click%
      MOUSE h%,v%,click%
      IF click%=4 THEN
        IF h%>x AND h%<x+50 AND v%>y AND v%<y+255 THEN r%=v%-y
        IF h%>x+49 AND h%<x+90 AND v%>y AND v%<y+255 THEN g%=v%-y
        IF h%>x+99 AND h%<x+140 AND v%>y AND v%<y+255 THEN b%=v%-y
      ENDIF
      IF switch%=0 OR click%=4 THEN
        PROCsbox(x-5,y-5,x+150,y+265,"255,255,255")
        PROCsbox(x,y+r%,x+40,y+r%+10,"200,000,000")
        PROCsbox(x+50,y+g%,x+90,y+g%+10,"000,200,000")
        PROCsbox(x+100,y+b%,x+140,y+b%+10,"000,000,200")
        switch%=1
        rgb$=FNnumstr(r%)+","+FNnumstr(g%)+","+FNnumstr(b%)
        PROCsbox(x-5,y+265,x+150,y+295,rgb$)
      ENDIF
      =rgb$
      REM  GRAPHICS(x,y)
      DEF PROCgraphics(x,y)
      VDU 23,22,x;y;8,15,16,1
      OFF
      VDU 5
      REM these variables are temporary
      N%=0
      N%=20
      DIM X(20),Y(20),H(20),V(20)
      ENDPROC
      DEFFNkey
      response$=INKEY$(0)
      =response$
      REM SBOX **********************
      DEF PROCsbox(x%,y%,w%,h%,c$)
      LOCAL ry%,sx%,sy%
      sx%=x%:sy%=y%
      IF x%>w% THEN x%=w%:w%=sx%
      IF y%>h% THEN y%=h%:h%=sy%
      ry%=y%
      PROCcolor("f",c$)
      REPEAT
        LINE x%,y%,w%,y%
        y%=y%+1
      UNTIL y%=h%
      y%=ry%
      IF c$<>"0" THEN PROCcolor("f","000,000,000") ELSE PROCcolor("f","white")
      LINE x%+2,y%+2,w%-2,y%+2
      LINE w%-2,y%+2,w%-2,h%-4
      LINE w%-2,h%-4,x%+2,h%-4
      LINE x%+2,h%-4,x%+2,y%+2
      PROCresetrgb
      ENDPROC
      REM RECT **********************
      DEFPROCrect(x%,y%,w%,h%)
      LOCAL sx%,sy%
      sx%=x%:sy%=y%
      IF x%>w% THEN x%=w%:w%=sx%
      IF y%>h% THEN y%=h%:h%=sy%
      LINE x%,y%,w%,y%
      LINE w%,y%,w%,h%
      LINE w%,h%,x%,h%
      LINE x%,h%,x%,y%
      ENDPROC
      REM pixel *******************
      DEFPROCpixel(x%,y%,c$)
      IF c$<>"" THEN PROCcolor("f",c$)
      MOVE x%,y%:DRAW x%,y%
      ENDPROC
      REM SET  c$ can be colors like blue or 1 or a R,G,B color
      DEF PROCset(x%,y%,c$)
      LOCAL h%
      PROCcolor("f",c$)
      FOR h%=0 TO 20
        LINE x%+h%,y%,x%+h%,y%+20
      NEXT
      MOVE 0,0
      ENDPROC
      REM restore default color palettes
      DEFPROCresetrgb
      COLOUR 0,0,0,0 :COLOUR 1,200,0,0 :COLOUR 2,000,200,000
      COLOUR 3,200,200,000:COLOUR 4,000,000,200:COLOUR 5,200,000,200
      COLOUR 6,000,200,200:COLOUR 7,200,200,200:COLOUR 8,056,056,056
      COLOUR 9,248,056,056:COLOUR 10,056,248,056:COLOUR 11,248,248,056
      COLOUR 12,056,056,248:COLOUR 13,248,056,248:COLOUR 14,056,248,248
      COLOUR 15,248,248,248
      ENDPROC
      DEF PROCcolor(fb$,rgb$)
      PRIVATE assemble$,br%,bg%,bb%
      IF rgb$="0" OR rgb$="black" THEN rgb$="000,000,000"
      IF rgb$="1" OR rgb$="red" THEN rgb$="200,000,000"
      IF rgb$="2" OR rgb$="green" THEN rgb$="000,200,000"
      IF rgb$="3" OR rgb$="yellow" THEN rgb$="200,200,000"
      IF rgb$="4" OR rgb$="blue" THEN rgb$="000,000,200"
      IF rgb$="5" OR rgb$="magenta" THEN rgb$="200,000,200"
      IF rgb$="6" OR rgb$="cyan" THEN rgb$="000,200,200"
      IF rgb$="7" OR rgb$="white" THEN rgb$="200,200,200"
      IF rgb$="8" OR rgb$="grey" THEN rgb$="056,056,056"
      IF rgb$="9" OR rgb$="light red" THEN rgb$="248,056,056"
      IF rgb$="10" OR rgb$="light green" THEN rgb$="056,248,056"
      IF rgb$="11" OR rgb$="light yellow" THEN rgb$="248,248,056"
      IF rgb$="12" OR rgb$="light blue" THEN rgb$="056,056,248"
      IF rgb$="13" OR rgb$="light magenta" THEN rgb$="248,056,248"
      IF rgb$="14" OR rgb$="light cyan" THEN rgb$="056,248,248"
      IF rgb$="15" OR rgb$="light white" THEN rgb$="248,248,248"
      assemble$=rgb$
      br%=VAL(MID$(assemble$,1,3)):bg%=VAL(MID$(assemble$,5,3)):bb%=VAL(MID$(assemble$,9,3))
      IF fb$="f" OR fb$="F" THEN COLOUR 0,br%,bg%,bb% : GCOL 0
      IF fb$="b" OR fb$="B" THEN COLOUR 1,br%,bg%,bb% : GCOL 128+1
      ENDPROC
      DEFFNnumstr(num)
      LOCAL cov$,l%
      cov$=STR$(num)
      l%=LEN(cov$)
      IF l%=1 THEN ret$="00"+cov$
      IF l%=2 THEN ret$="0"+cov$
      IF l%=3 THEN ret$=cov$
      =ret$
      DEFPROCpaint(x%,y%,co$)
      PROCcolor("b",FNrgb(x%,y%)):PROCcolor("f",co$)
      FILL x%,y%
      ENDPROC
      REM dotrgb ********************************
      DEFPROCdotrgb(x%,y%,r%,g%,b%)
      COLOUR 0,r%,g%,b% : GCOL 0
      MOVE x%,y%:DRAW x%,y%
      ENDPROC
      REM *****SPECIAL RGB tools (color extraction) has use with PROCdotrgb
      DEF PROCrgbret(x%,y%,RETURN r%,RETURN g%,RETURN b%)
      LOCAL rgb%
      rgb%=TINT(x%,y%)
      b%=INT(rgb%/(256*256))
      g%=INT((rgb%-b% *256*256)/256)
      r%=INT(rgb%-b%*256*256-g%*256)
      ENDPROC
      REM experimental
      DEFFNrgb(x%,y%)
      LOCAL r$,g$,b$,join$,r,g,b
      rgb%=TINT(x%,y%)
      b=INT(rgb%/(256*256))
      g=INT((rgb%-b *256*256)/256)
      r=INT(rgb%-b*256*256-g*256)
      r$=FNnumstr(r):g$=FNnumstr(g):b$=FNnumstr(b)
      join$=r$+","+g$+","+b$
      =join$
      REM  "INTERFACE" -library - for graphics text input and other tools
      REM X,Y,message,r,g,b
      DEF PROCpr(X,Y,msg$,c$)
      PRIVATE trackx,tracky,trackmsg$,trackc$
      LOCAL initialx%,fi%,reduction%,tx,ty
      IF trackx=X AND tracky=Y AND trackmsg$<>msg$ THEN PROCprsub(trackx,tracky,trackmsg$,"000,000,000")
      IF trackx<>X OR tracky<>Y OR trackmsg$<>msg$ OR trackc$<>c$ THEN
        initialx%=LEN(msg$)
        PROCcolor("f",c$)
        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 fi%=12 TO 48
          LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
        NEXT
        COLOUR 0,0,0,0
        GCOL 0
        MOVE tx,ty
        PRINT msg$
        MOVE 0,0
      ENDIF
      trackx=X:tracky=Y:trackmsg$=msg$:trackc$=c$
      ENDPROC
      DEFPROCprsub(X,Y,msg$,c$)
      LOCAL initialx%,fi%,reduction%,tx,ty
      initialx%=LEN(msg$)
      PROCcolor("f",c$)
      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 fi%=12 TO 48
        LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
      NEXT
      COLOUR 0,0,0,0
      GCOL 0
      MOVE tx,ty
      PRINT msg$
      MOVE 0,0
      ENDPROC
      DEFFNbuttonz(X,Y,msg$)
      LOCAL initialx%,fi%,reduction%,tx,ty,mx%,my%,mb%,ad%,ady%,c$
      PRIVATE st$
      IF msg$<> "clearitall" THEN
      initialx%=LEN(msg$)
      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%
      MOUSE mx%,my%,mb%
      ad%=initialx%+8:ad%+=X:ady%=Y-28
      IF mx% >X AND mx%<ad% AND my%<Y+8 AND my%>ady% THEN
        c$="255,255,255"
        IF mb%=4 THEN st$=msg$
      ELSE c$="200,200,200"
      ENDIF
      IF FNrgb(X,Y)="000,000,000" THEN c$="200,200,200"
      PROCcolor("f",c$)
      IF FNrgb(X,Y)<>c$ THEN
        FOR fi%=12 TO 48
          LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
        NEXT
        PROCcolor("f","000,000,000")
        MOVE tx,ty
        PRINT msg$
      ENDIF
      ENDIF
      IF msg$="clearitall" THEN st$=""
      MOVE 0,0 REM hide that thing
      =st$

 
« Last Edit: Dec 25th, 2016, 5:44pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
lamp Re: RETROLIB 6- here is your Christmas tree
« Reply #22 on: Dec 25th, 2016, 5:07pm »

At last it almost works as you would expect.
Great. It is not by the method I would have chosen :I would have got rid of the private variable and process the loop differently like I mentioned in an earlier post.

Now all it needs is detection of the button being released so that holding down the button does not give repeated hits so it is like a windows button (or any GUI in the last 30 years), or you put in a delay before you get repeats like on a keyboard key so that old slow coaches, such as me, don't get 3 circles per click instead of just one.

By the way your last post has that pesky surplus ENDIF again. If you fix it in the original code then you won't keep copying the error.

Do you intend to provide any documentation on how any of this code should be used?

Z
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
lamp Re: RETROLIB 6- here is your Christmas tree
« Reply #23 on: Dec 25th, 2016, 5:15pm »

RETROLIB 6 has the bug fixes, including the ENDIF issue..

There is documentation for RETROLIB 2 and 3..


Although it needs to be updated, as RETROLIB 6 is looking like it has the necessary components and modifications to make it workable in projects

The example you see is a paste from RETROLIB 2 (with modifications and deletions and ... well its no longer RETROLIB 2... its a snippet


I will look to ensure that a person cant click 2 times on the same button and get a repeated response from that button...

But there is one problem..

If I do that then, what if the button is meant to adjust something ?

Perhaps I could just make a setting in the FNbuttonz syntax... so that it can serve more than one purpose.

A note: The WAIT command does give a person enough time to click on the button and avoid repeating the action... I could increase the WAIT command to lesson repeating something

There will be more content added to RETROLIB 6 in the future, but for now, it will stay the way it is until I get my game done.
I will work on improving its function as time passes.

It is a tool for the BBC Basic community.


« Last Edit: Dec 25th, 2016, 7:22pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
lamp Re: RETROLIB 6- here is your Christmas tree DEC 2
« Reply #24 on: Dec 25th, 2016, 10:50pm »

Quote:
I will look to ensure that a person cant click 2 times on the same button and get a repeated response from that button...


That is not what I think is needed. In the cases I suggested you can press repeatedly and get repeated actions. What you don't want is repeated actions from one brief press of the button.

The windows action requires that the button down and button up both occur on the same button for it to be actioned. I think that would be very difficult to achieve without a complete rewrite of the button procedures.

Achieving a keyboard type delay should be easy. Or you could tell the user that they should add a wait after the action procedure to stop additional triggering. That is where the documentation comes in. If you can tell the user the limitations of the code then all is well. It is just that you tend to hype your code as flawless which kind of builds up the user expectations.

Z
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
lamp Re: RETROLIB 6- here is your Christmas tree DEC 2
« Reply #25 on: Dec 25th, 2016, 11:47pm »

After thinking about the possibilities, with a button check beyond, say a delay, it would add too many factors when keeping track of buttons pressed.

Buttonz is supposed to be simple and unlimited. (well what you can fit on a screen at any given time.. )

I believe it is the most simple button that can be made. The simple design of the buttonz FN is that it relies on what it is immediately given at the moment that it is being used or observed.

That, and for me, it was revolutionary in design, and simplicity.. It remade my programming strategy on other utilities that are not here yet, that rely on interface controls.

I will just make documentation for buttonz so a person knows how to make it work best.


I am not saying that buttonz couldn't be modified to do the checks, it just seems that monitoring it would be unnecessary.
My point being, that, if a button is pressed once.. it would do a pause then a task, then return to the beginning of the cycle, clear the function string and look for the next instruction.
By that time, the button should no longer be pressed.

Also, it is a simple alternative.. RETROLIB is a work in progress.
Its not perfection, but it works ..

An idea has crossed my mind about a FN that could keep a string list for any other FN or Procedure that would extract and insert the information, only allowing 1 instance of that string and giving it a time limit.. I am trying to work it out.
« Last Edit: Dec 26th, 2016, 02:38am by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
lamp Re: RETROLIB 6- here is your Christmas tree DEC 2
« Reply #26 on: Dec 26th, 2016, 2:59pm »

Quote:
After thinking about the possibilities, with a button check beyond, say a delay, it would add too many factors when keeping track of buttons pressed.


Yes it would require you to keep a track of the buttons either by storing details in an array or something and I understand that you want to keep it simplistic. Certainly you can increase the WAIT time so that it effectively reduces the unwanted repeats, and that works well in most instances. But isn't the point of libraries so that you can hide sophisticated code which users don't need to know about the details of but just that it works. Take the COMLIB library that you use. That is pretty complex and I doubt that the code in there means much to most people but it is (relatively) simple to use. I am biased though as I wrote part of that code.

I still can't fathom why you want to go to the 'clearitall' solution rather than simply make st$ LOCAL in FNbuttonz and then you simply write the loop like this:
Code:
      REPEAT
        a$=""
        a$+= FNbuttonz(100,1100,"Limitless buttons and no need for complexity !!")
        a$+= FNbuttonz(100,1000,"This is a RETROLIB 6 button TEST for DECEMBER 25 2016")
        a$+= FNbuttonz(100,900,"Lets skip this and look at the next options")
        IF a$="This is a RETROLIB 6 button TEST for DECEMBER 25 2016" THEN  GCOL RND(15)-1: RECTANGLE FILL RND(800),RND(600),RND(800),RND(600)
        IF a$="Limitless buttons and no need for complexity !!" THEN GCOL RND(15)-1: CIRCLE FILL RND(800), RND(600), RND(200)
        WAIT 20
      UNTIL a$="Lets skip this and look at the next options"
 


a$ then always reflects the button message that is currently pressed, and so it does not need to be unlatched by 'clearitall'.
That seems to me to be simpler still.

Or you could use the more direct action linking as I was suggesting on the 23rd. When I talked about getting rid of the PRIVATE variable st$ then. That is:
Code:
      REPEAT
        a$= FNbuttonz(100,1100,"Limitless buttons and no need for complexity !!") : \
        \ IF a$="Limitless buttons and no need for complexity !!" THEN GCOL RND(15)-1: CIRCLE FILL RND(800), RND(600), RND(200)
        a$= FNbuttonz(100,1000,"This is a RETROLIB 6 button TEST for DECEMBER 25 2016") : \
        \IF a$="This is a RETROLIB 6 button TEST for DECEMBER 25 2016" THEN  GCOL RND(15)-1: RECTANGLE FILL RND(800),RND(600),RND(800),RND(600)
        a$= FNbuttonz(100,900,"Lets skip this and look at the next options")
        WAIT 20
      UNTIL a$="Lets skip this and look at the next options"
 


Both of these options work.
And a final suggestion or request actually (really!) can you add Code:
 
SYS "MessageBox",@hwnd%,REPORT$,0,48
 
to your ON ERROR line so that when an error does occur you can see it otherwise the error report is hidden under the black mantle of the background. Then when the PROCgr("loadbmp tree 10 0 900 900") fails because there is no such file on my machine I know why the program stopped.

Z
User IP Logged

Zaphod
Guest
lamp Re: RETROLIB 6- here is your Christmas tree DEC 2
« Reply #27 on: Dec 26th, 2016, 4:49pm »

Here is a variation on Michael's theme. UPDATED.
The code can be compacted if we don't do string comparisons but do boolean ones to see if the button is pressed. In this case the result will be TRUE or FALSE.
Then using BB4W's ability to do compound assignments you can simplify things quite a lot.
Let me stress that the ideas for this theme are Michael's and I have just re-coded various bits to make this minimal demo.
Code:
      REM Demo of buttons
      REM Based on ideas by "Michael", recoded and revised by Zaphod. Dec 2016

      ON ERROR SYS "MessageBox",@hwnd%, REPORT$,0,48
      PROCgraphics(1000,600)
      REPEAT
        REM Note that the WAIT to avoid repeats is AFTER the action.
        IF FNbuttonpressed(100,1100,"Rectangles") THEN  GCOL RND(15)-1: RECTANGLE FILL RND(800),RND(600),RND(800),RND(600):WAIT 20
        IF FNbuttonpressed(100,1000,"Circles") THEN GCOL RND(15)-1: CIRCLE FILL RND(800), RND(600), RND(200):WAIT 20
        WAIT 0
      UNTIL  FNbuttonpressed(100,900,"Exit")
      VDU 4
      CLS
      PRINT "That's all folks"
      END

      DEFFNrgb(x%,y%) :REM by Zaphod
      LOCAL rgb%, r&, g&, b&
      rgb%=TINT(x%,y%)
      r&=rgb%    :REM Use byte variable as mask.
      g&=rgb% >>8
      b&=rgb% >>16
      =FNnumstr(r&)+","+FNnumstr(g&)+","+FNnumstr(b&)

      DEFFNnumstr(num&)
      LOCAL cov$
      cov$=STR$(num&)
      WHILE LEN(cov$)<3 cov$="0"+cov$ ENDWHILE
      =cov$

      DEF PROCgraphics(x%,y%)
      VDU 23,22,x%;y%; 8,15,16,1
      OFF
      VDU 5
      ENDPROC

      DEF FNbuttonpressed(x%,y%,msg$) :REM by Zaphod
      LOCAL mx%,my%,mb%,dx%,dy%,c$
      REM Button is 1.5 time text height and 1.5 times text length.
      dx%=LEN(msg$)*3*@vdu%!216
      dy%=@vdu%!220*3
      WAIT 0
      MOUSE mx%,my%,mb%
      IF mx% >x% AND mx%<(x%+dx%) AND my%<(y%+dy%) AND my%>y% THEN
        c$="255,255,255"
        IF mb%=4 THEN :=TRUE
      ELSE
        c$="200,200,200"
      ENDIF
      IF FNrgb(x%+2,y%+2)<>c$ THEN
        PROCcolor("f",c$)
        RECTANGLE FILL x%, y%, dx%, dy%
        PROCcolor("f","000,000,000")
        MOVE x%+dx%/6, y%+dy%*5/6 :REM Center text.
        PRINT msg$
      ENDIF
      =FALSE
      DEF PROCcolor(fb$,rgb$)
      LOCAL assemble$,br%,bg%,bb%
      IF rgb$="0" OR rgb$="black" THEN rgb$="000,000,000"
      IF rgb$="1" OR rgb$="red" THEN rgb$="200,000,000"
      IF rgb$="2" OR rgb$="green" THEN rgb$="000,200,000"
      IF rgb$="3" OR rgb$="yellow" THEN rgb$="200,200,000"
      IF rgb$="4" OR rgb$="blue" THEN rgb$="000,000,200"
      IF rgb$="5" OR rgb$="magenta" THEN rgb$="200,000,200"
      IF rgb$="6" OR rgb$="cyan" THEN rgb$="000,200,200"
      IF rgb$="7" OR rgb$="white" THEN rgb$="200,200,200"
      IF rgb$="8" OR rgb$="grey" THEN rgb$="056,056,056"
      IF rgb$="9" OR rgb$="light red" THEN rgb$="248,056,056"
      IF rgb$="10" OR rgb$="light green" THEN rgb$="056,248,056"
      IF rgb$="11" OR rgb$="light yellow" THEN rgb$="248,248,056"
      IF rgb$="12" OR rgb$="light blue" THEN rgb$="056,056,248"
      IF rgb$="13" OR rgb$="light magenta" THEN rgb$="248,056,248"
      IF rgb$="14" OR rgb$="light cyan" THEN rgb$="056,248,248"
      IF rgb$="15" OR rgb$="light white" THEN rgb$="248,248,248"
      assemble$=rgb$
      br%=VAL(MID$(assemble$,1,3)):bg%=VAL(MID$(assemble$,5,3)):bb%=VAL(MID$(assemble$,9,3))
      IF fb$="f" OR fb$="F" THEN COLOUR 0,br%,bg%,bb% : GCOL 0
      IF fb$="b" OR fb$="B" THEN COLOUR 1,br%,bg%,bb% : GCOL 128+1
      ENDPROC
 


Z
« Last Edit: Dec 27th, 2016, 01:17am by Zaphod » User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
lamp Re: RETROLIB 6- here is your Christmas tree DEC 2
« Reply #28 on: Dec 26th, 2016, 5:28pm »

Amazing work... There is one difference ..

FNbuttonz was designed to be simple and non flicker..

Richard did make issue with the fact that I needed to make my functions efficient.

You are more skilled than I am atm. (probably always will be) I am working on my skills.

I am sure you were planning to make the buttons not constantly redraw themselves.
I thought to point that out.. FNbuttonz is extremely efficient.

But then you did slap that great work together quick..


I will make minor improvements to RETROLIB over time, although, I don't plan to drastically change its structure, as it was made to assist people who are new to BBC Basic and those who would like to use it.

The Game I am working on might not even use any of the library,(but I will use the mask tool for sprite creation) as I may specialize each part, including the custom images. I do plan to advance far beyond this.

RETROLIB is just a plateau.. People can use it if they want.
« Last Edit: Dec 26th, 2016, 5:51pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
lamp Re: RETROLIB 6- here is your Christmas tree DEC 2
« Reply #29 on: Dec 26th, 2016, 6:59pm »

Quote:
FNbuttonz was designed to be simple and non flicker..

I didn't change any of that code so the flicker may be down to the change from WAIT 10 to WAIT 0 in the main loop. I did not notice any flicker on my machine but that means nothing as each configuration is different. Maybe a WAIT of 1 or 2 might work better.
That was perhaps far too fast a refresh but the main loop wait time in this configuration is time that blocks the button down sensing so has to be less than a typical click duration or you might get occasional missed clicks, which is annoying. So yes this code does have that limitation. Locking refresh to the scan rate can be done but it is pretty darn complex and outside of the initial remit, I think.
Code:
I am sure you were planning to make the buttons not constantly redraw themselves. 

No, because I thought that might be difficult to do simply but I have just had a thought about that, so I might update it if it works out...
Stay tuned.

Z
User IP Logged

Pages: 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

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