scripting@wanadoo.nl




slUBound()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
5 August 2002 slUBound()
AuthorScriptLogic Corporation
Action Returns the upper boundary of an array, or -1 if the array has only one element and the element is a blank string.
SyntaxslUBound ($array) 
Parameters
  • $array (Required / Array) The array that would would like the modified ubound of. 
  • RemarksThis UDF was created because there is no way of knowing whether an array that was dynamically created & resized, contains no elements or a single element.

    Necessary because there is no way to know if an array has a single element or no elements. 
    ReturnsReturns the upper boundary or the array, just like the native UBound() function, however, if the array has only one element and the lone element is a zero-byte string, this UDF returns a -1. 
    DependenciesNone. 
    Examples
    $ArrayA=""
    $numelements=slUBound($ArrayA)+1
    ?"The array has "+$numelements+" elements."
    ; output = 0
    
    $ArrayB="one"
    $numelements=slUBound($ArrayB)+1
    ?"The array has "+$numelements+" elements."
    ; output = 1
    
    $ArrayC="one","two"
    $numelements=slUBound($ArrayC)+1
    ?"The array has "+$numelements+" elements."
    ; output = 2
    
     
    Source
    FUNCTION slUBound ($array)
      ; Returns: -1 if Array has no elements, (no elements is defined as
      ;             a ubound of zero AND the first element is a blank string)
      ;   otherwise returns the upper boundary of the array.
      ;
      ; Necessary because there is no way to know if an array has a single
      ; element or no elements.
    
      IF (UBound($array) = 0) AND (''+$array[0] = '')
        $slUBound=-1
      ELSE
        $slUBound=UBound($array)
      ENDIF
    ENDFUNCTION ; - slUBound -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter