Showing posts with label single dimension array concatenation. Show all posts
Showing posts with label single dimension array concatenation. Show all posts

Wednesday, June 27, 2007

Single Dimension Array concatenation

Single dimension array

Most of the time you will find that you need to concatenate 2 or more arrays.Somehow in classic asp there's no built in function that can combine array in one command. At least not that i know. Fill with the desperation to do it most of the time i wrote a simple function to concatenate 2 or more arrays

First i create a function call concat:

Function concat(array1,array2)
str1=join(array1,",")
str2=join(array2,",")
str3=str1 & "," &
str2 concat=split(str3,",")
end function

then I call the function anywhere when you need to concatenate arrays. For example, you want concatenate single dimension array

aitem1=array("A1","A1","A3")
aitem2=array("A4","A5","A6")

using this function:
aitem3=concat(aitem1,aitem2)

The elements for aitem3 are: "A1","A1","A3","A4","A5","A6"

Try it and let me know if there's any error by email to nor@melur.com