strange behavior

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

strange behavior

johnd
The following codes logs prints out NaN, but if I remove a non related
line of logging code then it prints out a number.  this behavior only
shows it self in build mode, in source mode everything works...

Anyone have any idea as to why taking out          
console.log("html1:"+html1);  would make the line above it
console.log('calc: '+v); print a number?  but leaving it in makes it say
NaN?

also, any idea why it works as source but not as a build?




qx.Class.define("tool_bar_demo.Application",
{
  extend : qx.application.Standalone,
        members :
  {
    main: function()
    {
      this.base(arguments);
var horiz =700
var vert = 700;
var col = 2;
var row = 2;
      var mainContainer = new qx.ui.container.Composite(new
qx.ui.layout.Basic());
        var foz=this.getRoot();
        var html1="";
        for (i=0;i<horiz;i+=horiz/col)
        {
                html1 +='<div style="position:absolute; top: 0; left:
'+i+'px; width: 2px; height: '
                +vert+'px; background: black;" ></div>\n';
}
        for (i=0;i<vert;i+=vert/row)
        {
                html1+='<div style=" position:absolute; top: '+i+'px;
left: 0px;  width: '
                +horiz+'px; height: 2px; background: black;" ></div>\n';
        }
        html1 +='<div style="position:absolute; top: 0; left:
'+horiz+'px; width: 2px; height: '
                +vert+'px; background: black;" ></div>\n';
        html1 +='<div style="position:absolute; top: '+vert+'px; left:
0px; height: 2px; width: '
                +vert+'px; background: black;" ></div>\n';

        for (v=1, cam=1;v<=row;v++)
        {
                for (h=1;h<=col;h++, cam++)
                {
                        html1 +='<div style="position:absolute; top:
'+Math.floor((v*(vert/row)-((vert/row)*.10)))
                        +'px; left: '
+Math.floor((h*(horiz/col)-((horiz/col)*.60)))
                        +'px;color: black; " >camera '+cam+'</div>\n';
console.log('calc: '+Math.floor((v*(vert/row)-((vert/row)*.10))));
console.log('calc: '+v);
                }

        }
         console.log("html1:"+html1);
      var embed1 = new qx.ui.embed.Html(html1);
      embed1.setWidth(horiz+2);
      embed1.setHeight(vert+2);
      mainContainer.add(embed1);

      // add the main container to the root
      this.getRoot().add(mainContainer);//, {left:20, top:20, right:20});
      this.getRoot().setBackgroundColor(null);
    }
}
});


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: strange behavior

Derrell Lipman
On Wed, Sep 10, 2008 at 5:52 PM, John de la Garza <[hidden email]> wrote:
The following codes logs prints out NaN, but if I remove a non related
line of logging code then it prints out a number.  this behavior only
shows it self in build mode, in source mode everything works...

Anyone have any idea as to why taking out
console.log("html1:"+html1);  would make the line above it
console.log('calc: '+v); print a number?  but leaving it in makes it say
NaN?

also, any idea why it works as source but not as a build?

I can not reproduce this problem (it never prints NaN in either case for me) but I highly suspect that the problem has to do with the fact that your variable 'v' is global.  You don't have a "var v" anyplace in your application.  See if changing this:

        for (v=1, cam=1;v<=row;v++)

to this:

      for (var v=1, cam=1;v<=row;v++)

improves things any.

(BTW, this also fixes global variable 'cam' but not global variable 'i' uses above.)

This could change between source and build versions because the build replaces variable names.  I would not expect global variables to be replaced, but that's at least a possible reason for your source/build differences.

Derrell


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel