Liquid UI - WS Reference Library

usejs()


Purpose

To include a JavaScript or a file within a script in Web Server.

The usejs() command is used to include a Javascript or a file within a script in WS Web Server. The usejs() command functions similar to the usecss() command and is placed in the same config.sjs configuration file.


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 'Hello World', then include the following 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 should 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:

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("C:\ScriptFiles\TestFunction.js");

For files present 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 directory. If the file is present in a different directory, then it is necessary to include the full path to the file, as shown:

usejs("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.