Global Variables

Is it possible to declare 'Global' variables somewhere in DX so all objects have access to the variables?  I know you can Dim variables at the head of an object's script that will be visible to all subroutines in the objects script.  How about for DX itself?

I want to Dim a variable, Dim Color for example, and set the states of other multiple objects based on the value of Color. 

Is this possible?  If so, how.

Thanks.

5,208 views 4 replies
Reply #1 Top
Yes and no. By default if your variable is declared external to a sub or function than it is global to that script.

You can reference that script from a script in the calling object using the DesktopX ScriptObject namespace or do everything from one main script.

IMO the best way is to use one main script but, you need to make sure all the objects are children of the main script object. You would use something like below to do states.

Code: vbscript
  1. 'Called on selected object state changes
  2. Function Object_OnStateChangeEx(obj,state)
  3. With DesktopX
  4. Select Case obj.name
  5. Case "object1"
  6. If state= "Mouse over" Then
  7. ElseIf state= "Mouse away" Then
  8. ElseIf state= "Mouse down" Then
  9. ElseIf state= "Mouse up" Then
  10. ElseIf state="Command executed" Then
  11. End If
  12. End Select
  13. End With
  14. End Function
Reply #3 Top
No problem.

If you need or are looking for help post in the DesktopX Forum here https://forums.wincustomize.com/forum/37

Most of the scripters are all over that thread like seagulls on a french fry. ;)
Reply #4 Top

SQUAWK!!!