Thread

2 questions. (Sdk)

2 questions. // Sdk

1  |  

x@x.com (xelag)

Nov 10, 1998, 12:40pm
I use vb6.0 and have managed to login 3 bots at a time, roughly
following the greeter bot script (no greetings i'm afraid). I have 2
questions at the moment. Can anyone help explaining these matter?.

1.
Whether i log in 1 or more bots, they disappear from the world (Beta
GZ) after some time, about a minute. Their instance number is still
valid (selectable) but they are gone. The only way to get them back on
stage is to select one of the bots with
rc = aw_instance_set(<instance number>)
and start from aw_enter(.World,0) to aw_state_changed() all over
again.
Strangely enough, this method sometimes gets all three bots back, even
if I only explicitely select one of them and bring it back.

The sequence i follow to create the bots is this one:

rc = aw_create("auth.activeworlds.com", 5670, Inst)
rc = aw_int_set(AW_LOGIN_OWNER, .LoginOwner)
rc = aw_string_set(AW_LOGIN_PRIVILEGE_PASSWORD, .PrivilegePassword)
rc = aw_string_set(AW_LOGIN_APPLICATION, ApplicationName)
rc = aw_string_set(AW_LOGIN_NAME, .Caption)
rc = aw_login()

rc = aw_enter(.World, 0)
rc = aw_int_set(AW_MY_X, .we)
rc = aw_int_set(AW_MY_Z, .ns)
rc = aw_int_set(AW_MY_Y, .Altitude)
rc = aw_int_set(AW_MY_YAW, .Rotation)
rc = aw_int_set(AW_MY_TYPE, .Avatar)
rc = aw_int_set(AW_MY_GESTURE, .Gesture)
rc = aw_state_change()
Call aw_say("Hi, I'm " & .Caption & ", a VB6.0 freak...")

2.
I cant seem toget char* aw_string (AW_ATTRIBUTE a) working in VB6. The
code I use
Public Declare Function aw_string Lib "aw.dll" (ByVal awAttribute As
AW_ATTRIBUTE) As String
is useless, although a similar syntax for aw_int() works ok. I think
it is because this is the only function retuning a string. Is there
any workaround? <wishfull thinking> Maybe having a function with no
return value that accepts a fixed length string as parameter, as in
Kernel's GetPrivateProfileString.

TIA. XelaG, agrigny at xs4all.nl

canopus

Nov 10, 1998, 3:02pm
When I read your previous message, I noticed you were having some of the
same problems I faced when converting the AWAPI from C to Object Pascal
for Delphi programmers. (Like the C use of 0 to mean nil.) I had never
actually tried to field multiple bot instances, so I wondered if that part
of the Delphi AWAPI would actually work, since it gave aw_create a third
parameter that is a Pointer to an untyped Pointer, and you said that in
VB, a simple variable parameter worked better. (Also that aw_instance_set
should be passed an untyped value.) I don't know if it is relevant, but I
did roughly the same program as the one you describe (based on the
multibot SDK document), and the three bot avatars appeared, said their
speeches, and then hung around until I finally pressed the Stop button to
aw_destroy each of them. Believe me, I don't know why the C version of
aw_create insists upon being passed the address of an untyped Pointer, but
at least it works. (In Pascal, you can't pass a nil into a parameter coded
as var {=ByRef} or const, so I had to declare the parameter as a Pointer
to an untyped Pointer.)

[View Quote] > I use vb6.0 and have managed to login 3 bots at a time, roughly
> following the greeter bot script (no greetings i'm afraid). I have 2
> questions at the moment. Can anyone help explaining these matter?.
>
> 1.
> Whether i log in 1 or more bots, they disappear from the world (Beta
> GZ) after some time, about a minute. Their instance number is still
> valid (selectable) but they are gone. The only way to get them back on
> stage is to select one of the bots with
> rc = aw_instance_set(<instance number>)
> and start from aw_enter(.World,0) to aw_state_changed() all over
> again.
> Strangely enough, this method sometimes gets all three bots back, even
> if I only explicitely select one of them and bring it back.
>
> The sequence i follow to create the bots is this one:
>
> rc = aw_create("auth.activeworlds.com", 5670, Inst)
> rc = aw_int_set(AW_LOGIN_OWNER, .LoginOwner)
> rc = aw_string_set(AW_LOGIN_PRIVILEGE_PASSWORD, .PrivilegePassword)
> rc = aw_string_set(AW_LOGIN_APPLICATION, ApplicationName)
> rc = aw_string_set(AW_LOGIN_NAME, .Caption)
> rc = aw_login()
>
> rc = aw_enter(.World, 0)
> rc = aw_int_set(AW_MY_X, .we)
> rc = aw_int_set(AW_MY_Z, .ns)
> rc = aw_int_set(AW_MY_Y, .Altitude)
> rc = aw_int_set(AW_MY_YAW, .Rotation)
> rc = aw_int_set(AW_MY_TYPE, .Avatar)
> rc = aw_int_set(AW_MY_GESTURE, .Gesture)
> rc = aw_state_change()
> Call aw_say("Hi, I'm " & .Caption & ", a VB6.0 freak...")
>
> 2.
> I cant seem toget char* aw_string (AW_ATTRIBUTE a) working in VB6. The
> code I use
> Public Declare Function aw_string Lib "aw.dll" (ByVal awAttribute As
> AW_ATTRIBUTE) As String
> is useless, although a similar syntax for aw_int() works ok. I think
> it is because this is the only function retuning a string. Is there
> any workaround? <wishfull thinking> Maybe having a function with no
> return value that accepts a fixed length string as parameter, as in
> Kernel's GetPrivateProfileString.
>
> TIA. XelaG, agrigny at xs4all.nl

walter knupe

Nov 10, 1998, 3:05pm
Xelag,

XelaG schrieb in Nachricht <36484701.31444845 at news.activeworlds.com>...
> I use vb6.0 and have managed to login 3 bots at a time, roughly
>following the greeter bot script (no greetings i'm afraid). I have 2
>questions at the moment. Can anyone help explaining these matter?.
>
>1.
>Whether i log in 1 or more bots, they disappear from the world (Beta
>GZ) after some time, about a minute. Their instance number is still
>valid (selectable) but they are gone.

I found my bots to dissappear if i don't call aw_wait anymore....

It happens in my C++ programm when i am debugging it and keeping it on hold
on a breakpoint.

so make sure you have some kind of mainloop that calls aw_init().... i do
this using a WM_TIMER and calling aw_wait(10); in there, about once a
second.

>2.
>I cant seem toget char* aw_string (AW_ATTRIBUTE a) working in VB6. The
>code I use
>Public Declare Function aw_string Lib "aw.dll" (ByVal awAttribute As
>AW_ATTRIBUTE) As String
>is useless, although a similar syntax for aw_int() works ok. I think
>it is because this is the only function retuning a string. Is there
>any workaround? <wishfull thinking> Maybe having a function with no
>return value that accepts a fixed length string as parameter, as in
>Kernel's GetPrivateProfileString.


i have no clue there since I am not into VB. but char * is a common
expressions for API functions as well i think.
For example, lstrcpy is a WIN32 function (exported from kernel32.dll) and it
returns a string pointer like that. So see if you can find a declaration for
that one and use it to create your proper aw_string prototype.

Walter

canopus

Nov 10, 1998, 5:46pm
In earlier versions of VB, you could get round VB's preference for VB
strings by providing a fixed-length string that was long enough to hold
whatever was returned by a C DLL function (Dim ReceiverString As String *
255, or ReceiverString = String(255,0)). VB would convert VB string
parameters to C strings if you declared them ByVal, but that only worked
for passing strings TO a C DLL, not for getting them FROM a C DLL. It was
up to you to find the ASCII Zero that C uses to mark the end of a returned
string. Don't know if this is still true.

Walter Knupe's idea about aw_wait is worth trying, as some callback events
seem to depend on it. But the Delphi version of the multibot program
worked without any mention of aw_wait (it just had a "repeat...until Stop"
loop).

[View Quote] > I use vb6.0 and have managed to login 3 bots at a time, roughly
> following the greeter bot script (no greetings i'm afraid). I have 2
> questions at the moment. Can anyone help explaining these matter?.
>
> 1.
> Whether i log in 1 or more bots, they disappear from the world (Beta
> GZ) after some time, about a minute. Their instance number is still
> valid (selectable) but they are gone. The only way to get them back on
> stage is to select one of the bots with
> rc = aw_instance_set(<instance number>)
> and start from aw_enter(.World,0) to aw_state_changed() all over
> again.
> Strangely enough, this method sometimes gets all three bots back, even
> if I only explicitely select one of them and bring it back.
>
> The sequence i follow to create the bots is this one:
>
> rc = aw_create("auth.activeworlds.com", 5670, Inst)
> rc = aw_int_set(AW_LOGIN_OWNER, .LoginOwner)
> rc = aw_string_set(AW_LOGIN_PRIVILEGE_PASSWORD, .PrivilegePassword)
> rc = aw_string_set(AW_LOGIN_APPLICATION, ApplicationName)
> rc = aw_string_set(AW_LOGIN_NAME, .Caption)
> rc = aw_login()
>
> rc = aw_enter(.World, 0)
> rc = aw_int_set(AW_MY_X, .we)
> rc = aw_int_set(AW_MY_Z, .ns)
> rc = aw_int_set(AW_MY_Y, .Altitude)
> rc = aw_int_set(AW_MY_YAW, .Rotation)
> rc = aw_int_set(AW_MY_TYPE, .Avatar)
> rc = aw_int_set(AW_MY_GESTURE, .Gesture)
> rc = aw_state_change()
> Call aw_say("Hi, I'm " & .Caption & ", a VB6.0 freak...")
>
> 2.
> I cant seem toget char* aw_string (AW_ATTRIBUTE a) working in VB6. The
> code I use
> Public Declare Function aw_string Lib "aw.dll" (ByVal awAttribute As
> AW_ATTRIBUTE) As String
> is useless, although a similar syntax for aw_int() works ok. I think
> it is because this is the only function retuning a string. Is there
> any workaround? <wishfull thinking> Maybe having a function with no
> return value that accepts a fixed length string as parameter, as in
> Kernel's GetPrivateProfileString.
>
> TIA. XelaG, agrigny at xs4all.nl

roland vilett

Nov 10, 1998, 10:01pm
Are you calling aw_wait() at all? You must call aw_wait() in order to
receive any events. Also, aw_wait() periodically sends heartbeats to the
servers so they know your bot is still alive. I assume the reason your bots
are vanishing is that you are not calling aw_wait(), so after about a minute
the world server gives up on your bots and disconnects them.

After setting up your bots, your program should spend the majority of its
time in a loop calling aw_wait(), as demonstrated in the sample programs.

-Roland

[View Quote]

canopus

Nov 10, 1998, 10:41pm
Yep, after about two and a half minutes of SDK inactivity, the server did
finally erase my three bots. (Watching them go through calisthenic routines one
after the other was worth the wait.) What if I don't use aw_wait and instead
give bot commands? Will the server erase them anyway? And how long is "-1"
milliseconds (in one of the examples)?

[View Quote] > Are you calling aw_wait() at all? You must call aw_wait() in order to
> receive any events. Also, aw_wait() periodically sends heartbeats to the
> servers so they know your bot is still alive. I assume the reason your bots
> are vanishing is that you are not calling aw_wait(), so after about a minute
> the world server gives up on your bots and disconnects them.
>
> After setting up your bots, your program should spend the majority of its
> time in a loop calling aw_wait(), as demonstrated in the sample programs.
>
> -Roland
>
[View Quote]

x@x.com (xelag)

Nov 11, 1998, 1:20am
No, I wasn't calling aw_wait. I don't use a loop as such, the windows
form just sits and waits for events to pour on it. I wrongly assumed
that since i cant get events from the server using VB6 anyway,
aw_wait() was unnecessary. Facter (Walter) first put me on the right
track: use a timer object instead of a loop, set the Timer.Interval to
1 second, and let the timer call aw_wait(10) i.e. for 10 milliseconds
every minute. Thanks for your explanation about how aw_wait() works.

On Tue, 10 Nov 1998 16:01:23 -0800, "Roland Vilett" <roland at lmi.net>
[View Quote] >Are you calling aw_wait() at all? You must call aw_wait() in order to
>receive any events. Also, aw_wait() periodically sends heartbeats to the
>servers so they know your bot is still alive. I assume the reason your bots
>are vanishing is that you are not calling aw_wait(), so after about a minute
>the world server gives up on your bots and disconnects them.
>
>After setting up your bots, your program should spend the majority of its
>time in a loop calling aw_wait(), as demonstrated in the sample programs.
>
>-Roland
>
[View Quote]

x@x.com (xelag)

Nov 11, 1998, 1:33am
On Tue, 10 Nov 1998 14:46:04 -0500, Canopus <aek2 at ix.netcom.com>
[View Quote] I sort of tried that trick today, i'll try it later again more
systematically. It didn't work.

Wat VB does fine is using a string of a sufficient length as an
argument to an api, for instance, GetPrivateProfileString uses that
method. Searching for ascii zero is unnecessary, VB shortens the
string to the right VB-length, so you can't use a constant which has
fixed length. What i don't yet know is if this also works for a
returned string. I've noticed awapi has AW_MAX_ATTRIBUTE_LENGTH =
255& which i declared Public Const. That didn't work. I'll retry
later.
>In earlier versions of VB, you could get round VB's preference for VB
>strings by providing a fixed-length string that was long enough to hold
>whatever was returned by a C DLL function (Dim ReceiverString As String *
>255, or ReceiverString = String(255,0)). VB would convert VB string
>parameters to C strings if you declared them ByVal, but that only worked
>for passing strings TO a C DLL, not for getting them FROM a C DLL. It was
>up to you to find the ASCII Zero that C uses to mark the end of a returned
>string. Don't know if this is still true.
>
>Walter Knupe's idea about aw_wait is worth trying, as some callback events
>seem to depend on it. But the Delphi version of the multibot program
>worked without any mention of aw_wait (it just had a "repeat...until Stop"
>loop).
See my thread to Roland about this.

Thanks for your answer.

>
[View Quote]

x@x.com (xelag)

Nov 11, 1998, 1:52am
Facter, thanks for your posting and the online help this afternoon.
Its stable now with 2 SDK bots, the 3rd one crashes the syten. (and I
had my 2 other Hambots there at the same time, I thought the limit was
3). Got the forward/ back/ sidewards/ up/ down and turning around
movements ready, sorted out the trigonometry this evening. Next:
climbing at an angle, random-walking and figure-skating! I can also
have him say through keyboard input, I'm working on the teleport
option now and trimming the GUI. Pity he can't interact.



On Tue, 10 Nov 1998 18:05:55 +0100, "Walter Knupe" <wak at faber.ping.de>
[View Quote] >Xelag,
>
>XelaG schrieb in Nachricht <36484701.31444845 at news.activeworlds.com>...
>
>I found my bots to dissappear if i don't call aw_wait anymore....
>
>It happens in my C++ programm when i am debugging it and keeping it on hold
>on a breakpoint.
>
>so make sure you have some kind of mainloop that calls aw_init().... i do
>this using a WM_TIMER and calling aw_wait(10); in there, about once a
>second.
>
>
>
>i have no clue there since I am not into VB. but char * is a common
>expressions for API functions as well i think.
>For example, lstrcpy is a WIN32 function (exported from kernel32.dll) and it
>returns a string pointer like that. So see if you can find a declaration for
>that one and use it to create your proper aw_string prototype.
>
>Walter
>
>

roland vilett

Nov 11, 1998, 3:08am
If you are using callbacks for all your methods (i.e. asynchronous mode)
then your app must call aw_wait() periodically or the heartbeats won't get
sent and your bots will get disconnected, but in this case of course you
must call aw_wait() anyway or your callbacks won't get called either.

In synchronous mode, any of the methods that can have a callback installed
(e.g. aw_query(), aw_object_add(), etc.) will do an implicit aw_wait() and
thus heartbeats will get sent. However most of the common API methods don't
have callbacks and thus will not call aw_wait() when you call them.

It's only dawning on me now that this wasn't made clear in the SDK docs.
I'll remedy that oversight as soon as possible...

Calling aw_wait() with any negative time value means "wait infinitely". In
other words,

aw_wait (-1);

is equivalent to

for (;;)
aw_wait (1000);

-Roland

[View Quote]

facter

Nov 11, 1998, 3:49am
> No, I wasn't calling aw_wait. I don't use a loop as such, the windows
> form just sits and waits for events to pour on it. I wrongly assumed
> that since i cant get events from the server using VB6 anyway,
> aw_wait() was unnecessary. Facter (Walter) first put me on the right

Me and Walt are different people Xela =))

Fac.

x@x.com (xelag)

Nov 11, 1998, 10:14am
Canopus, i made a mistake in my previous posting: windows does require
an ascii zero check,as you said, doesn't conveniently clip the string.
It's just that I use a constantly a routine that masks that fact...!
;o)

x@x.com (xelag)

Nov 11, 1998, 10:21am
Sorry for the confusion, both Walter and Facter, I haven't slept for
48 hours because of my deafbot. Walter (I forgot your aw- nickname),
you and your bot [Daniel] were very helpful to me yesterday, many
thanks.

On Wed, 11 Nov 1998 13:49:40 +0800, facter <facterinvurt at hotmail.com>
[View Quote] >
>
>
>Me and Walt are different people Xela =))
>
>Fac.

