Unusual behavior of AW SDK in classes (Sdk)

Unusual behavior of AW SDK in classes // Sdk

1  |  


May 20, 2002, 1:22pm
This morning, I continued working on a "sekrit project" that I announced a
few days ago. [Remember that phrase? :)] Before anyone asks what it's
about, I will give one hint - that it will revolutionize the environment in
AWTeen and perhaps affect the rest of the universe as well. That's all the
info I'm divulging until it's released in two weeks.

Now that that's over with, I was trying to create a "Bot" class this morning
to unify all the other classes I've been using. Basically, this class would
simplify the use of the SDK by automating things like session tables and
object querying. For example, someone could use:

Bots(1).Move("900n 30e")
Bots(1).Whisper "Brant", "Hi"
Bots(1).ConsoleMessageToAllUsers "Test message"
var1 = Bots(1).AvatarList("Brant").session
Bots(1).query("800n 50e")

and so on. But as I was trying to do this, I tried to include an AWSdkOcx4
object in the class and have been receiving "Object with block or variable
not set" errors.

At first, I used these lines:

Private AW as AWSdkOcx4 'as a class property
Set AW = new AWSdkOcx4 'at first access

but that fails with an "invalid use of New keyword." I tried making the
object AW public, but there was no change. Even if you try to use the SDK
as a simple variable (not as an object), it fails as well with a similar
error. When I looked up the help on this issue in the MSDN library, it


You tried to instantiate an Automation object, but it was not a creatable
object. For example, you tried to create a new instance of a list box by
specifying ListBox in a statement like the following:
' Valid syntax to create the variable.
Dim MyListBox As ListBox
Dim MyFormInst As Form
' Invalid syntax to instantiate the object.
Set MyFormInst = New Form
Set MyListBox = New ListBox

ListBox and Form are class names, not specific object names. You can use
them to specify that avariable will be a reference to a certainobject type,
as with the valid Dim statements above. But you can't use them to
instantiate the objects themselves in a Set statement. You must specify a
specific object, rather than the generic class name, in the Set statement:

' Valid syntax to create new instance of a form or list box.
Set MyFormInst = New Form1
Set MyListBox = New List1


I don't see why you'd have to use a different name when instantiating these
objects. Anyone have any ideas on why this might be or how to solve the



May 20, 2002, 1:56pm
Its the same problem as you get if you want to wrap the Winsock control ...
there is no object exposed under the control for you to instantiate - so the
control HAS to be owned by a valid container (a form).

There are two ways to handle it. The first (and quickest in terms of
development) definitely works but is a bit nasty, and that's to have a form
with just an SDK control on it (plus a timer if you like - to keep the bot
class self contained). The class then has two member variables to handle
it - one for the form and one (WithEvents) for the control. In the
class_initialize, instantiate a new form against the form member variable
and then set the control member variable to the control on the form. This
example may look like the MSDN code.

Consider a form called frmBotControl, as described above, with the SDK
control on it (called awSDK).

Private mControlForm as frmBotControl
Private WithEvents mAWSDK as AwSdkOcx4

Private Sub Class_Initialize()

Set mControlForm = New frmBotControl
Set mAWSDK = mControlForm.awSDK

End Sub

Private Sub Class_Terminate()

Set mAWSDK = Nothing

Unload mControlForm
Set mControlForm = Nothing

End Sub

Using the above, you should be able to instantiate a single bot (unless I've
forgotten something), totally self-contained, communicating using the mAWSDK
member variable and receiving all the events through it. It can run
out-of-process too. The other way is to build a broker class that does
basically the same thing but loads/unloads its own SDK controls on its own
form to hand out to other classes requesting it. Essentially, you would
start the broker and the initialisation code of the bot class would request
a control from the broker and the terminate code would tell it to discard

The broker method is "Nicer" but I've always used the first way, with an
intention of putting the broker in place later. The problem is I've never
got around to it, and I have a feeling it may not let you unless you make
the form in the broker public (ick!) .... and maybe not even then.

If you're not going to start a whole bunch of bot classes, then there's no
real impact on having a form/control in the bot class itself.

Hope that helps, otherwise let me know and I'll knock up an example for you
to use as a template to save some time and keep your follicles in your scalp
where they belong.


[View Quote]


May 20, 2002, 4:30pm
I think I know what it is. IT'S a WeatherBot!

[View Quote]


May 20, 2002, 5:05pm
oooh, bot array class. I want a copy of that when it works brant :o)


[View Quote]


May 20, 2002, 6:10pm
Weatherbot? That's already been done, albeit in a much sloppier manner. I
thought I'd finally get a class like this together to save me a lot of work
in the future, especially since I'm programming the classes and certain
3.2/non-AW functions now, and waiting until MrGrimm has put together the new
VB SDK and AW 3.3 is out of the beta test phase before finishing up with the
3.3 only functions.

[View Quote]


May 21, 2002, 12:16am
Thanks a lot, grims! Everything works perfectly now. Thanks again.

[View Quote]

strike rapier

May 29, 2002, 3:21pm
Not knowing what Brants reply was cause im offline.. but

Carl... *should* already know Brants Thor is a weatherbot that can also
control world rights etc....

*Its 12:10, and I have a maths test tomorrow (Wed) but this will probably be
delayed untill then) - Time for bed*


May 30, 2002, 10:58am
I hadn't planned on making a reply, lol. Thor (and Thor 2) are programmed
such that they will only work in AWTeen. Massive changes would be necessary
to make it work in another world, not to mention another backdrop or skybox
series would be needed since Beardo and NoMad own the rights to the current
projects. I wish I could help :(

[View Quote]


May 30, 2002, 7:01pm
Brant, you can do whatever you like with the images I made for you. It =
was a gift to you and AWTeen, so you guys own it now :-)



Remove nospam for email reply. Free Bryce 4-5 textures and planet =

"brant" <awteen at> skrev i meddelandet =
news:3cf62210$1 at
> I hadn't planned on making a reply, lol. Thor (and Thor 2) are =
> such that they will only work in AWTeen. Massive changes would be =
> to make it work in another world, not to mention another backdrop or =
> series would be needed since Beardo and NoMad own the rights to the =
> projects. I wish I could help :(
[View Quote]

1  | is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn