Name GetWorld
Type Method
Summary Gets an object reference to the named world
Prototype IDispatch* GetWorld(BSTR WorldName);
Description Returns an object which can be used to refer to another world.

You should be very cautious about storing the object reference of the world in a global variable, because if the world is closed then that reference becomes invalid, which will very likely lead to an access violation (program crash). You are better off using "world.getworld (name)" every time you need to get a reference to the world, and checking if it "is nothing" as in the example.

You could use a small variation on the examples above to write your own "send to all worlds" or something similar.
VBscript example
' --------------------------------------------------
' Example showing sending a message to another world
' --------------------------------------------------

sub SendToWorld (name, message)
dim otherworld

  set otherworld = world.getworld (name)

  if otherworld is nothing then
    world.note "World " + name + " is not open"
    exit sub
  end if

  otherworld.send message

end sub
Jscript example
// --------------------------------------------------
// Example showing sending a message to another world
// --------------------------------------------------

function SendToWorld (name, message)
{
 var otherworld

   otherworld = world.getworld (name);

  if (otherworld == null)
    {
    world.note("World " + name + " is not open");
    return;
    }

  otherworld.send(message);

}

SendToWorld ("MyOtherWorld", "say Hi there");
PerlScript example
# --------------------------------------------------
# Example showing sending a message to another world
# --------------------------------------------------

sub SendToWorld {
 my ($name, $message) = @_;

 my $otherworld;

 $otherworld = $world->getworld ($name);

  if (!defined ($otherworld))
    {
    $world->note("World " . $name . " is not open");
    return;
    }

  $otherworld->send($message);

}

SendToWorld ("MyOtherWorld", "say Hi there");
Returns An object reference to the named world, if it was found.
Otherwise NULL.

In Vbscript use the test "is nothing" to see if the reference is to a valid world.
In JavaScript use the test "== null" to see if the reference is to a valid world.
In PerlScript use the test "defined ()" to see if the reference is to a valid world.

See also ...