/******************************************************************************************
 * To add additional script to the scripting widget, create/upload a JavaScript file
 * to the 'scripts' folder. Open the scripting.html file in the editor by double clicking
 * the file in the Project view. Append the filename to the 'scripts' attribute in the
 * ti-widget-scripting element, separated each script filename by a comma.
 ******************************************************************************************/

const SCRIPT_START_MESSAGE = 'Script Started';
const SCRIPT_END_MESSAGE   = 'Script Ended';

/**
 * The entry point for the script, this function will be called when the user presses
 * the RUN button in the scripting widget. Any call to access the controller must be
 * initiated within this function.
 */
function main() {
    /*
     * To debug this script, open the debugger in the main application window that
     * spawned this window. For most browser, press F12 to enable debugging.
     *
     * The 'debugger' keyword is an inline breakpoint. Uncomment the following line to stop
     * the script at main when the debugger is opened.
     */
    // debugger

    /* Log to text file */
    // log(SCRIPT_START_MESSAGE);

    /* Read the myvar and toggle it */
    // let myVar = read('myVar');
    // write('myVar', myVar == 1 ? 0 : 1);

    /* Invoking an existing function or user defined function in the custom codec with the provided interface */
    // invoke('doSomething', [true], 'myInterface' /* interface parameter is optional, it is codec specific */);

    /* Log to text file */
    // log(SCRIPT_END_MESSAGE);
}