[Gambas-user] If x <> +Inf Then [Error]

BB adamnt42 at gmail.com
Wed Apr 19 01:52:46 CEST 2023


I can't disagree with you there but there are other constructs where you 
need to "force" the evaluation before the test, not just this case.

I am away from my machine so I cant give a confirmed example, could be 
something like:

     If hObjectA.StringVar And hObjectB.StringVar Then

needs to be parenthesized

     If (hObjectA.StringVar And hObjectB.StringVar) Then

otherwise it evaluates the string lengths before the test, i.e. it 
"sees" the first as

     If (Len(hObjectA.StringVar)>0) And (Len(hObjectB.StringVar)>0) Then
     i.e. If ((1) And (1))

or something like that anyway.

What I'm trying to say is that +/-Inf isn't the single root cause of the 
error, other things can do it too and sometimes it is hard to think the 
same way as the lexer and force the evaluation.


bruce


On 19/4/23 8:58 am, Jussi Lahtinen wrote:
> Yes, that works, but it is still inconsistency.
>
> Jussi
>
> On Wed, Apr 19, 2023 at 2:05 AM BB <adamnt42 at gmail.com 
> <mailto:adamnt42 at gmail.com>> wrote:
>
>     I think, from memory you need to use
>
>     If (x <> +Inf) then
>
>     bruce
>
>     On 19/4/23 8:13 am, Jussi Lahtinen wrote:
>>     I can confirm. The error is "THEN expected". IE the code is not
>>     parsed properly.
>>
>>     Jussi
>>
>>
>>     On Wed, Apr 19, 2023 at 12:48 AM Martín <mbelmonte at belmotek.net
>>     <mailto:mbelmonte at belmotek.net>> wrote:
>>
>>         Hi,
>>
>>         There maybe are an error in the evaluation of expression:
>>
>>         If x <> +Inf Then ...
>>
>>         To reproduce the error you can use this code (it occurs in
>>         3.18.2 &
>>         3.18.90 but not in 3.18.0)
>>
>>         Public Sub Form_Open()
>>
>>            Dim i As Integer
>>            'Dim inFinito As Integer = (2 ^ 31) - 1
>>            Dim inFinito As Integer = +Inf
>>            Dim a As New Integer[]
>>
>>            For i = 0 To 9
>>              a.Add(Rand(0, inFinito))
>>            Next
>>
>>            For i = 0 To 9
>>              'If a[i] <> +Inf Then ' it doesn't works
>>              If a[i] <> inFinito Then ' it works
>>
>>                Print "Continua jugando"
>>              Else
>>                Print "Fin del juego"
>>              Endif
>>            Next
>>
>>         End
>>
>>
>>         Best regards
>>
>>         Martin.
>>
>>
>>         ----[ http://gambaswiki.org/wiki/doc/netiquette
>>         <http://gambaswiki.org/wiki/doc/netiquette> ]----
>>
>>
>>     ----[http://gambaswiki.org/wiki/doc/netiquette  <http://gambaswiki.org/wiki/doc/netiquette>  ]----
>
>     ----[ http://gambaswiki.org/wiki/doc/netiquette
>     <http://gambaswiki.org/wiki/doc/netiquette> ]----
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230419/2ea2c65e/attachment-0001.htm>


More information about the User mailing list