Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

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

Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

Pascal Geuns
Hi,

I am getting confused here:

<?LassoScript
        Local:'test_array'=('10|20|30' -> (Split:'|'));
        // Convert elements to decimals so they can be used in calculations
        Iterate:#test_array, (Local:'item');
                # test_array -> (Get:(Loop_Count))=(Decimal:#item);
                Output:#test_array+'  ';
        /Iterate;
        Output:'Final Result:'+#test_array;
?>

In Lasso 8.1, on OSX 10.4.7 I get I would get

array: (10), (20), (30)  array: (10), (20), (30)  array: (10), (20),  
(30)  Final Result:array: (10), (20), (30)

but in Lasso 8.5.1 on OSX 10.4.7 I get

array: (10), (20), (30)  array: (10), (20), (30)  array: (10), (20),  
(30)  Final Result:array: (10), (20), ()

Notice that the last entry is () in the array, even so it was (30)  
inside the Iterate loop.

Am I doing something wrong or is this a bug in 8.5.1?

Kind Regards
Pascal

------------------------------------------------------------------------
-----
Save 50% on QualitySSL Certificates for a short time only
https://secure.qualityssl.com/en/order/crazysummer06.html
------------------------------------------------------------------------
-----




------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

James Harvard
Looks buggy to me. What do you get from #test_array->last->type at the end of your code?

BTW one of the main features of iterate is that it creates a reference to the items in the array, so that you can update the array contents directly. Therefore you shouldn't need ->(get:loop_count) in your code - you just do this sort of thing:

var: 'arr' = (array: 2,4,6,8);
iterate: $arr, (var:'i') ;
        $i = (decimal:$i);
        $i->(setformat: -precision=2);
/iterate;
$arr;

HTH,
James H

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

Pascal Geuns
> Looks buggy to me. What do you get from #test_array->last->type at  
> the end of your code?

I get null, what do you get?

> BTW one of the main features of iterate is that it creates a  
> reference to the items in the array, so that you can update the  
> array contents directly. Therefore you shouldn't need ->
> (get:loop_count) in your code - you just do this sort of thing:
>
> var: 'arr' = (array: 2,4,6,8);
> iterate: $arr, (var:'i') ;
> $i = (decimal:$i);
> $i->(setformat: -precision=2);
> /iterate;
> $arr;

Great, that I did not know until now, thanks James :-)

I applied the change to my code, but the result is still the same,  
guess I have to submit it as a bug ...

Kind Regards
Pascal

------------------------------------------------------------------------
-----
Save 50% on QualitySSL Certificates for a short time only
https://secure.qualityssl.com/en/order/crazysummer06.html
------------------------------------------------------------------------
-----


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

James Harvard
I see the same thing as you on 8.5.1. Definitely a bug, I think. It seems to be problem only with self-assignment when iterating through arrays. Here's a test case which you might like to include with your bug report.

Are you definitely using the latest version of 8.5.1? I can't be sure because I tested on a server running 8.5.1 that I don't administer, so not sure about exact versions (beta, final candidate or release).

James

<?LassoScript
var( 'arr1' = array(10,20,30), 'arr2' = array );
iterate( $arr1, var('i') );
        $arr2->insert( decimal($i)  );
        $i = decimal($i);
/Iterate;
$arr1;
'<br />';
$arr2;
?>

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

jasonhuck
Interesting that doing the same thing using ->foreach does not exhibit
the problem:

[//lasso
        // using this method, the last element is null
        var('a') = (:'10','20','30');

        iterate($a, local('i'));
                #i = decimal(#i);
        /iterate;

        $a;

        '<hr>';

        // using this method, it works as expected
        var('a') = (:'10','20','30');
       
        define_tag('convert', -req='in');
                #in = decimal(#in);
                return(true);
        /define_tag;
       
        $a->foreach(\convert)&;
]

- jason


