DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass ChnListBox Selection to Diadem Script

Solved!
Go to solution

I have a dialog box with a ChnListBox that the user selects particular Channels from using the multiselection option.  I would like to pass the selected channel indexes to a variable to use in a script.

So far I have attempted using setting the global "TV" variable when based on the user selections when the dialog "OK" button is pressed with the code below:

 

Sub Button1_EventClick(ByRef This) 'Created Event Handler  
    For i=1 to ChnListBox.MultiSelection.Count
        TV(i) = ChnListBox.MultiSelection(i).value
        MsgBoxDisp(TV(i))
    Next
    Dialog.OK  
End Sub 

 

I have also tried setting the variable on the ChnListBox event change.  In both cases the MsgBoxDisp of "TV" show the correct selected channel index but are not transferred as "NOVALUE" when attempting to read variable in Diadem script.

 

Any thoughts on the correct way to do this?

 

Thanks,

BG103

0 Kudos
Message 1 of 6
(4,959 Views)

I mistyped:

 

Post should have said .... In both cases the MsgBoxDisp of "TV" shows the correct selected channel index but ARE transferred as "NOVALUE" when attempting to read variable in Diadem Script...

0 Kudos
Message 2 of 6
(4,952 Views)
Solution
Accepted by topic author BG103

Ok, I was able to figure it out using a user defined global variable to link dialog box to Diadem script instead of any of the predefiend Diadem Global Variables which seem to have specific applications such as use with text or long integers.  I remembered seeing warnings against using user defiend globals at some point but it seems to be doing the job.

 

0 Kudos
Message 3 of 6
(4,950 Views)

Could you please send your solution to the board!?

Thank's

0 Kudos
Message 4 of 6
(4,382 Views)

Sorry I didn't inlcude any actual code with my solution...

 

So basically when creating the dialog box channel selector I first created the ChnListBox in DIAdem Dialog Editor.  Then I created an event action for my dialog box  "OK" button that will update the will populate my user defined vairable when I press OK on the dialog button. In example code below I create a user defined array "X" that is initilaized to 50 elements.  Again, this code is in the EventClick subroutine in the DIAdem Dialog Editor. "Button1" is my "OK" button.

 

Dim i
GlobalRedim ("X(50)")


Sub Button1_EventClick(ByRef This) 'Created Event Handler
  For i=1 to ChnListBox.MultiSelection.Count
    X(i) = ChnListBox.MultiSelection(i).value
  Next
  Dialog.OK
End Sub

 

After selecting which channels I want (the number selected needs to be less than the array size of "X"), I press the OK button.  In the code above,  "i" iterates on the count of items selected in ChnListBox and populates the user defines array which each of these selections.  Then back in DIAdem Script, we can use the "X" array to do whatever you want.  In my case, I use the selected channels to delete all other channels in data portal.

 

After using the GlobalRedim command, the "X" variable should show up as green text when used in other scripts.  Just be careful using a generic variable such as X as it may often be used elsewhere.

 

Hope that helps!

 

 

0 Kudos
Message 5 of 6
(4,373 Views)

I like using global variables for my dialog boxes, as it makes it a lot easier to keep any options the user selects.  You can declare your own variables, so that you don't have to rely on built in global vars.  To do this, you use the GlobalDim command and send it text for the name of your variable. So, for a dynamic array, you can use the below code.  Works just like a normal dim declaration, but the variables and values remain in memory until you restart Diadem, or call the ScriptCmdReset() function. Another convenient thing is that once the global variables are actually declared, they turn green in your code. 

 

 

Call GlobalDim("TV()")
Call GlobalReDim("TV(5)")

 

0 Kudos
Message 6 of 6
(4,372 Views)