|
Post by tailoredreaction on Nov 8, 2021 0:35:47 GMT
Ever since I started to learn how to use Just Basic V 2.0 I have been having a recurring problem when drawing graphics. I draw my screen in a graphicbox, then I use the #main, "flush" command to make the graphics stick. However, the screen is interactive using just MouseX and MouseY input to give my program feedback, ie, the user picks a box and it plays a wav file, or a movie.
After a few clicks, the entire white background of my program fills in with whatever color I last used with a "backcolor <color>" command. In this particular case it is the backcolor to the last text I used. One more click and the backcolor disappears, but appears later after another click on the screen.
I have had this problem with other programs I've written that do not have an interactive screen as well. I feel like I have reached the end of my ability to self teach this. I just can't grasp the fundamentals of what is going on.
|
|
|
Post by Rod on Nov 8, 2021 16:58:27 GMT
It will be a simple code error. But we really need to see the code. You might print a debugging line every color change statement you make. That might show you where your code changes color inappropriately.
But best show your code. There is a bug because Just BASIC will do just exactly what you tell it to do.
|
|
|
Post by tsh73 on Nov 8, 2021 17:54:08 GMT
|
|
|
Post by tailoredreaction on Nov 8, 2021 21:18:28 GMT
nomainwin
WindowWidth = 830 WindowHeight = 810
UpperLeftX = 630 UpperLeftY = 5
file$ = "C:\Users\Thomas\Desktop\New folder 3\Moms Movie Launcher.rtf"
dim movie$(20) dim MovieName$(20) dim MovieName2$(20) dim title$(20) dim about$(20) dim color$(20)
color$(1) = "yellow" color$(2) = "brown" color$(3) = "red" color$(4) = "darkred" color$(5) = "pink" color$(6) = "darkpink" color$(7) = "blue" color$(8) = "darkblue" color$(9) = "green" color$(10) = "darkgreen" color$(11) = "cyan" color$(12) = "darkcyan" color$(13) = "white" color$(14) = "black" color$(15) = "lightgray" color$(16) = "darkgray"
open file$ for input as #text
for k = 1 to 12
line input #text, movie$(k) MovieName2$(k) = word$(movie$(k), 2, ",") MovieName$(k) = word$(MovieName2$(k), 1, ".") title$(k) = word$(movie$(k), 3, ",") about$(k) = word$(movie$(k), 4, ",")
print movie$(k), k print MovieName$(k), k print MovieName2$(k), k print title$(k), k print about$(k), k
next k
close #text
graphicbox #main.g, 5 , 5 , 820 , 800 open "Mom's Movie Launcher" for window_popup as #main
#main, "trapclose [quit.main]"
[DrawingTheSlots] ' drawing the title\About\PLAY slots
for j = 0 to 2 for k = 0 to 9
m = 13 if j < 2 then n = 8 if j = 2 then n = 10 if j < 2 then o = 11 if j = 2 then o = 9
#main.g, "up"
if j = 0 then #main.g, "goto "; 10 ;" "; k*72 + 10 if j > 0 then #main.g, "goto "; 290 + 180*j ;" "; k*72 + 10
#main.g, "down"
if k=0 or k=2 or k=4 or k=6 or k=8 then #main.g, "backcolor "; color$(n) else _ #main.g, "backcolor "; color$(o)
#main.g, "boxfilled "; 450 + j*180 ;" "; k*72 + 70 #main.g, "up"
if j = 0 then #main.g, "goto "; 18 ;" "; k*72 + 50 if j > 0 then #main.g, "goto "; 293 + 195*j ;" "; k*72 + 50
#main.g, "down" #main.g, "font Comic 26 bold"
if k=0 or k=2 or k=4 or k=6 or k=8 then #main.g, "color "; color$(m) else _ #main.g, "color "; color$(n)
if k=0 or k=2 or k=4 or k=6 or k=8 then #main.g, "backcolor "; color$(n) else _ #main.g, "backcolor "; color$(o)
if j = 0 then #main.g, "\";MovieName$(k+3) if j = 1 then #main.g, "\About.." if j = 2 then #main.g, "\PLAY"
next k next j
#main.g, "up" #main.g, "goto 650 726" #main.g, "down" #main.g, "backcolor darkred" #main.g, "boxfilled 810 786" #main.g, "up" #main.g, "goto 715 774" #main.g, "down" #main.g, "font Comic 37 bold" #main.g, "color white" #main.g, "backcolor darkred" #main.g, "\X"
' #main.g, "flush"
[InterActivePart]
#main.g, "when leftButtonDown [leftclick]"
wait
[leftclick]
' #main.g, "redraw"
if MouseX > 0 and MouseX < 460 then [SayTheTitle] if MouseX > 459 and MouseX < 640 then [DescribeTheMovie] if MouseX > 639 then [PlayTheMovie]
[SayTheTitle]
title = int((MouseY - 4)/72) + 1
playwave "C:\Users\Thomas\Desktop\New folder 3\WAVS\";title$(title+2)
wait
[DescribeTheMovie]
about = int((MouseY - 4)/72) + 1
playwave "C:\Users\Thomas\Desktop\New folder 3\WAVS\";about$(about+2)
wait
[PlayTheMovie]
PLAY = int((MouseY - 4)/72) + 1
if PLAY > 10 then [quit.main]
run "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe "_ ;chr$(34);"C:\Users\Thomas\Desktop\New folder 3\";MovieName2$(PLAY+2);chr$(34)
[quit.main]
close #main
end
-- code below left just in case I broke something
nomainwin
WindowWidth = 830
WindowHeight = 810
UpperLeftX = 630
UpperLeftY = 5
file$ = "C:\Users\Thomas\Desktop\New folder 3\Moms Movie Launcher.rtf"
dim movie$(20)
dim MovieName$(20)
dim MovieName2$(20)
dim title$(20)
dim about$(20)
dim color$(20)
color$(1) = "yellow"
color$(2) = "brown"
color$(3) = "red"
color$(4) = "darkred"
color$(5) = "pink"
color$(6) = "darkpink"
color$(7) = "blue"
color$(8) = "darkblue"
color$(9) = "green"
color$(10) = "darkgreen"
color$(11) = "cyan"
color$(12) = "darkcyan"
color$(13) = "white"
color$(14) = "black"
color$(15) = "lightgray"
color$(16) = "darkgray"
open file$ for input as #text
for k = 1 to 12
line input #text, movie$(k)
MovieName2$(k) = word$(movie$(k), 2, ",")
MovieName$(k) = word$(MovieName2$(k), 1, ".")
title$(k) = word$(movie$(k), 3, ",")
about$(k) = word$(movie$(k), 4, ",")
print movie$(k), k
print MovieName$(k), k
print MovieName2$(k), k
print title$(k), k
print about$(k), k
next k
close #text
graphicbox #main.g, 5 , 5 , 820 , 800
open "Mom's Movie Launcher" for window_popup as #main
#main, "trapclose [quit.main]"
[DrawingTheSlots] ' drawing the title\About\PLAY slots
for j = 0 to 2
for k = 0 to 9
m = 13
if j < 2 then n = 8
if j = 2 then n = 10
if j < 2 then o = 11
if j = 2 then o = 9
#main.g, "up"
if j = 0 then #main.g, "goto "; 10 ;" "; k*72 + 10
if j > 0 then #main.g, "goto "; 290 + 180*j ;" "; k*72 + 10
#main.g, "down"
if k=0 or k=2 or k=4 or k=6 or k=8 then #main.g, "backcolor "; color$(n) else _
#main.g, "backcolor "; color$(o)
#main.g, "boxfilled "; 450 + j*180 ;" "; k*72 + 70
#main.g, "up"
if j = 0 then #main.g, "goto "; 18 ;" "; k*72 + 50
if j > 0 then #main.g, "goto "; 293 + 195*j ;" "; k*72 + 50
#main.g, "down"
#main.g, "font Comic 26 bold"
if k=0 or k=2 or k=4 or k=6 or k=8 then #main.g, "color "; color$(m) else _
#main.g, "color "; color$(n)
if k=0 or k=2 or k=4 or k=6 or k=8 then #main.g, "backcolor "; color$(n) else _
#main.g, "backcolor "; color$(o)
if j = 0 then #main.g, "\";MovieName$(k+3)
if j = 1 then #main.g, "\About.."
if j = 2 then #main.g, "\PLAY"
next k
next j
#main.g, "up"
#main.g, "goto 650 726"
#main.g, "down"
#main.g, "backcolor darkred"
#main.g, "boxfilled 810 786"
#main.g, "up"
#main.g, "goto 715 774"
#main.g, "down"
#main.g, "font Comic 37 bold"
#main.g, "color white"
#main.g, "backcolor darkred"
#main.g, "\X"
' #main.g, "flush"
[InterActivePart]
#main.g, "when leftButtonDown [leftclick]"
wait
[leftclick]
' #main.g, "redraw"
if MouseX > 0 and MouseX < 460 then [SayTheTitle]
if MouseX > 459 and MouseX < 640 then [DescribeTheMovie]
if MouseX > 639 then [PlayTheMovie]
[SayTheTitle]
title = int((MouseY - 4)/72) + 1
playwave "C:\Users\Thomas\Desktop\New folder 3\WAVS\";title$(title+2)
wait
[DescribeTheMovie]
about = int((MouseY - 4)/72) + 1
playwave "C:\Users\Thomas\Desktop\New folder 3\WAVS\";about$(about+2)
wait
[PlayTheMovie]
PLAY = int((MouseY - 4)/72) + 1
if PLAY > 10 then [quit.main]
run "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe "_
;chr$(34);"C:\Users\Thomas\Desktop\New folder 3\";MovieName2$(PLAY+2);chr$(34)
[quit.main]
close #main
end
|
|
|
Post by tsh73 on Nov 8, 2021 22:44:35 GMT
I removed extra spacing and added code box.
Please add sample file it reads.
|
|
|
Post by Rod on Nov 9, 2021 12:46:56 GMT
I ran the code you posted. There is nothing fundamentally wrong with it in terms of flush and redraw. The graphics stick and no matter how many times I click it all stays rock solid. I wonder if the processor is getting pushed when sound or video files are loaded and played? If so the redraw command will be the culprit. It redraws all drawing commands in the segment, so you may see partial graphics if the screen refreshes.
There is actually no need for the redraw command. You draw the screen once and flush. If the screen presentation never changes that's all you need. So take out the redraw command and try again.
If you do change the screen presentation the simples way is to CLS then redraw and flush once more.
Let us know how you get on, also tell us what your OS is and are your graphics card drivers up to date? Stick to testing the code as posted for now.
|
|
|
Post by tailoredreaction on Nov 9, 2021 14:10:33 GMT
thanks for your efforts Rod,
there is no redraw command. I tried it, it didnt work, what you see is a commented out remnant, i think. I am not planning on changing the screen presentation. my OS is win10 home, graphics card, no idea, but its built in. how do i know if my drivers are up to date?
this problem has presented across both computers i have here. both run win10 home, one is a desktop, the other a laptop.
|
|
|
Post by tailoredreaction on Nov 9, 2021 14:13:47 GMT
tsh, thank you for replying.
i am not sure how to reply to you directly.
do you think my .rtf file might be the cause? or the spacing of the code i posted here?
what is a "code box"?
|
|
|
Post by tsh73 on Nov 9, 2021 14:47:14 GMT
rtf file needed for program to work on I put in something, but binary file prodiced garbage and random text file with different line lengths probably not that supposed to be in your file? Just post an example, 3-5 lines will be enough.
Spacing just doubled. I guess that happens automatically if you paste from some editor? Or you really insert every other empty lines?
Code box is code formatting aids on this forum You just put [_code_]
[_/code_]
(but without "_") around your posted code. It gets scrollable region and monospaced font. (button with big [C] on forum editor toolbar pastes these codes)
|
|
|
Post by Rod on Nov 9, 2021 15:32:32 GMT
This code runs for me and does not need the .rtf which will have nothing to do with the problem. I don't play any sound or play any movie. The code runs perfectly for me. Try it and tell us if you still have a problem. The difference will be that when you run it it will find and play the sound files. For me it simply plays a default beep because I don't have the sound files.
WindowWidth = 830 WindowHeight = 810
UpperLeftX = 630 UpperLeftY = 5
file$ = "C:\Users\Thomas\Desktop\New folder 3\Moms Movie Launcher.rtf"
dim movie$(20) dim MovieName$(20) dim MovieName2$(20) dim title$(20) dim about$(20) dim color$(20)
color$(1) = "yellow" color$(2) = "brown" color$(3) = "red" color$(4) = "darkred" color$(5) = "pink" color$(6) = "darkpink" color$(7) = "blue" color$(8) = "darkblue" color$(9) = "green" color$(10) = "darkgreen" color$(11) = "cyan" color$(12) = "darkcyan" color$(13) = "white" color$(14) = "black" color$(15) = "lightgray" color$(16) = "darkgray"
' open file$ for input as #text
for k = 1 to 12
' line input #text, movie$(k) MovieName2$(k) = "test movie name" 'word$(movie$(k), 2, ",") MovieName$(k) ="test name two" ' word$(MovieName2$(k), 1, ".") title$(k) = "Title of Movie"+str$(k) 'word$(movie$(k), 3, ",") about$(k) = "about info" 'word$(movie$(k), 4, ",")
print movie$(k), k print MovieName$(k), k print MovieName2$(k), k print title$(k), k print about$(k), k
next k
'close #text
graphicbox #main.g, 5 , 5 , 820 , 800 open "Mom's Movie Launcher" for window_popup as #main
#main, "trapclose [quit.main]"
[DrawingTheSlots] ' drawing the title\About\PLAY slots
for j = 0 to 2 for k = 0 to 9
m = 13 if j < 2 then n = 8 if j = 2 then n = 10 if j < 2 then o = 11 if j = 2 then o = 9
#main.g, "up"
if j = 0 then #main.g, "goto "; 10 ;" "; k*72 + 10 if j > 0 then #main.g, "goto "; 290 + 180*j ;" "; k*72 + 10
#main.g, "down"
if k=0 or k=2 or k=4 or k=6 or k=8 then #main.g, "backcolor "; color$(n) else _ #main.g, "backcolor "; color$(o)
#main.g, "boxfilled "; 450 + j*180 ;" "; k*72 + 70 #main.g, "up"
if j = 0 then #main.g, "goto "; 18 ;" "; k*72 + 50 if j > 0 then #main.g, "goto "; 293 + 195*j ;" "; k*72 + 50
#main.g, "down" #main.g, "font Comic 26 bold"
if k=0 or k=2 or k=4 or k=6 or k=8 then #main.g, "color "; color$(m) else _ #main.g, "color "; color$(n)
if k=0 or k=2 or k=4 or k=6 or k=8 then #main.g, "backcolor "; color$(n) else _ #main.g, "backcolor "; color$(o)
if j = 0 then #main.g, "\";MovieName$(k+3) if j = 1 then #main.g, "\About.." if j = 2 then #main.g, "\PLAY"
next k next j
#main.g, "up" #main.g, "goto 650 726" #main.g, "down" #main.g, "backcolor darkred" #main.g, "boxfilled 810 786" #main.g, "up" #main.g, "goto 715 774" #main.g, "down" #main.g, "font Comic 37 bold" #main.g, "color white" #main.g, "backcolor darkred" #main.g, "\X"
#main.g, "flush"
[InterActivePart]
#main.g, "when leftButtonDown [leftclick]"
wait
[leftclick]
#main.g, "redraw"
if MouseX > 0 and MouseX < 460 then [SayTheTitle] if MouseX > 459 and MouseX < 640 then [DescribeTheMovie] if MouseX > 639 then [PlayTheMovie]
[SayTheTitle]
title = int((MouseY - 4)/72) + 1
playwave "C:\Users\Thomas\Desktop\New folder 3\WAVS\";title$(title+2) print "Describe ";title wait
[DescribeTheMovie]
about = int((MouseY - 4)/72) + 1 print "about ";about playwave "C:\Users\Thomas\Desktop\New folder 3\WAVS\";about$(about+2)
wait
[PlayTheMovie]
PLAY = int((MouseY - 4)/72) + 1 print "Playing ";PLAY if PLAY > 10 then [quit.main]
' run "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe "_ ';chr$(34);"C:\Users\Thomas\Desktop\New folder 3\";MovieName2$(PLAY+2);chr$(34) wait
[quit.main] print "Quitting" close #main
end
Another point I just noticed, you don't use the async argument when you use the play wave command. This will cause the program to freeze till the sound file is complete. So experiment and try as is then add the async argument to the play wave command and see if it makes it behave differently.
|
|
|
Post by tailoredreaction on Nov 9, 2021 17:00:17 GMT
Thanks for helping Rod.
That took me forever to figure out what you mean and run it.
That ran for me with the alterations you made. It did not backfill my screen with darkred at any time and I tried it over 30 times.
I didn't see your last tip about async until after I had copied and ran the code. The darkred was only appearing after I clicked on the "about" and "title" boxes. Clicking a "play" box automatically launches the chosen movie and exits the JB program. So the darkred problem never happened there.
Since it doesn't do the darkred thing now, does that indicate to you that playing my wav files might be the cause?
The program as you've altered it seems exactly as I have been using it pretty well all along. I will look more into the "async" thing you mentioned, add it in, and run it again. I will get back to you with my results/any questions I might have then.
|
|
|
Post by tsh73 on Nov 9, 2021 17:12:49 GMT
In your code as posted "flush" at the end of [DrawingTheSlots] block was commented out. Turn it ON.
One more things BEFORE you do any drawing - just at the top of [DrawingTheSlots] block - do
#main.g, "down; fill white; flush"
(I do this all the time. Probably someone taught me long ago, I do not remember)
This does help on my machine. I really hope it will help you.
last thing program as posted NEEDS rtf file to run if you want us to run your program, you should post something. It kind of hard to guess back - especially because it is not RTF file (standard Rich TextFile format) at all and it happened to have to look like this
name1.name2_1,title1,about1 name2.name2_2,title2,about2 name3.name2_3,title3,about3 name4.name2_4,title4,about4 name5.name2_5,title5,about5 name6.name2_6,title6,about6 name7.name2_7,title7,about7 name8.name2_8,title8,about8 name9.name2_9,title9,about9 name10.name2_10,title10,about10 name11.name2_11,title11,about11 name12.name2_12,title12,about12
Why on the Earth should I guess that just to run your program to help you?
EDIT. Obviously hard day. You can disregard it. Noone owe me a thing. Noone makes me help people.
|
|
|
Post by tailoredreaction on Nov 9, 2021 17:39:46 GMT
Thanks for your further indulgence, Rod.
I added "sync" to my "playwave" command and it worked great for about 15 or so clicks. Then the program just shut itself down, editor and all.
So I changed it to "async" and it ran perfectly well past 30 clicks. No darkred problem at all.
I am happy with this result because I can't see my mother clicking the screen more than a few times at any one session. She watches a movie and this JB program closes itself as soon as the movie launches. I set the movie player (VLC) to shut down as well when her movie finishes. I thought "sync" would serve her better and kind of just left the "playwave" command in its default.
I am hoping this is a permanent solution going forward.
Thanks again, and I will be back if anything else arises.
|
|
|
Post by tailoredreaction on Nov 9, 2021 18:05:18 GMT
tsh, thank you for helping. that link you sent me that described "flush" etc was very helpful.
i feel your frustration. i think (for now anyway) the problem with this particular program has been identified as not adding "async" after a "playwave" command. I don't know why it didn't work with the default, or why "async" fixed it.
i was convinced originally the problem lay in me not fully understanding the whole "flush", "discard", "cls", "redraw" thing. that is why i asked about that in my OP.
i hate having to add this, but i really am a newbie with programming and do not understand half or more of what is told to me here. i have never had any formal training with computers or programmimg languages. i don't even know how to reply to you directly here on this forum. all stuff i should learn, but obviously not a lot sticks in my dated memory.
again, thanks for helping. i really do appreciate it.
**edit
about the commented out parts of the program i did send. i had tried about a million different things to make it work. i moved "flush" around so many times i had given up. when someone asked to see the code, i didn't even think to restore it to the condition that had been working the best. i just copy/pasted and asked at this forum.
|
|
|
Post by Rod on Nov 9, 2021 19:36:08 GMT
Anatoly, better known as tsh37 isn't frustrated he just likes to help and succeed at that. The difference between playwave sync and playwave async is that the program freezes when sync is used. The program freezes till the sound file is complete, often seconds. This will cause problems because updates, interrupts like mouse clicks and such cannot be processed and queue. So you get a sudden rush of activity when the sound file stops. So best use async which lets Just BASIC carry on as normal and handle all interrupts timeously.
|
|