I'm working on an array_merge function for ASP classic. What I have seems to be working, until one (or both) params are empty or not arrays. Here's what I have so far:
function array_merge(left, right)
dim total_size
dim i
dim merged
' Convert "left" to an array
if not isArray(left) then
left = Array(left)
end if
' Convert "right" to an array
if not isArray(right) then
right = Array(right)
end if
' Start with "left" and add the elements of "right"
right_size = ubound(right)
total_size = ubound(left) + right_size + 1
merged = left
redim preserve merged(total_size)
for i = 0 to ubound(right)
merged(right_size + i + 1) = right(i)
next
' Return value
array_merge = merged
end function
I get the error:
Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'merged'
/_inc/nav/left-nav.inc, line 21
From the line merged(right_size + i + 1) = right(i)
. Any wisdom on where I'm going wrong?