[Gambas-user] How to test if result is an array

Randall Morgan rmorgan62 at ...626...
Sat Mar 17 18:48:54 CET 2012


Tried that, didn't work. I got the same errors

On Sat, Mar 17, 2012 at 10:45 AM, Emil Lenngren <emil.lenngren at ...626...>wrote:

> You need to use "And If", not only "And".
> http://gambasdoc.org/help/lang/andif?v3
>
> /Emil
>
> 2012/3/17 Randall Morgan <rmorgan62 at ...626...>
>
> > Hi Benoit,
> >
> > I tried the code below and I get errors. If I use:
> >
> > if result Is Array Then
> >
> > I get a type error.
> >
> > If I use:
> >
> > if IsObject(result) And result Is Array Then
> >
> > I get an identifier error IsObject unknown identifier.
> >
> >
> > I just updated my code base and recompiled and still have these errors. I
> > am working on a new machine so maybe I don't have something I should
> have.
> > Although everything compiles.  I am using Ubuntu 11.10 if that makes any
> > difference. Also, I am writing command line/console code if that matters?
> >
> > Here is my function, the code can be found in the gb.gsl test folder. In
> > the Test class file. But I have had the same issue using Is with Complex
> > and Polynomial. I have not tried it on my other machine. When I return to
> > California I will....
> >
> >
> > Public Function IsEqual(result As Variant, expected As Variant) As
> Boolean
> >  Dim err As Boolean = False
> >  Dim i As Integer = 0
> >
> >  If TypeOf(result) <> TypeOf(expected) Then
> >    AddError(TypeError(Me.ResType, Me.ExpType))
> >    Me.hasError = True
> >  Else
> >    If IsObject(result) And result Is Array And expected Is Array Then
> >      If result.len <> expected.len Then
> >       Me.hasError(LengthError(result.len, expected.len))
> >      Else
> >        For i = 0 To result.len - 1
> >          If result[i] <> expected[i] Then
> >            Me.hasError = True
> >          Endif
> >        Next
> >      Endif
> >
> >    Else
> >      If result <> expected Then
> >        AddError(ValueError(Me.Result, Me.Expected))
> >        Me.hasError = True
> >      Endif
> >    Endif
> >  Endif
> >
> >  Return Me.hasError
> >
> > End
> >
> >
> > Thanks for your help
> >
> > Randall
> >
> >
> >
> > 2012/3/16 Benoît Minisini <gambas at ...1...>
> >
> > > Le 16/03/2012 04:14, Randall Morgan a écrit :
> > > > Hi,
> > > >
> > > > I am writing a small test suit and need to tell is the result I got
> > back
> > > > from a function is an array of some type.
> > > > Does anyone have a solution for this?
> > > >
> > > > Thanks
> > > >
> > >
> > > You can do like that:
> > >
> > >        Dim Result As Variant
> > >
> > >        Result = TestFunction()
> > >        If IsObject(Result) And If Result Is Array Then ...
> > >
> > > Or that way:
> > >
> > >        Dim Result As Variant
> > >        Dim AnArray As Array
> > >
> > >        Result = TestFunction()
> > >        Try AnArray = Result
> > >        If Not Error Then ...
> > >
> > > Anyway, I compiled the last gb.gsl, and I got many very suspicious
> > > warnings. Did you aware of them? Or maybe you know what you are doing,
> > > but don't know how to write your code not to get these warnings?
> > >
> > > --
> > > Benoît Minisini
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------------
> > > This SF email is sponsosred by:
> > > Try Windows Azure free for 90 days Click Here
> > > http://p.sf.net/sfu/sfd2d-msazure
> > > _______________________________________________
> > > Gambas-user mailing list
> > > Gambas-user at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> >
> >
> >
> > --
> > If you ask me if it can be done. The answer is YES, it can always be
> done.
> > The correct questions however are... What will it cost, and how long will
> > it take?
> >
> >
> ------------------------------------------------------------------------------
> > This SF email is sponsosred by:
> > Try Windows Azure free for 90 days Click Here
> > http://p.sf.net/sfu/sfd2d-msazure
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
If you ask me if it can be done. The answer is YES, it can always be done.
The correct questions however are... What will it cost, and how long will
it take?



More information about the User mailing list