Open
Script function

world.Open

DOC_scripting Read about scripting

Type

Method

Summary

Opens a named document

Prototype

IDispatch* Open(BSTR FileName);

DOC_data_types View list of data type meanings


Description

Returns an object which can be used to refer to the new document.

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.

Better still, use "world.world.GetWorldById (id)" which uses each world's unique ID, in case you have multiple worlds of the same name.

You can use Open to open either a MUSHclient world (ie. a MCL file) or a text file (ie. a TXT file).

If the named document is already open then "open" does *not* open another copy, rather it activates that document (brings it to the front).



VBscript example

dim otherworld

  set otherworld = world.open  ("smaug.mcl")

  if not (otherworld is nothing) then
    otherworld.send "say hello everyone" 
  end if



Jscript example

var otherworld

   otherworld = world.Open ("smaug.mcl");

  if (otherworld != null)
   otherworld.send("say hi there everyone");



PerlScript example

my $otherworld;

 $otherworld = $world->Open ("smaug.mcl");

  if (!defined ($otherworld))
    { 
   $otherworld->send("say hi there everyone");
    }



Python example

var otherworld

   otherworld = world.Open ("smaug.mcl")

  if (otherworld != null)
   otherworld.send("say hi there everyone")



Lua example

-- not implemented for Lua



Lua notes

Lua is not implemented using the COM model, and thus opening a file and getting an object reference is not possible.

This function, if called, always returns nil.



Return value

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 ...

Topics

DOC_scripting Scripting
DOC_world World functions

Functions

FNC_Activate Activate (Activates the world window)
FNC_GetWorld GetWorld (Gets an object reference to the named world)
FNC_GetWorldById GetWorldById (Gets an object reference to the world given its unique ID)
FNC_GetWorldIdList GetWorldIdList (Gets the list of open worlds - returning their world IDs)
FNC_GetWorldList GetWorldList (Gets the list of open worlds - returning their world names)
FNC_OpenBrowser OpenBrowser (Opens a supplied URL in your default web browser)

(Help topic: function=Open)

DOC_contents Documentation contents page