--
Find and Share Free Lasso Custom Tags at tagSwap.net!
Download hundreds of open source Lasso custom tags, and post your own
for others to use. RSS feeds track the newest and most popular tags.
http://tagSwap.net/

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

James Harvard
Is this bug definitely present in the latest (i.e. release) version of 8.5.1?
James

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

jasonhuck
> Is this bug definitely present in the latest (i.e. release) version of 8.5.1?
> James

Yes, I tested on 8.5.1GM/Mac.




--
Find and Share Free Lasso Custom Tags at tagSwap.net!
Download hundreds of open source Lasso custom tags, and post your own
for others to use. RSS feeds track the newest and most popular tags.
http://tagSwap.net/

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

Pascal Geuns
In reply to this post by James Harvard
> Are you definitely using the latest version of 8.5.1? I can't be  
> sure because I tested on a server running 8.5.1 that I don't  
> administer, so not sure about exact versions (beta, final candidate  
> or release).

I use  Lasso 8.5.1 release verdion on an iBook g4 with 10.4.7

> <?LassoScript
> var( 'arr1' = array(10,20,30), 'arr2' = array );
> iterate( $arr1, var('i') );
> $arr2->insert( decimal($i)  );
> $i = decimal($i);
> /Iterate;
> $arr1;
> '<br />';
> $arr2;
> ?>

That gives me

array: (10), (20), ()
array: (10), (20), (30)

Kind Regards
Pascal

------------------------------------------------------------------------
-----
Save 50% on QualitySSL Certificates for a short time only
https://secure.qualityssl.com/en/order/crazysummer06.html
------------------------------------------------------------------------
-----




------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

m i l e s-5
Pascal,

If its any consolation.

Im using the same set up, powerbook G4 (my macbook is on order!)

and Im getting:

array: (10), (20), (30)
array: (10), (20), (30)
array: (10), (20), (30)
Final Result:array: (10), (20), ()

and that IS the GM of 8.5.1

M i l e s.

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

[Bug 8.5.1] iterate(array) when reassigning to array items

