Page 1 of 1

Bug in pages or in program ?

Posted: Fri Dec 13, 2024 11:48 am
by Dutchman
Apparently my question about a possible bug has gone unnoticed.
See https://nitisara.ru/forum/viewtopic.php ... 627#p15627
That's why I posted it here in the hope that someone can help.

I've been trying to make a background for a custom toolbar for some time now, but I can't.
I want to create the toolbar in a separate page that remains visible and then return to the default page "" on which the program should generate the output.
The code below gives a minimal example:

Code: Select all

' Problem with pages
'm'
  SET BUTTONS CUSTOM
  GET SCREEN SIZE sw,sh
  GRAPHICS
  GRAPHICS CLEAR 0.5,0.5,0.5
' Set bar backgroundcolor
'loop for action, do something
  y=sh/2
  DO SLOWDOWN ' relax while doing
    FILL COLOR RND(1),RND(1),RND(1)
    FILL CIRCLE sw/2, y SIZE 100
    y-=sh/20
    REFRESH
Checkbutton:
REM    IF NOT buttonbar THEN END
    pause 0.03
  UNTIL y<-5
  END ' of testprogram
''
'b'
' Function to create bar with stop button
' If stop-button has been pressed then the function returns 0, else 1

'g'
DEF ButtonBar
  sw=.sw ! sh=.sh
  IF NOT Init THEN GOSUB CreateButton
  'get base option
    base=SUBSTR$("10",1,1)
'Set bar background on separate page
'     so that it will not be cleared by GRAPHICS CLEAR
  PAGE "bar" SET
    PAGE "bar" COLOR 0,0,1,0.5
    PAGE "bar" FRAME 0,0,sw,22
    PAGE "bar" SET
    PAGE "bar" SHOW
 PAGE "" SET
 PAGE "" SHOW
 'b' Check stop button
  IF BUTTON_PRESSED("stop") THEN RETURN 0
RETURN 1 ' from function

CreateButton:
' create all toolbar buttons 
  ypos=-6
  FILL COLOR 0,0,0
  DRAW COLOR 1,1,1
  FILL ALPHA 0
  DRAW ALPHA 1
  BUTTON "stop" TEXT "stop" AT int(sw*.4),ypos
  init=1
END DEF
[/code
If you run that program, you will see circles drawn from the center of the screen to the top, after which the program stops.

If you remove the "REM" statement after the "Checkbutton:" label, the program will display a colored top bar, but only draw one circle and stop after the usual time. While running, the program can be stopped prematurely by pressing "stop" in the top bar.

Why don't the other circles appear?
How can I fix this?

Re: Bug in pages or in program ?

Posted: Fri Dec 13, 2024 2:24 pm
by Henko
Hi Ton,
After the first call to the function “ButtonBar”, the “FILL ALPHA” parameter remains zero, whence the circles are drown, but without any color strength.
Greets, Henk

Re: Bug in pages or in program ?

Posted: Sat Dec 14, 2024 8:24 am
by Henko
drown -> drawn :)

Insert “FILL ALPHA 1” between both “FILL” statements in the main program.

Re: Bug in pages or in program ?

Posted: Sat Dec 14, 2024 1:53 pm
by Dutchman
Thank you very much Henko. I don't know how many hours I spent trying to fix it, but it was a lot. That's why I'm very happy that the solution is so simple.
Groeten :D