Found_count and conditional statements in lasso 9

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

Found_count and conditional statements in lasso 9

XL Cordemans
Progressed quite well in the migration from Lasso 8.6 to 9.x, with sometimes a stumbling block.
One of them being the use of found_count in a conditional [if( )] [/if] statement. (I still prefer to use the simple use of square brackets, old habits die hard)
(am using lasso 9.3.x on an  El Capitan Server)

This is the issue: when to use ==, or =, when to use  '...',  or noneThe legacy code I re-wrote was as such 
    [inline (-search database etc ... )]
        [if( found_count == '1' )]
            do this this or  do that        [/if]

    [/inline]
It worked fine. Then out of the blue it did not work anymore , unless I removed the ' ' :
        [if( found_count == 1 )]
            do this this or  do that        [/if]

So I am wondering if there have been a replacement or changes in lasso 9.x for these logics, which I quite like.








#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Found_count and conditional statements in lasso 9

Jolle Carlestam-2
11 aug. 2016 kl. 01:24 skrev XL Cordemans <[hidden email]>:

>
> Progressed quite well in the migration from Lasso 8.6 to 9.x, with sometimes a stumbling block.
> One of them being the use of found_count in a conditional [if( )] [/if] statement. (I still prefer to use the simple use of square brackets, old habits die hard)
> (am using lasso 9.3.x on an  El Capitan Server)
>
> This is the issue: when to use ==, or =, when to use  '...',  or noneThe legacy code I re-wrote was as such
>     [inline (-search database etc ... )]
>         [if( found_count == '1' )]
>             do this this or  do that        [/if]
>
>     [/inline]
> It worked fine. Then out of the blue it did not work anymore , unless I removed the ' ' :
>         [if( found_count == 1 )]
>             do this this or  do that        [/if]
>
> So I am wondering if there have been a replacement or changes in lasso 9.x for these logics, which I quite like.

Lasso 9 is stricter in its parsing of your code. And that is a good thing.
Found_count is by nature an integer. If you want to match that in a conditional you of course have to match it with another integer, not a string. The bug accepting your old code was in Lasso 8, not in Lasso 9.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Fw: Found_count and conditional statements in lasso 9

XL Cordemans
noted your observation - but as I am not specialist would it be possible to illustrate this explantion more by way of an example?
I understand that found_count is an integer and "1" is another integer too. Actually the number of found_count records returned in a search of a database will most likely be an integer anyway, is it not? 



     
----- Forwarded Message -----
 From: Jolle Carlestam <[hidden email]>
 To: [hidden email]
 Sent: Thursday, August 11, 2016 5:06 AM
 Subject: Re: Found_count and conditional statements in lasso 9
   
11 aug. 2016 kl. 01:24 skrev XL Cordemans <[hidden email]>:

>
> Progressed quite well in the migration from Lasso 8.6 to 9.x, with sometimes a stumbling block.
> One of them being the use of found_count in a conditional [if( )] [/if] statement. (I still prefer to use the simple use of square brackets, old habits die hard)
> (am using lasso 9.3.x on an  El Capitan Server)
>
> This is the issue: when to use ==, or =, when to use  '...',  or noneThe legacy code I re-wrote was as such
>    [inline (-search database etc ... )]
>        [if( found_count == '1' )]
>            do this this or  do that        [/if]
>
>    [/inline]
> It worked fine. Then out of the blue it did not work anymore , unless I removed the ' ' :
>        [if( found_count == 1 )]
>            do this this or  do that        [/if]
>
> So I am wondering if there have been a replacement or changes in lasso 9.x for these logics, which I quite like.

Lasso 9 is stricter in its parsing of your code. And that is a good thing.
Found_count is by nature an integer. If you want to match that in a conditional you of course have to match it with another integer, not a string. The bug accepting your old code was in Lasso 8, not in Lasso 9.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>


 

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Fw: Found_count and conditional statements in lasso 9

stevepiercy
Put this into a file and load it on your Lasso 9 server:

<?lasso

1 -> type
'<br>'
'1' -> type
'<br>'
1 == '1'

?>

=>
integer
string
false

Explanation: Lasso 9 compares the value *and type* of the
objects being compared, whereas Lasso 8 didn't do such a good job.

There are several other differences to be aware of, including
the two biggest stinkers:

* NULL and '' (empty string) comparisons when pulling data from
an SQL datasource.
* when replacing action_param with web_request -> param,
comparisons of '' and void.

--steve


On 8/11/16 at 6:54 AM, [hidden email] (XL Cordemans) pronounced:

