XWidgetSoft Forum

BUG: Tabbed or indented functions not recognised
Page 1 of 1

Author:  yereverluvinuncleber [ 2017年 Sep 5日 06:31 ]
Post subject:  BUG: Tabbed or indented functions not recognised

Functions can exist within other functions within javascript. Code is typically structured so that it is 'tabbed' or indented to show its relationship to the parent function. This is perfectly valid in normal code and the indentation helps to show the function is solely operative within the context of the parent function. However, in Xwidget some functions are not recognised as being valid when indented or tabbed in code.

It specifically applies to Xwidget's own functions, note the following function is tabbed to the right and has 5 spaces prior to the function declaration.:

     function BottomHelpOnMouseDown(Sender,Button,Shift,X,Y)
           if (preferencesSoundPref.text === "enable") {
           TopHelp.opacity = 0;
           BottomHelp.opacity = 0;

These non-standard Xwidget function definitions (those created automatically with the Xwidget IDE, typically identified with the extra Sender,Button,Shift,X,Y variable information passed to the function), the function declaration must be at column position 1 for the IDE to know the function exists and to recognise it in your program. If they are indented the engine does not recognise them.

The effect of this bug is that if you have tabbed or indented onEvent functions based solely within other functions, after you convert your standard javascript code to Xwidget these type of functions may no longer be accessible. You will have to untab them and restore their position to column 1.

However, do note this does not apply to standard jscript functions as shown here:

          function getListing(path) {
                        pathString = getFileList(path,validTypes,false);
                        // convert to array
                        var paths = pathString.split('|');
                        for(var i = 0; i < paths.length; i++)

The above indented function is valid for both jscript and Xwidgets, only the indented Xwidget function is not recognised. That is the bug that needs to be fixed.

Author:  yereverluvinuncleber [ 2017年 Sep 5日 08:12 ]
Post subject:  Re: BUG: Tabbed or indented functions not recognised

Jim, please feel free to test but I suspect you'd rather not. Just take my word for it that this is a bug and enter it into the list please.

Basically, indenting some code should not stop it being recognised.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group