Can I embed javascript in my web page and run it as a CETerm script?

Version 1

    Verified Product Versions

    Wavelink Naurtech CETerm 5.7

    CETerm provides a complete JavaScript script engine for its emulation and Browser sessions. This is in addition to and seperate from the JavaScript engine which is part of the Web Browser.

     

    You cannot simply run Javascript embeded as part of the web page as a CETerm script. The CETerm script must be defined in the CETerm script engine to run in the CETerm. There are two ways to define the script in the CETerm script engine from a HTML web page.

     

    The following JavaScript in your web page will define the function printLabel() in the CETerm script engine. This definition will be *lost* when CETerm exits.

    WARNING: Note that you must escape all internal double-quotes in your script (e.g., \"1024\").

        var myscript = "function printLabel( printer,lblType, upc )"

                            + " { "

                            + "    var employeeNumber = \"1024\"; "

                            + .......   ;

     

        external.CETerm.RunScript( myscript );

    The following Javascript in your web page will configure a new script in CETerm and then load it into the CETerm script engine. This script will become part of the CETerm configuration and be available the next time CETerm is run.

    WARNING: This will load the script for the currently running instance of CETerm, but you must check "Load at Startup" setting for the corresponding script slot if you want the script to be loaded the next time you run CETerm. There is no SetProperty() command to alter this setting.

     

        var scriptNumber = 35;        // Pick an available slot

        var scriptSlot = "app.script." + scriptNumber;

        var myscript = "function printLabel( printer,lblType, upc )"

                            + " { "

                            + "    var employeeNumber = \"1024\"; "

                            + ....... ;

     

       // Save the script in an internal CETerm slot

        external.CETerm.SetProperty( scriptSlot, myscript );

     

        // Load the script in the CETerm engine

        external.CETerm.PostIDA( "IDA_SCRIPT_" + scriptNumber, 0 );