|
Post by turtleman on Jul 10, 2020 8:41:38 GMT -5
I'm sure there must be a way of using a FOR – NEXT loop for this greatly simplified example, but I'm totally stumped!
If g1 = 1 then #tab3.g1, "!show" If g2 = 2 then #tab3.g2, "!hide" If g3 = 3 then #tab3.g3, "!show" and so on for a dozen more
I've successfully used loops lots of times, but usually with just a numerical variable. I'm embarrassed asking help for something I should know how to handle by now, but would appreciate any push in the right direction. Thanks!
|
|
|
Post by alincon on Jul 10, 2020 10:15:00 GMT -5
Select Case might be what you want, rather than for-next. Check the help file. r.m.
|
|
|
Post by turtleman on Jul 10, 2020 10:24:10 GMT -5
Thanks Alincon. I'm using Select Case elsewhere in the program, and for sure it would eliminate having to run through a dozen or more IF statements, but I was hoping to find some way of plugging a value into the #tab3.gx value, where x = the 1-14 in the IF statements.
|
|
|
Post by Chris Iverson on Jul 10, 2020 10:59:43 GMT -5
You might be able to look into handle variables.
You can't use handle variables when creating a window/controls, but you can use them in a lot of cases when interacting with controls.
hndl$ = "#tab3.g1" #hndl$, "!show"
|
|
|
Post by Gordon Rahman on Jul 10, 2020 16:26:56 GMT -5
I feel what you need. ON A GOSUB [label1],[label2],[label3] The whole world was against BASIC for that .... including a Dutch professor who hated to study BASIC listings .... But now even I like SELECT CASE
|
|
|
Post by metro on Jul 10, 2020 21:19:19 GMT -5
Not sure if this helps Could do with subs instead though
'nomainwin WindowWidth=900 WindowHeight=650 UpperLeftX=(DisplayWidth-WindowWidth)/2 UpperLeftY=(DisplayHeight-WindowHeight)/2 button #main.b1, "button1", [button1Click], UL, 10, 10, 120, 25 button #main.b2, "button2", [button2Click], UL, 10, 40, 120, 25 button #main.b3, "button3", [button3Click], UL, 10, 70, 120, 25 button #main.b4, "button4", [button4Click], UL, 10, 100, 120, 25 button #main.b5, "button5", [button5Click], UL, 10, 130, 120, 25 button #main.b6, "button6", [button6Click], UL, 10, 160, 120, 25 button #main.b7, "button7", [button7Click], UL, 10, 190, 120, 25 button #main.b8, "button8", [button8Click], UL, 10, 220, 120, 25 button #main.b9, "button9", [button9Click], UL, 10, 250, 120, 25 button #main.b10, "button10", [button10Click], UL, 10, 280, 120, 25 button #main.b11, "button11", [button11Click], UL, 10, 310, 120, 25 button #main.b12, "button12", [button12Click], UL, 10, 340, 120, 25 button #main.b13, "button13", [button13Click], UL, 10, 370, 120, 25 button #main.b14, "CLICK ME FIRST", [SEERESULTS], UL, 10, 400, 120, 25
open "My New Program" for Window as #main #main,"trapclose [quit]" hide=0 WAIT [SEERESULTS] if hide= 1 goto [REVERSE] if hide=0 then for i = 1 to 13 checkHandle$ = "#main.b"; i r= i MOD 2 if r/i=0 then nextHandle$ = "#main.b";i #nextHandle$,"!hide" end if next #main.b14, "PUT THEM BACK" hide = 1 end if WAIT
[REVERSE] if hide = 1 then for i = 1 to 13 checkHandle$ = "#main.b"; i r= i MOD 2 if r/i = 0 then nextHandle$ = "#main.b";i #nextHandle$,"!show" end if next #main.b14, "CLICK ME FIRST" hide = 0 end if WAIT
[quit] close #main END
|
|
|
Post by turtleman on Jul 11, 2020 10:40:40 GMT -5
I'm still pondering what to do, but didn't want to wait any longer before thanking everyone. Your suggestions are much appreciated! I suppose I was searching for a way of "simply" substituting a digit (1-14 in my application) for what is essentially the same repeating code.
|
|
|
Post by metro on Jul 11, 2020 18:12:57 GMT -5
OR...........
nomainwin WindowWidth=900 WindowHeight=650 UpperLeftX=(DisplayWidth-WindowWidth)/2 UpperLeftY=(DisplayHeight-WindowHeight)/2 button #main.b1, "START", [button1Click], UL, 10, 10, 120, 25 button #main.b2, "button2", [button2Click], UL, 10, 40, 120, 25 button #main.b3, "button3", [button3Click], UL, 10, 70, 120, 25 button #main.b4, "button4", [button4Click], UL, 10, 100, 120, 25 button #main.b5, "button5", [button5Click], UL, 10, 130, 120, 25 button #main.b6, "button6", [button6Click], UL, 10, 160, 120, 25 button #main.b7, "button7", [button7Click], UL, 10, 190, 120, 25 button #main.b8, "button8", [button8Click], UL, 10, 220, 120, 25 button #main.b9, "button9", [button9Click], UL, 10, 250, 120, 25 button #main.b10, "button10", [button10Click], UL, 10, 280, 120, 25 button #main.b11, "button11", [button11Click], UL, 10, 310, 120, 25 button #main.b12, "button12", [button12Click], UL, 10, 340, 120, 25 button #main.b13, "button13", [button13Click], UL, 10, 370, 120, 25 button #main.b14, "PUT EM BACK", [REVERSE], UL, 10, 400, 120, 25
open "My New Program" for Window as #main #main,"trapclose [quit]" #main.b1,"!font Arial 14 bold" #main.b14,"!hide" wait
[button1Click] for i= 1 to 13 TIMER 100, [DOIT] wait [DOIT]
CALL HIDEME i next TIMER 0 #main.b14,"!show" WAIT
SUB HIDEME i nextHandle$ = "#main.b";i #nextHandle$,"!hide" END SUB
[REVERSE] for i= 1 to 13 nextHandle$ = "#main.b";i #nextHandle$,"!show" next #main.b14,"!hide" WAIT
[quit] close #main END
|
|