Sign in to follow this  
Followers 0
azure

Variable Select Blocks

2 posts in this topic

Here's a scenario. I put the variable handles for a bunch of GUI controls into an array.

Such as:

Dim $control[8][3]
Dim $labels[8][3]

$temparray = ''
$temparray = stringsplit('Sunday,Monday,Tuesday,Wednsday,Thursday,Friday,Saturday',',')
For $i = 1 To $temparray[0]
   $labels[$i-1][0] = $temparray[$i]
Next
$temparray = ''
$temparray = stringsplit('Sunday,Monday,Tuesday,Wednsday,Thursday,Friday,Saturday',',')
For $i = 1 To $temparray[0]
   $labels[$i-1][1] = $temparray[$i]
Next
$temparray = ''
$temparray = stringsplit('Sunday,Monday,Tuesday,Wednsday,Thursday,Friday,Saturday',',')
For $i = 1 To $temparray[0]
   $labels[$i-1][2] = $temparray[$i]
Next

$tabgroup = GUISetControl("tab", "Tab Group", 10, 10, 180, 180)
For $i = 0 To UBound ( $control, 0 )
   $control[$i][0] = GUISetControl("tabitem", $labels[$i][0], 0, 0, 0, 0)
   $control[$i][1] = GUISetControl("progress", $labels[$i][1], 100, 40, 50, 140)
   $control[$i][2] = GUISetControl("edit", $labels[$i][2], 20, 40, 80, 140)
Next
$tabclose = GUISetControl("tabitem","",-99,-99,1,1)

How would I write a select block to check if the GUIMsg = a variable stored in, say another array. (using a for/ubound loop perhaps?) I could save tons of lines of code and make it much more dynamic than having to define every single case! :ph34r:

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Use this kind of construct:

Select
  Case Test1()
  ;do stuff
  Case Test2()
  ;do other stuff
;etc etc etc
EndSelect

Func Test1()
  Local $count
  For $count = 0 To 5
    If $global_array[$count] = 1 Then return 1
  Next
  return 0
EndFunc

Func Test2()
  Local $count
  For $count = 6 To 10
    If $global_array[$count] = 1 Then return 1
  Next
  return 0
EndFunc

You'll notice that the functions that define the text can be as complex as you need them to, and access multipile variables, arrays, whatever. The return of that function will make up the true or false value that the Select... Case construct uses to determine which branch of your code to run.

Minor code edit

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0