What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » including files

including files
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: including files
You don't need to include files. Any JS file you put in the script's directory will be loaded automatically.

So if first.js includes:
code:
var myVar = 'Hello World';
And if another file named another.js includes:
code:
Debug.Trace(myVar);
You will get the proper output: "Hello World"

--------

Then there is also the MsgPlus::LoadScriptFile function which loads an external script file (eg: a file in a subdirectory) directly into your current running script.

See the Plus! Scripting Documentation for more...

--------

But for changing language purposes I really really really suggest you to use variables. Using variables is in fact way more easy.

Also, the include() approach will simply not work for certain things and is in overall way too slugish. Using such an approach means that you actually will end up with a massive amount of files which all contain the very same script (just in another language). While the proper approach (with variables) is way shorter.

Even in other programming languages the include() approach is almost never (mis)used for translating purposes since that isn't what it is meant for. The purpose of include() is to seperate much used declarations and libraries and so that you can easly change that stuff later on without the need to mess in the code files. eg: declaring constants and variables, loading needed libraries (which contain other variables, functions, etc). But the fact that all JScript files in the current script's directory are already automatically loaded makes that you don't need this in Plus! scripting anyways. In PHP only the file you tell the compiler/interpreter to run is executed, other files aren't executed. So that's why it has an include function, so those other files are executed (aka included in the current executing code) too.

The approach of if(language=="english"){ var ... = "..."; } is not the best approach either though. Instead, store your translated lines in a data file and simply read in that data file and use like a kind of ID for each string you want to translate in the JScript code itself. This involves arrays, XML or INI or the registry, etc...

Good examples can be found on the forums and/or in various existing scripts.

--------

PS: seeing your questions lately, I really suggest to forget about PHP and trying to mimic all its functions. First skim (well, not skim, actually read :P) the official Plus! Scripting Documentation and first look at the code of some scripts for how things are done. Learning by example and documentation works wonders in this case. ;)

This post was edited on 05-08-2008 at 12:07 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
05-08-2008 11:52 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
including files - by Zeelia on 05-07-2008 at 11:14 PM
RE: including files - by CookieRevised on 05-08-2008 at 11:52 AM
RE: including files - by Zeelia on 05-08-2008 at 03:42 PM
RE: including files - by CookieRevised on 05-08-2008 at 04:37 PM
RE: including files - by Zeelia on 05-08-2008 at 05:30 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On