P.S. he is called [Daniel] your bot, Walter, or am I again mistaken?

P.P.S. and thanks to you, Fac, for your help a few days ago (or am I
again confused?). I'm going to bed!

x@x.com (xelag)

Nov 11, 1998, 10:25am
Thank you for your posting. I only hope we'll soon be able to use all
the aw.dll features in Visual Basic... XelaG.

walter knupe

Nov 12, 1998, 3:17pm
I am glad to help, but its Faber, not Facter...

Why to people confuse my nick all the time ? *grin*

Walter aka Faber on AW

XelaG schrieb in Nachricht <364b06f8.29019427 at news.activeworlds.com>...
>Facter, thanks for your posting and the online help this afternoon.
>Its stable now with 2 SDK bots, the 3rd one crashes the syten. (and I
>had my 2 other Hambots there at the same time, I thought the limit was
>3). Got the forward/ back/ sidewards/ up/ down and turning around
>movements ready, sorted out the trigonometry this evening. Next:
>climbing at an angle, random-walking and figure-skating! I can also
>have him say through keyboard input, I'm working on the teleport
>option now and trimming the GUI. Pity he can't interact.

walter knupe

Nov 12, 1998, 3:22pm
XelaG schrieb in Nachricht <364a7fb3.663103 at news.activeworlds.com>...
>Sorry for the confusion, both Walter and Facter, I haven't slept for
>48 hours because of my deafbot. Walter (I forgot your aw- nickname),
>you and your bot [Daniel] were very helpful to me yesterday, many
>thanks.

My nick name is Faber, (to add to the confusion :) )

>
>On Wed, 11 Nov 1998 13:49:40 +0800, facter <facterinvurt at hotmail.com>
[View Quote] in fact(er) *grin*

>
>P.S. he is called [Daniel] your bot, Walter, or am I again mistaken?


Yes, the first instance my bot is allways called [Daniel] in honor of R.
Daniel Oliwav, the famous Robot of Isaac Asimovs Robot Stories.

Walter aka Faber

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