Not used to ASP

Not used to ASP

am 13.09.2007 14:14:18 von Sonnich Jensen

Hi all!

I am usually working with PHP, rarely with ASP. I have a book for
help, but that does not do much for me.

I have an array, like:

redim Preserve ecode(I+1)
ecode(I) = field_value(0, rsItem)

it adds stuff to the array.

Now, I need to _insert_ items into the array.
In other words, I need to find an item, say "code C" in the array, and
then insert "code C-1" right after it.

I know very well how to do this in PHP, but I dont even know where to
look for help for ASP.

Would anyone be so kind to help me out?

BR
Sonnich

Re: Not used to ASP

am 13.09.2007 14:47:58 von reb01501

Sonnich Jensen wrote:
> Hi all!
>
> I am usually working with PHP, rarely with ASP. I have a book for
> help, but that does not do much for me.
>
> I have an array, like:
>
> redim Preserve ecode(I+1)
> ecode(I) = field_value(0, rsItem)
>
> it adds stuff to the array.
>
> Now, I need to _insert_ items into the array.
> In other words, I need to find an item, say "code C" in the array, and
> then insert "code C-1" right after it.
>
> I know very well how to do this in PHP, but I dont even know where to
> look for help for ASP.
>
> Would anyone be so kind to help me out?
>
First of all, the language you are using is vbscript, not ASP. ASP is a
"platform" which supports multiple scripting languages, including
vbscript and jscript.
You can download the Windows Scripting Host (which includes vbscript)
documentation from here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=015 92c48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en
Vbscript does not support inserting elements into the middle of an
array.
If you are tied to using a vbscript array, you have two options:
1. Create a new array and write the array elements in the order you want
them
2. Resize the array, use a loop to move the array element values to the
desired location and set the desired element value to the value you wish
to insert.

This task is a little simpler with an ad hoc ADO recordset: AddNew still
adds records to the end of the recordset, but you can use Sort to order
them in any order you want.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.