DXScript - Calling external class object?

Hey y'all, long time reader, first time poster.

I'm doing a little experimenting and can't quite seem to get past this. The idea is to create a hidden object that has most of my code and make calls to that object when I need to access my functions or class objects. I know I can call functions from the hidden object.

I created an object ("Object01") and attached the code to it. I made my own class object...

Class MyTestObject
Sub SayMessage()
MsgBog "Test"
End Sub
End Class

I can create a new MyTestObject from within "Object01"...

Dim vTest
Set vTest = New MyTestObject
vTest.SayMessage

However, I can't access MyTestObject from another DesktopX object ("Object02"). I tried...

Dim vTest
Set vTest = DesktopX.ScriptObject("Object01").MyTestObject

Doesn't work. I get Class not defined: 'DesktopX'

Am I missing something? Is this possible?

24,334 views 3 replies
Reply #1 Top
I don't think this is possible through objects. One reason is it wouldn't be possible from a standard script accessing another script; unless you read/imported the entire class object through a function, which kind of defeats the purpose of using an external script "class" (in DesktopX).

Just tried doing this using an external script with the same results. The closest work-a-round - if you're set on using classes - is to declare the object in "Object01" script and access it the same as you would a function.

Code: vbscript
  1. ' Object01 Script
  2. Dim vTest : Set vTest = New MyTestObject
  3. Class MyTestObject
  4. Sub SayMessage()
  5. MsgBox "Test"
  6. End Sub
  7. End Class
  8. ' Object02 Script
  9. DesktopX.ScriptObject("Object01").vTest.SayMessage
+1 Loading…
Reply #2 Top
That might work. I'll play with it. Mad I didn't think of it;-) Thanks!
Reply #3 Top
No problem. ;)

The only issue might be in the size of the classes and how many objects you're calling.