James Harvard
In reply to this post by Pascal Geuns
Thought I would post a more definitely titled warning about the bug that Pascal has identified, because it could break or alter functionality on a site that is updated to Lasso 8.5.1 without the problem being immediately obvious. (In many ways I think that's more dangerous than more obvious bugs that produce say crashes or syntax errors.)

The code that Jason posted is worth repeating as it contains both test case and workaround:

// using this method, the last element is null
var('a') = (:'10','20','30');
iterate($a, local('i'));
        #i = decimal(#i);
/iterate;
$a;

'<hr>';

// using this method, it works as expected
var('a') = (:'10','20','30');
define_tag('convert', -req='in');
        #in = decimal(#in);
        return(true);
/define_tag;
$a->foreach(\convert)&;

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

Bil Corry-3
In reply to this post by Pascal Geuns
Pascal Geuns wrote:
> <?LassoScript
>     Local:'test_array'=('10|20|30' -> (Split:'|'));
>     // Convert elements to decimals so they can be used in calculations
>     Iterate:#test_array, (Local:'item');
>         # test_array -> (Get:(Loop_Count))=(Decimal:#item);
>         Output:#test_array+'  ';
>     /Iterate;
>     Output:'Final Result:'+#test_array;
> ?>

It appears to be a problem with references.  For example, this works:

    Local:'test_array'=('10|20|30' -> (Split:'|'));
    // Convert elements to decimals so they can be used in calculations
    local:'item' = string; // add this
    Iterate:#test_array, (Local:'item');
        #item=(Decimal:#item); // change this
        Output:#test_array+'  ';
    /Iterate;
    Output:'Final Result:'+#test_array;

And so does this:

    Local:'test_array'=('10|20|30' -> (Split:'|'));
    // Convert elements to decimals so they can be used in calculations
    local:'temp' = string; // add this
    Iterate:#test_array, (Local:'item');
        #temp = (decimal:#item); // add this
        #test_array -> (Get:(Loop_Count))=#temp; // change this
        Output:#test_array+'  ';
    /Iterate;
    Output:'Final Result:'+#test_array;


- Bil


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Was I lucky or is it there a bug in Iterate concerning Lasso 8.5.1?

Ke Carlton

Hello All,

Yesterday, I upgraded a machine to 8.5.1 and experienced similar issues with
a heavy duty csv file import script (200k records).

Previously the script managed 2000 records every 4-6 seconds after upgrade
to 8.5.1 (from 8.5, OSX 10.4) it drop to 16 - 30 seconds and became very
unstable.

Here's a cut down version of the tag causing the crashes and slow down.

        define_tag('parseCSV2', -required='line');
                local:'temp' = line->(split:',');
                local('field' = string);
                iterate:#temp,#field;
                        #field->(removetrailing:'"');
                        #field->(removeleading:'"');
                        #field->trim;
                        #field = (encode_sql:#field);
                /iterate;
                return:#temp;
        /define_tag;


Debugging revealed that this worked ok:

        define_tag('parseCSV2', -required='line');
                local:'temp' = line->(split:',');
                local('field' = string, 'i' = null,'b'= 1,'row' = array );
                iterate:#temp,#field;
                        //#field->(removetrailing:'"');
                        //#field->(removeleading:'"');
                        //#field->trim;
                        #field = (encode_sql:#field);
                /iterate;
                return:#temp;
        /define_tag;


And that setting #temp to a string resolved the issue. Although I though
that this should not have made a difference as I thought that split: would
automatically convert each element of the array to a string.
 
        define_tag('parseCSV2', -required='line');
                local:'temp' = (string:#line)->(split:',');
                local('field' = string, 'i' = null,'b'= 1,'row' = array );
                iterate:#temp,#field;
                        #field->(removetrailing:'"');
                        #field->(removeleading:'"');
                        #field->trim;
                        #field = (encode_sql:#field);
                /iterate;
                return:#temp;
        /define_tag;



The script now runs at 2000 records every 6 - 7 seconds versus 4 - 6
seconds, which is manageable - but: still slower.

The original tag worked 100% in the original release of 8.5 - but not the
official 8.5.1. My concern is other elements of code throughout the system
that are affected by this. I tried unsuccessfully a few times yesterday to
downgrade to the original release of 8.5 so am stuck with 8.5.1 (which
*should* be a good thing).





















-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf
Of Bil Corry
Sent: 04 September 2006 17:23
To: [hidden email]
Subject: Re: Was I lucky or is it there a bug in Iterate concerning Lasso
8.5.1?

Pascal Geuns wrote:
> <?LassoScript
>     Local:'test_array'=('10|20|30' -> (Split:'|'));
>     // Convert elements to decimals so they can be used in calculations
>     Iterate:#test_array, (Local:'item');
>         # test_array -> (Get:(Loop_Count))=(Decimal:#item);
>         Output:#test_array+'  ';
>     /Iterate;
>     Output:'Final Result:'+#test_array;
> ?>

It appears to be a problem with references.  For example, this works:

    Local:'test_array'=('10|20|30' -> (Split:'|'));
    // Convert elements to decimals so they can be used in calculations
    local:'item' = string; // add this
    Iterate:#test_array, (Local:'item');
        #item=(Decimal:#item); // change this
        Output:#test_array+'  ';
    /Iterate;
    Output:'Final Result:'+#test_array;

And so does this:

    Local:'test_array'=('10|20|30' -> (Split:'|'));
    // Convert elements to decimals so they can be used in calculations
    local:'temp' = string; // add this
    Iterate:#test_array, (Local:'item');
        #temp = (decimal:#item); // add this
        #test_array -> (Get:(Loop_Count))=#temp; // change this
        Output:#test_array+'  ';
    /Iterate;
    Output:'Final Result:'+#test_array;


- Bil


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage