09-01-2015 10:44 AM
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
Solved! Go to Solution.
09-01-2015 12:17 PM
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...
09-01-2015 12:36 PM
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.
01-19-2016 08:54 AM
Could you please send your solution to the board!?
Thank's
01-19-2016 09:26 AM
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!
01-19-2016 09:28 AM - edited 01-19-2016 09:29 AM
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)")