|
Post by wexhammer on Jan 12, 2020 10:11:34 GMT -5
Is it possible to put handles in arrays? So you can hide or show the array instead of hiding and showing hundreds of handles.
|
|
|
Post by Rod on Jan 12, 2020 11:56:32 GMT -5
Yes with a little work round.
'create a window with a checkbox and set it checkbox #win.red, "Red", [redSet], [redReset], 10, 10, 400, 24 open "The new handle variable way" for window as #win 'fill the array var with the handle of the checkbox: dim var$(5) var$(1) = "#win.red" 'now use the associated array variable to set the checkbox 'first we have to make it an ordinary string, not an array$() v$=var$(1) #v$ "set" wait
|
|
|
Post by sarossell on Jan 12, 2020 12:09:09 GMT -5
Please excuse the spaghetti code. I took a different approach. I hope I understood what you are asking for.
From the menu, select either Hide or Show.
nomainwin
dim w$(3) ' Array to hold Show/Hide status.
for n = 1 to 3 ' Load initial array values to Show all elements. w$(n) = "Show" next n statictext #win.stat, "What?", 10, 10, 100, 20 button #win.bttn, "Hello",[hello],UL,10,70 checkbox #win.cbox, "Goodbye",[quit],[quit],10,160,120,24 menu #win, "&Main","&Show",[doShow],_ "&Hide",[doHide],"E&xit",[quit] open "Show and Hide" for window as #win wait
[quit] close #win end
[doShow] ' Load array to Show all elements. for n = 1 to 3 w$(n) = "Show" next n goto [execute]
[doHide] for n = 1 to 3 w$(n) = "Hide" next n goto [execute]
[execute] ' Display all elements according to array values. #win.stat "!" + w$(1) ' Some elements require the leading "!" #win.bttn "!" + w$(2) #win.cbox w$(3) ' Others don't. wait
[hello] wait
|
|
|
Post by sarossell on Jan 12, 2020 12:19:22 GMT -5
I initially attempted to store the handle names in the array, but some handles would not work properly, complaining of missing extensions during compile.
For example Button and Statictext handles worked fine, but Textbox complained.
|
|
|
Post by wexhammer on Jan 12, 2020 14:07:20 GMT -5
Pretty cool, cheers all!
|
|