[Laszlo-user] parseInt() anomaly

Cary Clark caclark at cox.net
Wed Sep 24 18:08:38 PDT 2008


Well, that'll teach me to post before Googling:
http://www.faqts.com/knowledge_base/view.phtml/aid/8108/fid/53 or any of 
the other 629,000 references to it....

It's the old assumed radix deal...

Cary Clark wrote:
> Anyone with an opinion on why
>
>    <handler name="oninit">
>        Debug.write( "testApp.lzx test 01:[" + parseInt("01") + "]" ) ;
>        Debug.write( "testApp.lzx test 02:[" + parseInt("02") + "]" ) ;
>        Debug.write( "testApp.lzx test 03:[" + parseInt("03") + "]" ) ;
>        Debug.write( "testApp.lzx test 04:[" + parseInt("04") + "]" ) ;
>        Debug.write( "testApp.lzx test 05:[" + parseInt("05") + "]" ) ;
>        Debug.write( "testApp.lzx test 06:[" + parseInt("06") + "]" ) ;
>        Debug.write( "testApp.lzx test 07:[" + parseInt("07") + "]" ) ;
>        Debug.write( "testApp.lzx test 08:[" + parseInt("08") + "]" ) ;
>        Debug.write( "testApp.lzx test 09:[" + parseInt("09") + "]" ) ;
>        Debug.write( "testApp.lzx test 10:[" + parseInt("10") + "]" ) ;
>    </handler>
>
> would show this in DHTML mode in both Firefox & IE:
> testApp.lzx test 01:[1]
> testApp.lzx test 02:[2]
> testApp.lzx test 03:[3]
> testApp.lzx test 04:[4]
> testApp.lzx test 05:[5]
> testApp.lzx test 06:[6]
> testApp.lzx test 07:[7]
> testApp.lzx test 08:[0]
> testApp.lzx test 09:[0]
> testApp.lzx test 10:[10]
>
> and this in Flash:
> testApp.lzx test 01:[1]
> testApp.lzx test 02:[2]
> testApp.lzx test 03:[3]
> testApp.lzx test 04:[4]
> testApp.lzx test 05:[5]
> testApp.lzx test 06:[6]
> testApp.lzx test 07:[7]
> testApp.lzx test 08:[8]
> testApp.lzx test 09:[9]
> testApp.lzx test 10:[10]
>
> Notice the values printed for 08 & 09 in each.
> I created this output using this code:
> =================================================
> <!DOCTYPE canvas SYSTEM "http://www.laszlosystems.com/lps/tools/lzx.dtd">
>
> <canvas>
>      <handler name="oninit">
>        Debug.write( "testApp.lzx test 01:[" + parseInt("01") + "]" ) ;
>        Debug.write( "testApp.lzx test 02:[" + parseInt("02") + "]" ) ;
>        Debug.write( "testApp.lzx test 03:[" + parseInt("03") + "]" ) ;
>        Debug.write( "testApp.lzx test 04:[" + parseInt("04") + "]" ) ;
>        Debug.write( "testApp.lzx test 05:[" + parseInt("05") + "]" ) ;
>        Debug.write( "testApp.lzx test 06:[" + parseInt("06") + "]" ) ;
>        Debug.write( "testApp.lzx test 07:[" + parseInt("07") + "]" ) ;
>        Debug.write( "testApp.lzx test 08:[" + parseInt("08") + "]" ) ;
>        Debug.write( "testApp.lzx test 09:[" + parseInt("09") + "]" ) ;
>        Debug.write( "testApp.lzx test 10:[" + parseInt("10") + "]" ) ;
>    </handler>
>
>              <view>
>        <text>Hello...</text>
>    </view>
> </canvas>
>
> =================================================
>
> I got onto this testing my real app which grabs the hours and minutes 
> from a time string in the form of HH:MM, parseInt()'ing the values to 
> int's and putting them into a Date object.  Doesn't seem to work so 
> well in DHTML.  The Flash script engine got it right.
>
> Cary
>


More information about the Laszlo-user mailing list