Page 1 of 1 1
Topic Options
#41391 - 2003-06-11 04:48 PM IDispatch pointers
Duke Offline
Fresh Scripter

Registered: 2003-06-10
Posts: 6
As part of my login script, Merlin will announce any planned network outages. If I run the Merlin script by itself, it runs great. When I put it in the login script (which requires Function Merlin() and Endfunction) I get the message "IDispatch pointers not allowed in expressions. What's the problem!?
Top
#41392 - 2003-06-11 05:01 PM Re: IDispatch pointers
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Can you post the portion of the script that is giving you problems?

Likely are performing a function on the object that isn't supported. Certain functions will fail on COM objects, like...

code:
If LEN($Merlin) = 0
...blah
EndIf


Top
#41393 - 2003-06-11 05:09 PM Re: IDispatch pointers
Duke Offline
Fresh Scripter

Registered: 2003-06-10
Posts: 6
Function Merlin()
break On
; If InGroup("Testgroup")
$merlin_path = "%windir%\msagent\chars\merlin.acs"
$agent = createobject ("agent.control.2")
$agent.connected = "1"
$= $agent.characters.load("merlin","$merlin_path")
$merlin = $agent.characters.character("merlin")
$= $merlin.moveto(400,200)
$= $merlin.show()
$wait = $merlin.play("announce" )
do sleep 1 until $merlin.wait($wait) <> 0
$wait = $merlin.speak("Hello! You are part of a test group using the new login scripts." )
$wait = $merlin.speak("If I had anything important to say, I would have told you here." )
do sleep 3 until $merlin.wait($wait) <> 0

; Endif
EndFunction

This code works fine as stand-alone and without Function Merlin() and Endfunction.

Top
#41394 - 2003-06-11 05:10 PM Re: IDispatch pointers
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
IIRC, Shawn did some work with Merlin..

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#41395 - 2003-06-11 05:35 PM Re: IDispatch pointers
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Yeah sure did, Merlin is a great guy to work with ... has this habit of disappearing from the office though ... kinda like myself ... Merlin keeps telling us he's "working from the castle" ... ja, right !

Check to make sure the merlin object is being created properly, might want to stick an @ERROR after this line, like this:

$merlin = $agent.characters.character("merlin")
?@SERROR

-Shawn [Wink]

[ 11. June 2003, 17:37: Message edited by: Shawn ]

Top
#41396 - 2003-06-11 05:46 PM Re: IDispatch pointers
Duke Offline
Fresh Scripter

Registered: 2003-06-10
Posts: 6
I put the ?@serror after each line and got a "completed successfully" on each one. I then put it after the call for Merlin() and it didn't give a response. It's like it doesn't return to where it's suppose to. My code is set up like:

fun1()
fun2()
Merlin()
fun3()
Exit

And all the functions are below. It never runs fun3()

And Thanks for replying so quickly!

Top
#41397 - 2003-06-11 05:54 PM Re: IDispatch pointers
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
weird, so if you put a tracer just before the EndFunction in Merlin(), and then another tracer in the mainline after the Merlin() call, you never see that second tracer ?

I would carefully examine your ENITRE script, including those other functions, and look for missing EndFunctions or especially, missing ENDIF's and whatnot, mmake sure everything is closed-off.

-Shawn

Top
#41398 - 2003-06-11 06:08 PM Re: IDispatch pointers
Duke Offline
Fresh Scripter

Registered: 2003-06-10
Posts: 6
I've created a new script.

merlin()
Exit
Function merlin()
break On
$merlin_path = "%windir%\msagent\chars\merlin.acs"
$agent = createobject ("agent.control.2")
$agent.connected = "1"
$= $agent.characters.load("merlin","$merlin_path")
$merlin = $agent.characters.character("merlin")
$= $merlin.moveto(400,200)
$= $merlin.show()
$wait = $merlin.play("Announce" )
do sleep 1 until $merlin.wait($wait) <> 0
$wait = $merlin.speak("What the?" )
do sleep 3 until $merlin.wait($wait) <> 0
?"script done..."
EndFunction

This script is giving the same error.
If I remove the function and endfunction and call this script from the login, it works. I was just hoping to keep it all in one script so that I can encrypt it so it doesn't get tampered.

Top
#41399 - 2003-06-11 06:11 PM Re: IDispatch pointers
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
oh crap, i know what it is ...

Try renaming your Merlin function to something else, like

Function ShowMerlin()

then calling it with the new name ...

-Shawn

Top
#41400 - 2003-06-11 06:18 PM Re: IDispatch pointers
Duke Offline
Fresh Scripter

Registered: 2003-06-10
Posts: 6
That was it!!! My hat's off (and showing the bald spot where I pulled my hair out) to you!
Top
#41401 - 2003-06-11 06:24 PM Re: IDispatch pointers
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
You might be asking why this happened ? Inside a UDF, there is a special $variable that is reserved for returning a value from that function, the variable is $+Functioname so for the merlin function, one would use $merlin as the special variable name. Well, in the code posted above, $merlin was being used to contain the merlin object.

By the same token, sometimes this feature can be very usefull, and actually not too sure why it was mis-behaving in your case. You were simply using $merlin to host the object, which is cool. But I figured that this wasn't you original intent anyways ...

-Shawn

Top
#41402 - 2003-06-11 06:43 PM Re: IDispatch pointers
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ok, it was mis-behaving because the function Merlin() was returning an object, and objects can't be used in an expression by itself, so i would guess that if you reset your script to the way it was, and call the merlin function like this:

$= Merlin()

That it would probably work ok ...

-Shawn

Top
#41403 - 2003-06-11 07:34 PM Re: IDispatch pointers
Duke Offline
Fresh Scripter

Registered: 2003-06-10
Posts: 6
It's working now and I couldn't be happier! Thanks again
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1607 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.065 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org