Vbasic Scripting, creating entities and loading them elsewhere in plugin

Posted by MattMc on Wed 26 Jan 2005 09:50 PM — 8 posts, 38,866 views.

USA #0
Howdy, here's an example of some code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient [
<!ENTITY path "C:\Program Files\folder\program.exe" >
]>
[skipping standard stuff, alias, triggers, and timers..]

<script>
<![CDATA[
sub ShowPath (a,b,c)
dim path
path = GetEntity("path")
world.note path
end sub

This is a cut-dry version of the code I'm using, so ignore the simplicity. The problem is that the world.note sends a blank line - Why doesn't GetEntity respect the definition above?


Matt
USA #1
There's a much easier way to do it by simply exiting the CDATA block briefly instead of using GetEntity. Excuse any errors in the code, this is quick and dirty.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient [
<!ENTITY path "C:\Program Files\folder\program.exe" >
]>

...

<script>
<![CDATA[
sub ShowPath (a,b,c)
dim path
]]>

path = &path;

<![CDATA[
world.note path
end sub
...

Hope that helps.
USA #2
Why dont you just note &path; and skip the variable all together?

GetEntity is designed for server entities (as in MXP), not plugin entities.
So it returns the empty string (since no entity by that name is found) and thus a blank line is noted.

As of next version (3.66) you'll be able to set server entities using SetEntity, but that still isn't relevant here.
Amended on Thu 27 Jan 2005 04:55 AM by Flannel
Greece #3
I don't think &path works inside the CDATA block though...
USA #4
Yes, you have to exit the CDATA block. Just wondering, GetEntity is VB, neh? Not MC, because I don't see world.GetEntity. Is that a valid VB call then, and if so, what does it do?
USA #5
No, GetEntity is not a VB function (at least not according to the script docs).

Mushclient doesn't need 'world.' for everything, only execute (because that IS a VBScript command), everything else it just assumes (as of... well, whatever version).
USA #6
Heh, the part about not needing to use world.'' was news to me!
Australia Forum Administrator #7
See:


http://www.gammon.com.au/scripts/doc.php?function=GetEntity


However the answers above are correct, this is a server entity. For entities you yourself define you need to leave the CDATA block.