|
Post by tailoredreaction on Nov 30, 2020 21:16:32 GMT
This is me "!hide"ing 8 buttons.
#main.button1, "!hide"
#main.button2, "!hide"
#main.button3, "!hide"
#main.button4, "!hide"
#main.button5, "!hide"
#main.button6, "!hide"
#main.button7, "!hide"
#main.button8, "!hide"
I have tried using a for/next loop to hide all 8 buttons in one loop.
ie
for a = 1 to 8 #main.button(a), "!hide"
next a
But no such luck! It comes back at me with a syntax error (I believe).
I am 11 days into programming using any sort of graphics. I love JB so far. Except for the odd little thing here and there over the years, I have not done any programming in 30 years. When I did used to program, I was at a very early/low level. I just knew what I needed to get by with whatever project I was working on.
Solving this problem for me will open the gates to solving a whole slew of similar problems I have run into in the past 11 days.
Can anyone show me the correct syntax? Or is what I am attempting not possible?
|
|
|
Post by honkytonk on Dec 1, 2020 0:39:48 GMT
for x=1 to 8 hand$="#main.button"+str$(x) #hand$, "!hide" next x (or: # hand$ ?)
|
|
|
Post by tailoredreaction on Dec 1, 2020 7:12:10 GMT
Thank you honkytonk,
That works well and was just what I was looking for.
What would be the syntax for something longer, like this...
print #main.graphicbox1, "down; fill"; colour$(0); " flush"
...? where the graphicbox number changes as well as the colour$ string number?
I think I understand now how the syntax works for just one item, but what about two items, or even multiple items like when opening a box, or button, and you're adding the x and y start co-ordinates as well as the 2 size parameters?
Thank you
|
|
|
Post by honkytonk on Dec 1, 2020 9:42:28 GMT
Color requires three values (red green blue) RGB Example: color$ = "123 255 000" To change the colors of several graphicbox several ways are possible, here is one Test this
rgb$="123 255 000 255 234 124 243 125 000 241 312 145 254 246 147" '---5 x 3 values for x=1 to len(rgb$) '---to cont Ncolors if word$(rgb$,x)="" then n=(x-1)/3: exit for '---Not int((x-1)/3) Because if the result is not integer, there is 'an error in the number of values. next x print "Ncolors= ";n dim color$(n+1) '----(+1 because arrays start with "0") b=1 for x=1 to n '---fulling array color$(x)=word$(rgb$,b)+" "+word$(rgb$,b+1)+" "+word$(rgb$,b+2) b=b+3 next x
for x= 1 to n print color$(x) '----to vérify next x
'---and affect values
a = 0 for x = 1 to Ngraphics '---Ngraphics and Ncolors must be equals hand$ = "#main.graphicbox" + str$(x) #hand$, "down" a=a+1: #hand$, "fill ";" ";color$(a) #hand$, "flush" next x
Note: there is a space in: "fill " It is better not to use the "0" in arrays because strings begin with "1", so everything starts with "1". it avoids confusion.
|
|
|
Post by honkytonk on Dec 1, 2020 9:50:50 GMT
Note: If there are few Ncolors it's more simple to full array with: color$(1)="123 255 000" color$(2)="255 234 124" color$(3)="241 312 145" ...ect...
|
|
|
Post by tsh73 on Dec 1, 2020 11:18:29 GMT
1. commands to graphic boxes, buttons whatever in JB - are commands in plain text. So if you change
print #main.graphicbox1, "down; fill"; colour$(0); " flush" to
print "down; fill"; colour$(0); " flush" - removing object name - you will see what command your object is getting. (I for myself just got
down; fill flush that's nor really promicing, so I defined
colour$(0) = "red" and got
down; fillred flush still not good? There are need in spaces and semicolons to get it finally look like this
down; fill red; flush - so you just fiddle until you get nice human-readable (!) commands (separating numbers with spaces too). )
2. There is a help topic "Handle Variables" but you probably already know everything it has.
3. You can manipulate existing controls with handle variables. You CANNOT *create* controls with handle variables.
|
|
|
Post by tailoredreaction on Dec 1, 2020 16:22:01 GMT
Color requires three values (red green blue) RGB Example: color$ = "123 255 000" To change the colors of several graphicbox several ways are possible, here is one Test this rgb$="123 255 000 255 234 124 243 125 000 241 312 145 254 246 147" '---5 x 3 values for x=1 to len(rgb$) '---to cont Ncolors if word$(rgb$,x)="" then n=(x-1)/3: exit for '---Not int((x-1)/3) Because if the result is not integer, there is 'an error in the number of values. next x print "Ncolors= ";n dim color$(n+1) '----(+1 because arrays start with "0") b=1 for x=1 to n '---fulling array color$(x)=word$(rgb$,b)+" "+word$(rgb$,b+1)+" "+word$(rgb$,b+2) b=b+3 next x
for x= 1 to n print color$(x) '----to vérify next x
'---and affect values a = 0 for x = 1 to Ngraphics '---Ngraphics and Ncolors must be equals hand$ = "#main.graphicbox" + str$(x) #hand$, "down" a=a+1: #hand$, "fill ";" ";color$(a) #hand$, "flush" next x
Note: there is a space in: "fill " It is better not to use the "0" in arrays because strings begin with "1", so everything starts with "1". it avoids confusion. Thank you, honkytonk, for all your work here! The second example nailed it for me. That simple loop replaces 64 lines that I formerly had to type out. I am not too concerned with defining the colour$ string variable values yet. I am simply just sticking with the 16 default "colours" that come with JB, eg colour$(0) = " red" colour$(1) = " blue" colour$(2) = " yellow" etc I have now run into the next problem, that is I am getting a "syntax error" when I try to run a loop that initially places the 64 boxes on my screen. I have tried adjusting my syntax but can't seem to find the right syntax. graphicbox #main.graphicbox1, 15, 15, 60, 60 <---- this is the first box of 64 I want I tried this loop and it wouldn't work, v = 1 for t = 0 to 7 for u = 0 to 7 test3$ = "#main.graphicbox" + str$(v) #test3$, (60*t + 15), (60*u + 15), 60, 60 <--- it pointed at this line as the 'syntax error' v = v + 1 next u next t any ideas?
|
|
|
Post by honkytonk on Dec 1, 2020 17:31:08 GMT
Open ..... #x is the window #x.map, graphicbox, This is a control in the window. You can modify the attributes of the controls after the Open .... # x Dimensions and placements are made during CREATING the control.
tsh73 say: "You CANNOT *create* controls with handle variables." Graphicbox it's control
|
|
|
Post by tailoredreaction on Dec 1, 2020 18:45:14 GMT
Thank you again honkytonk!,
I think I get it.
But opening a graphic box requires (I think anyway) that I give it the top left x, y co-ordinates, as well as the length and width of the box. As so,
eg,
graphicbox #main.graphicbox1, 26, 536, 100, 100
At least this is the format I am getting from the Freeform GUI editor.
Surely there must be a way to open a multitude of graphicboxes all at the same time without tediously typing every single line in. Up until now I have just started a new program to print the line as I want them written, ran the new program, then copy/pasted the results into my original program.
|
|
|
Post by tailoredreaction on Dec 1, 2020 19:24:38 GMT
No, I don't get it. :-(
I can't even think of a question that might help me understand at this point.
I am lost at things like "Graphicbox the control".
I want to create 64 graphicboxes. I can do it the long way. I have done it the long way.
I think my confusion is around words like "handle", "control", "window", "graphicbox" <---all new to me.
|
|
|
Post by B+ on Dec 1, 2020 19:37:31 GMT
Do you think you could live with 64 boxes inside one graphics box that covers the whole screen or nearly so?
That would be more straight forward code-wise where you could use (an) array(s) to control contents of those boxes.
More that one way to skin a cat.*
* no animals were harmed nor any unnecessary harm intended in the posting of this reply.
|
|
|
Post by B+ on Dec 1, 2020 19:38:56 GMT
What the heck did I do? a repeat post, blah!
|
|
|
Post by Rod on Dec 1, 2020 20:14:56 GMT
Ok, this seems hard because we are jetting off in the wrong direction. One graphicbox suffices, all mouse and keyboard input can be managed more easily from one source. The graphics on display are limitless and easy. So have a rethink about your strategy.
|
|
|
Post by B+ on Dec 1, 2020 20:20:46 GMT
I think Rod just agreed with me
|
|
|
Post by tailoredreaction on Dec 1, 2020 21:51:06 GMT
"Ok, this seems hard because we are jetting off in the wrong direction. One graphicbox suffices, all mouse and keyboard input can be managed more easily from one source. The graphics on display are limitless and easy. So have a rethink about your strategy." I am a novice, especially with anything to do with programming graphics. I apologize. When you say "the graphics on display are limitless and easy." I have a very limited idea of what you are referring to. I made a Connect 4 game, all in one window (nomainwin) with 42 drawn boxes that fill as columns are chosen. It works great. It took me a couple of days to write and get working good. Now I am looking for a better way to draw the boxes, and I am making a different game at the same time that requires 64 boxes drawn. I just think this is may be a language issue. Or, as you say, I have completely "jetted off in the wrong direction" from day one, got things to work, and assumed it was a good way. :-) My questions must see 'crazy' if that's the case. I have already used 42 and 64 boxes in a single window with no problems. I am not trying to open 64 screens or anything like that. I am drawing rectangular and/or square boxes. I thought I was, anyway. lol Is perhaps one guy's graphicbox another guy's window? In the Freeform GUI editor, it calls the boxes I draw "graphicboxes" when it compiles the program for me. ================================================================ Question: When you say I need just "one graphicbox", assuming I make 64 copies in 64 locations then so 64 boxes stay on the screen when I run the program, if they are all called "graphicbox" how do I tell them apart inside my program?
|
|