[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: _Compare, passes array to single value compare.. Bug?



On 7/10/24 09:06, Benoît Minisini wrote:
Le 10/07/2024 à 17:29, Brian G a écrit :
When I have an object called  myobject with a _compare() the compiler passes both myobject and myobject[] to the function. But does not pass either when both are myobject[]. Not sure what the correct behavior is, but it seems incorrect to pass [] to a single myobject.

Anybody know what it should happen,  or do we have to guard against receiving an [], what should be the correct return value when we get an [].

Sample script

--------------------------------------------------------------------------

#!/usr/bin/env gbs3
'Auto Generated Script 07/10/2024 15:15:32.628 Version (3.19.90)
#Script Startup="Main"
#Script Version="0.0.1"
class cmpit
' Gambas class file
Public value As Variant = Null
Public Sub _new(newvalue As Variant)
     value = newvalue
End

Public Sub _compare(rvalue As Variant) As Integer
     If value = rvalue.value Then Return 0
     If value > rvalue.value Then Return 1
     Return -1
End
End class

' Gambas module file
Public Sub Main()
     Print "Hello world"
     Dim a As New Cmpit(9)
     Dim b As New Cmpit(10)
     Dim c As Variant = a
     Dim e As New Cmpit[10]
     For i As Integer = 0 To e.Max
         e[i] = New Cmpit(9)
     Next
     Print Str(a = b), Str(c = a)
     Print Str(a = e)
End

_________________________________________________________________-


I don't get what you are talking about. Can you post a real project archive instead of just a script?


As an aside, you can turn the scripts back to a project with gbs3 --convert-script thescript /directory to where project directory created/

--
~~~~ Brian

Attachment: OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


References:
_Compare, passes array to single value compare.. Bug?Brian G <brian@xxxxxxxxxxxxxxxx>
Re: _Compare, passes array to single value compare.. Bug?Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>