DXScript - Calling external class object?

By Posted May 26, 2008 14:30:51
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?

0 Karma 3 Replies 4 Referrals
May 26, 2008 17:31:06
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
May 26, 2008 20:01:02
That might work. I'll play with it. Mad I didn't think of it;-) Thanks!
May 26, 2008 21:33:39
No problem.

The only issue might be in the size of the classes and how many objects you're calling.
Stardock Forums v1.5.3112.18688
© 1995-2008 Stardock Corporation. All rights reserved.
All times are EST. The time is now 06:50:13
Server Load Time: 00:00:00.0021125   Page Render Time:
© 2008 Stardock Corporation. All rights reserved.