>noted your observation - but as I am not specialist would it be
>possible to illustrate this explantion more by way of an example?
>I understand that found_count is an integer and "1" is another
>integer too. Actually the number of found_count records
>returned in a search of a database will most likely be an
>integer anyway, is it not? 
>
>
>
>
>----- Forwarded Message -----
>From: Jolle Carlestam <[hidden email]>
>To: [hidden email] Sent: Thursday, August 11, 2016
>5:06 AM
>Subject: Re: Found_count and conditional statements in lasso 9
>
>11 aug. 2016 kl. 01:24 skrev XL Cordemans <[hidden email]>:
>>
>>Progressed quite well in the migration from Lasso 8.6 to 9.x, with sometimes a stumbling
>block.
>>One of them being the use of found_count in a conditional [if( )] [/if] statement. (I
>still prefer to use the simple use of square brackets, old habits die hard)
>>(am using lasso 9.3.x on an  El Capitan Server)
>>
>>This is the issue: when to use ==, or =, when to use  '...',  or noneThe legacy code I
>re-wrote was as such
>>    [inline (-search database etc ... )]
>>        [if( found_count == '1' )]
>>            do this this or  do that        [/if]
>>
>>    [/inline]
>>It worked fine. Then out of the blue it did not work anymore , unless I removed the ' '
>:
>>        [if( found_count == 1 )]
>>            do this this or  do that        [/if]
>>
>>So I am wondering if there have been a replacement or changes in lasso 9.x for these
>logics, which I quite like.
>
>Lasso 9 is stricter in its parsing of your code. And that is a
>good thing. Found_count is by nature an integer. If you want to
>match that in a conditional you of course have to match it with
>another integer, not a string. The bug accepting your old code
>was in Lasso 8, not in Lasso 9.
>
>HDB
>Jolle
>
>#############################################################
>
>This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>
>
>
>
>
>#############################################################
>
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.stevepiercy.com/>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Fw: Found_count and conditional statements in lasso 9

Jolle Carlestam-2
In reply to this post by XL Cordemans


2016-08-11 08:54 skrev XL Cordemans:
> noted your observation - but as I am not specialist would it be
> possible to illustrate this explantion more by way of an example?
> I understand that found_count is an integer and "1" is another integer
> too. Actually the number of found_count records returned in a search
> of a database will most likely be an integer anyway, is it not? 

Sure. Here's the non-specialist expansion.

"1" or '1' is NOT integers. They are constants of the type string.
Treated the same as "A" or 'A'. It is simply a character, in this case a
digit, in a string object.

1 on the other hand is an integer.
1.0 is a decimal.
Note the lack of quote marks.

When it comes to comparing values Lasso is fairly picky with type of
object it is comparing.
'1' will not equal 1 since one of the values is a string and the other
an integer.

Taking care of ensuring that you have the right sort of type for your
objects is your responsibility in most cases. If you want '1' to equal 1
you can accomplish this by casting the values to the same type.

Some examples:
'1' -> asinteger == 1 // true
1 -> asstring == '1' // also true

If you're unsure about the type of an input value, cast it to the proper
type before using it.

local(myinput = webrequest_param('myinput') -> asinteger)

In some cases Lasso will automatically recast type to help you on the
way.

If you instruct Lasso to do
1 + 1
the result will of course be 2.

But if you instead write
'1' + 1
the code will still compute but the result will be a string object with
the content 11. Since one of the input objects is of type string, Lasso
will recast the other input value to string as well and then concatenate
them.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Fw: Fw: Found_count and conditional statements in lasso 9

XL Cordemans
Thank you all for the explanation. Much appreciated.

     
----- Forwarded Message -----
 From: "[hidden email]" <[hidden email]>
 To: [hidden email]
 Sent: Thursday, August 11, 2016 7:40 AM
 Subject: Re: Fw: Found_count and conditional statements in lasso 9
   


2016-08-11 08:54 skrev XL Cordemans:
> noted your observation - but as I am not specialist would it be
> possible to illustrate this explantion more by way of an example?
> I understand that found_count is an integer and "1" is another integer
> too. Actually the number of found_count records returned in a search
> of a database will most likely be an integer anyway, is it not? 

Sure. Here's the non-specialist expansion.

"1" or '1' is NOT integers. They are constants of the type string.
Treated the same as "A" or 'A'. It is simply a character, in this case a
digit, in a string object.

1 on the other hand is an integer.
1.0 is a decimal.
Note the lack of quote marks.

When it comes to comparing values Lasso is fairly picky with type of
object it is comparing.
'1' will not equal 1 since one of the values is a string and the other
an integer.

Taking care of ensuring that you have the right sort of type for your
objects is your responsibility in most cases. If you want '1' to equal 1
you can accomplish this by casting the values to the same type.

Some examples:
'1' -> asinteger == 1 // true
1 -> asstring == '1' // also true

If you're unsure about the type of an input value, cast it to the proper
type before using it.

local(myinput = webrequest_param('myinput') -> asinteger)

In some cases Lasso will automatically recast type to help you on the
way.

If you instruct Lasso to do
1 + 1
the result will of course be 2.

But if you instead write
'1' + 1
the code will still compute but the result will be a string object with
the content 11. Since one of the input objects is of type string, Lasso
will recast the other input value to string as well and then concatenate
them.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>

 

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>