|
Messenger Plus! Live - Scripting Documentation
Getting StartedYour First ScriptCreating a new script is easy, even for a non-developer. All you have to do is go to the Scripts section in the Preferences and click on "Create New". The script's name will be used to create the new directory for the script as well as the first JScript file. Nothing else will be created as nothing else is necessary. So, start by creating a new script called "My First Script", click on "Create New", enter the name of the script and press OK. The file will be created, the new script automatically enabled and the editor window will popup with the following code: 创建一个新的脚本是很容易,即使是一个非开发人员。所有你必须
Two empty functions are automatically added to every new script: OnEvent_Initialize and OnEvent_Uninitialize. These functions are event handlers known by Messenger Plus!, they are called in your script automatically when a specific event occurs. Those two are called when your script is started and when it's ended. They both have one parameter, specifying when the script was launched or stopped (you can check the documentation of these events later on for more information). 两个空洞的职能是自动添加到每一个新的脚本: If the Script Debugging window is not visible, open it now (Plus! menu, check "Show Script Debugging". If you don't have this menu, please read Scripting Environment). Make sure the combo box in the Script Debugging window is set on "My First Script" then, in the editor window, click on "Save All" and "OK" for the confirmation message. Back in the Script Debugging window you'll notice the following entries: 如果脚本调试窗口是不可见,打开它,现在(的<font color="#808080">加! < /字体>
Each time a script file is modified and saved, the script has to be stopped and restarted to apply the changes. Clicking on "Save All" stops the script, saves the files and displays a confirmation message. When the confirmation message is dismissed, the script is restarted, JScript files are loaded and if no major syntax error is detected, the "Script is now loaded and ready" message is displayed in the debugging window. Global variables and function calls are immediately executed during the loading procedure (your new script does not have any). 每一次一个脚本文件是修改和保存,脚本已被停止 The first thing Messenger Plus! does once a script has been loaded is to call the OnEvent_Initialize function, if it exists. When an event is called, it is automatically mentioned in the debugging window. Depending on the kind of event your script is handling, it can be preferable to disable this behavior to avoid getting too many useless traces. To do so, click on the "Debug" menu of the script debugging window and uncheck "Trace Event Calls". The debugging window is the best place for developers to output diagnostic messages to keep track of what's going on in their scripts. Scripts that produce little or no diagnostic text at all are generally harder to debug, that's why you should always remember to send some kind of diagnostic information based on where you are in the script, variables that you are using, etc... 第一件事,Messenger Plus!是否一旦脚本已经加载是呼吁 Because JScript alone wouldn't be enough to create scripts that interact well with Messenger, the Messenger Plus! Live scripting system comes with over 100 functions and properties as well as nearly 50 events, all specifically designed for your Messenger needs. Functions and properties are organized into two kinds of objects: global objects and instantiated objects. 因为JScript的单是不足够的创建脚本互动
Let's start with the this famous international example of what a good program should say to its creator when emerging from the cyber-void. Simply replace the empty OnEvent_Initialize function of your new script by this one:
Click on "Save All", dismiss the confirmation message and take a look as the debugging window. The last entry will say "Hello World!". That's because the OnEvent_Initialize function, which is called when the script starts, now calls the Trace function from the Debug object. If you look as the documentation for Trace, you'll see that it takes a single string parameter which is the text that's sent to the debugging window. You can experiment adding calls to Debug.Trace in OnEvent_Uninitialize, you'll see that they are executed when you click on "Save All", before dismissing the confirmation message (because the script has been stopped which triggered the Uninitialize event). Of course, a script that just says hi to its developer is not very useful to a |