Link to home
Start Free TrialLog in
Avatar of rav_chow
rav_chow

asked on

integer array?

Do we have integer arrays in ASP. If yes, how can i work with them?
ASKER CERTIFIED SOLUTION
Avatar of DirkVe
DirkVe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Paul Maker
heres an example of code that takes an array, some of the array variables have been set to "" and the function cleanArray removes all the emties. whilst this does not address your question specificaly it will show you a few cool things with VBScript arrays. as already stated arrays can contain any data type and even a mixture of data types, in this way it is analogus to a java vector. it is best to use conversion routines when appropriate

<%

Function cleanArray(tarr)
      arr = tarr
      FOR i = 0 TO UBOUND(arr)
            IF(arr(i) = "" AND i < UBOUND(arr))THEN
                  arr(i) = arr(i + 1)
                  arr(i + 1) = ""     
            END IF            
      NEXT
      count = 0
      FOR i = 0 TO UBOUND(arr)
            IF(arr(i) <> "")THEN
                  count = count + 1      
            END IF            
      NEXT
      REDIM PRESERVE arr(count)
      cleanArray = arr
End Function

dim arra(6)
arra(0) = "Hello"
arra(1) = "Hi"
arra(2) = "asp"
arra(3) = ""
arra(4) = "weeeee"
arra(5) = ""

'narra will now be a clean version of arra
narra = cleanArray(arra)

FOR i = 0 TO UBOUND(narra)
      Response.Write(narra(i) & "<BR>")    
NEXT

%>