Posts tagged with 'asp'

Oh, how I hate ASP

Writing ASP (Active Server Pages) sucks. All I want to do, is to add one array to another. Sounds easy, right? Well, with ASP it isn't. Not by a long shot.

But first, and just for contrast, let's see how PHP does it:

$array1 = array("12","35","45");
$array2 = array("334","355","456");
$new_array = array_merge($array1, $array2);

Nice and simple, right? Okay, now how about Perl?

my @array1 = ("12","35","45");
my @array2 = ("334","355","456");
my @new_array = (@array1, @array2);

Wow! That's also pretty brain-dead easy. But, I'm writing about ASP here, so let's move on to that example:

Dim aArray1(), aArray2(), aNewArray(), iArrayCount, iInArray
aArray1 = Array("12","35","45")
aArray2 = Array("334","355","456")
ReDim aNewArray(0)
iArrayCount= 0

' Note that this below is part of a bigger loop where depending on input, I may
' have to add arrays together several times in one go. So, multiply the code below
' like ten times and that's what I'm dealing with.
If (UBound(aNewArray) = 0) Then
   ReDim Preserve aNewArray(UBound(aArray1) + 1)
Else
   ReDim Preserve aNewArray(UBound(aNewArray) + UBound(aArray1))
End If
For iInArray= 0 To UBound(aArray1)
   aNewArray(iArrayCount) = aArray1(iInArray)
   iArrayCount= iArrayCount+ 1
Next
If (UBound(aNewArray) = 0) Then
   ReDim Preserve aNewArray(UBound(aArray2) + 1)
Else
   ReDim Preserve aNewArray(UBound(aNewArray) + UBound(aArray2))
End If
For iInArray= 0 To UBound(aArray2)
   aNewArray(iArrayCount) = aArray2(iInArray)
   iArrayCount= iArrayCount+ 1
Next

I rest my case.

Jun 13, 2005 06:37PM (asp, perl, php, programming, work) Comments (16)

What Inspires Me

Birds of Prey by Hannah Stouffer
Crash 6 of 12, by Scott Teplin
Cathy Cullis' Mixed Textile art
Detail of one of Laure Nollet's sketches
Crafted Camera Case, by hine
wil freeborn
bleak-house
Mississippi
tempete