Testing for Existence of array(0)

Results 1 to 8 of 8

Thread: Testing for Existence of array(0)

  1. #1
    TuT Guest

    Default Testing for Existence of array(0)

    Sometimes arr2-arr5 do not exist. How do I test for their existence, and if they don&#039;t exist do something else?<BR><BR>bString=Split(Executor.ExecuteDosApp, " ")<BR>arr1=bString(0)<BR>arr2=bString(1)<BR>arr3=b String(2)<BR>arr4=bString(3)<BR>arr5=bString(4)

  2. #2
    Join Date
    Dec 1969
    Posts
    820

    Default RE: Testing for Existence of array(0)

    If (len (arr5) &#062; 0) then<BR>&#039;all exist<BR>ElseIf (len (arr4) &#062; 0) then<BR><BR>etc

  3. #3
    TuT Guest

    Default TRIED this: if bString(1) <> "" then BU

    if bString(1) &#060;&#062; "" then <BR><BR>arr=bString(1)<BR>else<BR>response.write "oots"<BR>end if<BR>

  4. #4
    TuT Guest

    Default Will (len (bString(x) > 0)) work if bString

    If bString(x) does not exist, then this code won&#039;t work??<BR><BR>If (len (bString(x) &#062; 0)) then<BR><BR>I need code that will tell me whether or no bString(x) exists


  5. #5
    TuT TuT Guest

    Default NEW: Test For How Many Elements an Array Has?

    Is there VBscript for testing how many elements an array has?

  6. #6
    Join Date
    Dec 1969
    Posts
    820

    Default RE: NEW: Test For How Many Elements an Array Has?

    Yes, ubound (arrayname) + 1 will give the number of elements, but if you&#039;re doing something like<BR><BR>Dim arr (4)<BR><BR>it will always have 5 elements, even if they have nothing in them.

  7. #7
    TuT Guest

    Default Thanks!

    &#060;EOP&#062;

  8. #8
    Join Date
    Dec 1969
    Posts
    605

    Default Javascript try.. catch...

    If you use Javascript, you can use the great catch.. try.. statement. <BR>It works like this:<BR>bString.Split(Executor.ExecuteDosApp, " ");<BR>try {<BR>arr1 = bString[0];<BR>}<BR>catch(e){<BR>arr1 = "";<BR>}<BR>try {<BR>arr2 = bString[1];<BR>}<BR>catch(e){<BR>arr2 = "";<BR>}<BR>etc.....<BR>Personally, I find this method much more elegant than the other options proposed.

Posting Permissions

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