Results 1 to 3 of 3

Thread: Empty Arrays

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    Mexico
    Posts
    25

    Exclamation

    Hi! There!

    OK, My problem is with an TypeUserDefined Array.

    How can i know if my array is empty???

    for example

    i have
    MODULE:
    Type anyType
    a1 as string *2
    a2 as string *2
    a3 as string *2
    a4 as string *2
    a5 as string *2
    End Type
    global arr() as anyType

    FORM:
    if i do a reference to my Array without set a number of elements it's obviously that it generates an error,ok, my question is if, there is an instruction or a function to validate if ANY array is empty.

    I tried this
    Call-->
    bFlag= bEmpty(arr())

    Function-->
    Function bEmpty(rgArr() as anyType) as boolean
    On Error Resume Next

    If LBound(rgArr())<0 then
    bEmpty=True
    else
    bEmptyFalse
    End If

    End Function

    but, as you can see, if i had 10, 15, 'x' number of arrays i would need to do one function by array.....
    The 'H' ^_^

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    There isn't, artificially you could check for subscript out of range error:
    Code:
    On error resume next
    X=Arrayname(0)
    if err=9 then msgbox "empty array"
    on error goto 0
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    New Member
    Join Date
    Oct 2000
    Location
    Swe
    Posts
    14

    Exclamation Elements in Array

    Why don´t you use intElements = Ubound(anyArray)
    That will return the number of elements stored in the array.
    Jesse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width