Shoutbox

init script in a folder - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: init script in a folder (/showthread.php?tid=83561)

init script in a folder by Suxsem on 05-06-2008 at 01:51 PM

Hi!
Look:

ScriptFolder > firstScript.js
ScriptFolder > secondScript.js

firstScript:

code:
secondScript_init()

ALL OK!
but...if i have a second script in another folder...

ScriptFolder > firstScript.js
ScriptFolder > folder > secondScript.js

firstScript:
code:
???

What is the code to initialize a script in a folder?
thank, bye!
RE: init script in a folder by mynetx on 05-06-2008 at 02:06 PM

Please try to find such solutions in the Official Scripting Documentation next time, before asking. :)

Objects Reference > MsgPlus Object > MsgPlus::LoadScriptFile

quote:
Originally posted by Official Scripting Documentation
The MsgPlus::LoadScriptFile function loads additional JScript code into your running script. The whole content of the file is parsed and immediately placed in a running state (newly defined functions can be executed from anywhere in your script and lines belonging to the global scope are executed).
Syntax

    [boolean] LoadScriptFile(
        [string] ScriptFile
    );

Parameters

ScriptFile
    [string] Name of the JScript file to be loaded. It is recommended to use Unicode text files. The path is relative to the script's directory by default, to override this behavior, prefix the path with "\". Example: "\C:\directory\script.js".

Return Value

A boolean value specifying if the code was parsed and run successfully.
Remarks

The use of this function should be weighted carefully. For clarity reasons, all the files of your script should be loaded when the script is started. This function is only meant to be used if parts of your script are optional or don't require to be started immediately. Remember that all the files with a .js extension placed in your main script's directory are always automatically loaded before the script is started.

For security reasons, never use this function to run code you dynamically downloaded from the internet.
Function Information
Object     MsgPlus
Availability     Messenger Plus! Live 4.50
See Also

MsgPlus Object.

RE: init script in a folder by Suxsem on 05-06-2008 at 02:12 PM

scuse me...thank!


RE: init script in a folder by Suxsem on 05-06-2008 at 02:42 PM

ok...but...
how do you Uninitialize the secondScript by firstScript?


RE: init script in a folder by Matti on 05-06-2008 at 04:08 PM

What do you mean with uninitializing the second script?

Most of the times, there's no need to use MsgPlus.LoadScriptFile() for such simple tasks. You can make a function in the second script which starts everything it should do, and make another function which wipes out everything when it's done. Then, your first script controls when it should call those functions. It really doesn't matter if those functions are loaded on script start-up, as long as they aren't called yet.

I don't see why you'd have to start and stop the script that way, do you really have such complex things in the global scope of your second script which can't be started from a simple function? :S

(And no, you can't unload a loaded script file.)