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

Randall Morgan rmorgan62 at ...626...
Fri Mar 16 13:43:10 CET 2012


The line containing the if statement. It is the "Is" keyword that fail
somehow.... If I change it to = or some other expression I get results I
would expect.

-> if expected Is Array Then --->>>>> Error: "Expected Object got boolean"

I am already using TypeOf to test the type of the results. What I need now
is to know if the result is an array or a single instance.



On Fri, Mar 16, 2012 at 5:09 AM, Emil Lenngren <emil.lenngren at ...626...>wrote:

> That kind of code should work, I think... On what line is the error?
>
> 2012/3/16 Randall Morgan <rmorgan62 at ...626...>
>
> > The code is for a test framework. I am currently on the wrong machine to
> > send the code. But it's something like this:
> >
> > Dim result As Variant
> > Dim expected As Variant
> > Dim i As Integer
> > Dim isEqual As Boolean
> >
> > result = myFunction() As Variant
> >
> >
> > if Typeof(result) = Typeof(expected) Then
> >   isEqual = True
> >
> >   'test values
> >   if expected Is Array Then
> >      'test each array element against the expected result
> >      if result Is Array Then
> >         For i=0 To result.Max()
> >            if expected[i] <> result[i] then
> >              isEqual = False
> >            endif
> >         Next
> >      endif
> >   else
> >    .....
> >   endif
> > endif
> >
> >
> >
> >
> >
> > On Fri, Mar 16, 2012 at 4:08 AM, Emil Lenngren <emil.lenngren at ...626...
> > >wrote:
> >
> > > How does your code look like?
> > > A boolean is certainly not an array... :)
> > >
> > > /Emil
> > >
> > > 2012/3/16 Randall Morgan <rmorgan62 at ...626...>
> > >
> > > > That works as long as a is an array. But it a is an a boolean then I
> > get
> > > an
> > > > error "Object expected but got boolean" or float, ect...
> > > >
> > > > I too thought it should work that way. Mybe there is a bug in the
> > Gambas
> > > or
> > > > my code?
> > > >
> > > >
> > > >
> > > > On Fri, Mar 16, 2012 at 3:34 AM, Emil Lenngren <
> > emil.lenngren at ...626...
> > > > >wrote:
> > > >
> > > > > Dim a As New String[]
> > > > > Print a Is Array
> > > > >
> > > > > should work I think...
> > > > >
> > > > > 2012/3/16 Randall Morgan <rmorgan62 at ...626...>
> > > > >
> > > > > > 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
> > > > > >
> > > > > > --
> > > > > > 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?
> > > >
> > > >
> > >
> >
> ------------------------------------------------------------------------------
> > > > 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?
> >
> >
> ------------------------------------------------------------------------------
> > 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