usejs

Including JavaScript or a file within a script in Web Server.

The usejs command is utilized to include Javascript or a file within a script in WS Web Server. Usejs functions very similarly to the usecss command and is placed in the same config.sjs configuration file as well. The syntax is as follows:

We will explain these three commands in the following sections of this document.

Options

The usejs command does not take any options.

Including a script

The string in the command could include a number of parameters or possibly a short script that would then be incorporated into the WS script. For example, if a user wanted to include code to print out 'Hello World', the following would need to be included in the config.sjs configuration file in the C:\Program Files\Synactive Inc\GuiXTFuzion\ directory.

usejs("println('Hello, World')");

The body of the action to be performed will be included within the double-quotes. In this case, the included line is for a simple 'println' operation. However, this string could be more complex as well.

Including a file

You can also call a separate Webscript function or even a complete script from an external file. To do this, the syntax would be as follows:

usejs("filename");

For example, if you want to include a script or function that would be housed externally in the file C:\ExternalScripts\TestFunction.js, you must also include the following code in the config.sjs configuration file:

usejs("TestFunction.js");

For files housed in the same directory as the scripts, you do not need to include the true or absolute path - the code can find the relevant file as long as it is in the same directly. If the file is housed in a different directory, then it would be necessary to include the full path to the file, as in the following example:

usejs("C:\ScriptFiles\TestFunction.js");

This file can contain any content from a single function to a complete script. Once called, the file will run, and then the remainder of the original code will continue from the point where the file left off.