473,395 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Delete ASP Multidimensional Array

I'm fairly new to ASP and must admit its proving a lot more unnecessarily
complicated than the other languages I know. I feel this is because there
aren't many good official resources out there to help do the most basic
things.

One of the "basic" things I haven't been able to find out how to do is how
to delete an item from a multidimensional array object and resize it
afterwards.

It seems so easy to conceive of the code to delete from a multidimensional
array but it just isn't working. Surely it should be as easy as something
like:

myArray.delete(1,0)
myArray.remove(5,7)

but what it is and how to find out - there just doesn't seem to be a way. I
reckon there must have been some collusion going on between m$ and the
writers of books called things like "Learn ASP in 4 days!!!" to stifle the
spread of information in order to make money because this language is
unreal!
Mar 23 '06 #1
10 12145
try
redim yourArray(5,5)

if you want to preserver the existing data

redim preserve yourArray(6,6)

this is all listed in the vbscript file
<no****@nospam.com> wrote in message
news:pe******************************@bt.com...
I'm fairly new to ASP and must admit its proving a lot more unnecessarily
complicated than the other languages I know. I feel this is because there
aren't many good official resources out there to help do the most basic
things.

One of the "basic" things I haven't been able to find out how to do is how
to delete an item from a multidimensional array object and resize it
afterwards.

It seems so easy to conceive of the code to delete from a multidimensional
array but it just isn't working. Surely it should be as easy as something
like:

myArray.delete(1,0)
myArray.remove(5,7)

but what it is and how to find out - there just doesn't seem to be a way.
I reckon there must have been some collusion going on between m$ and the
writers of books called things like "Learn ASP in 4 days!!!" to stifle the
spread of information in order to make money because this language is
unreal!

Mar 23 '06 #2
Slim wrote on 23 mrt 2006 in microsoft.public.inetserver.asp.general:
<no****@nospam.com> wrote in message
news:pe******************************@bt.com...
I'm fairly new to ASP and must admit its proving a lot more
unnecessarily complicated than the other languages I know. I feel
this is because there aren't many good official resources out there
to help do the most basic things.

One of the "basic" things I haven't been able to find out how to do
is how to delete an item from a multidimensional array object and
resize it afterwards.

It seems so easy to conceive of the code to delete from a
multidimensional array but it just isn't working. Surely it should be
as easy as something like:

myArray.delete(1,0)
myArray.remove(5,7)

but what it is and how to find out - there just doesn't seem to be a
way. I reckon there must have been some collusion going on between m$
and the writers of books called things like "Learn ASP in 4 days!!!"
to stifle the spread of information in order to make money because
this language is unreal!

try
redim yourArray(5,5)

if you want to preserver the existing data

redim preserve yourArray(6,6)

this is all listed in the vbscript file


The problem is, that ASP is not a language at all, but a platform for
serverside scripting languages, like vbscript and jscript.

It seems that you are both ignoring that and consequently don't connect.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 23 '06 #3

<no****@nospam.com> wrote in message
news:pe******************************@bt.com...
I'm fairly new to ASP and must admit its proving a lot more unnecessarily
complicated than the other languages I know. I feel this is because there
aren't many good official resources out there to help do the most basic
things.

One of the "basic" things I haven't been able to find out how to do is how
to delete an item from a multidimensional array object and resize it
afterwards.

It seems so easy to conceive of the code to delete from a multidimensional
array but it just isn't working. Surely it should be as easy as something
like:

myArray.delete(1,0)
myArray.remove(5,7)

but what it is and how to find out - there just doesn't seem to be a way. I reckon there must have been some collusion going on between m$ and the
writers of books called things like "Learn ASP in 4 days!!!" to stifle the
spread of information in order to make money because this language is
unreal!


ASP is essentially a scripting host with some ASP specific objects loaded
into the scripting context.

To use ASP you really need to look for documentation related not only to ASP
but also to the script language you are using.

Take look at these for documentation of the ASP objects

http://msdn.microsoft.com/library/en...d97c2a08c2.asp

http://msdn.microsoft.com/library/en...f33a651779.asp

Then take look at this if you are using javascript:-

http://msdn.microsoft.com/library/en...bfe2330aa9.asp

Or this if vbscript:-

http://msdn.microsoft.com/library/en...5acb52fc54.asp

Given the choice I prefer Javascript but if you want to gather and use ASP
examples from around the web you might want to stick with VBScript.

Anthony.
Mar 23 '06 #4

no****@nospam.com wrote:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily
complicated than the other languages I know. I feel this is because there
aren't many good official resources out there to help do the most basic
things.


Mistake number one - ASP is not a language. It's a technology. You
can access this technology using a number of different languages,
including JScript, Javascript, Perl and VBScript - the latter seems to
be the one used by the vast majority of developers.

When you search for code and help, I suggest you add the language you
are using for your scripts eg "VBScript arrays", and you shouldn't have
any problem getting help.

You might also like to download the language reference for VBScript
from Microsoft (it's free, by the way) here:
http://www.microsoft.com/downloads/d...DisplayLang=en

and then visit the official ASP documentation here:
http://msdn.microsoft.com/library/de...f33a651779.asp

Good luck

--
Mike Brind

Mar 23 '06 #5
> try
redim yourArray(5,5)
<%
Dim mycartArray
Redim mycartarray(1,1)
mycartArray(0,0) = "this"
mycartArray(0,1) = "that"
mycartArray(1,0) = "them"
mycartArray(1,1) = "those"
redim mycartArray(1,1)

Response.Write "<table><tr>"
Response.Write "<td bgcolor=#dddddd>00" & mycartArray(0,0) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>01" & mycartArray(0,1) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>10" & mycartArray(1,0) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>11" & mycartArray(1,1) & "</td></tr>"
Response.Write "</table>"
%>

Result:
00
01
10
11
if you want to preserver the existing data

redim preserve yourArray(6,6)
<%
Dim mycartArray
Redim mycartarray(1,1)
mycartArray(0,0) = "this"
mycartArray(0,1) = "that"
mycartArray(1,0) = "them"
mycartArray(1,1) = "those"
redim preserve mycartArray(1,1)

Response.Write "<table><tr>"
Response.Write "<td bgcolor=#dddddd>00" & mycartArray(0,0) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>01" & mycartArray(0,1) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>10" & mycartArray(1,0) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>11" & mycartArray(1,1) & "</td></tr>"
Response.Write "</table>"
%>

Result:
00this
01that
10them
11those

I'm sorry to be thick but how is this deleting or preserving what I need it
to? I want to clear item (1,1) of the value "those" and retain all the other
information in the array.
this is all listed in the vbscript file
<no****@nospam.com> wrote in message
news:pe******************************@bt.com...
I'm fairly new to ASP and must admit its proving a lot more unnecessarily
complicated than the other languages I know. I feel this is because there
aren't many good official resources out there to help do the most basic
things.

One of the "basic" things I haven't been able to find out how to do is
how to delete an item from a multidimensional array object and resize it
afterwards.

It seems so easy to conceive of the code to delete from a
multidimensional array but it just isn't working. Surely it should be as
easy as something like:

myArray.delete(1,0)
myArray.remove(5,7)

but what it is and how to find out - there just doesn't seem to be a way.
I reckon there must have been some collusion going on between m$ and the
writers of books called things like "Learn ASP in 4 days!!!" to stifle
the spread of information in order to make money because this language is
unreal!


Mar 23 '06 #6
> You might also like to download the language reference for VBScript
from Microsoft (it's free, by the way) here:
http://www.microsoft.com/downloads/d...DisplayLang=en
Arrgh! I'm really not having any luck here. I followed your link and it was
just the lastest scripting installation package - no docs or help concerning
where it may or may not have installed any docs. But I found a link from
that page which was for the documentation I think you mean to link me to and
then when I downloaded that it looked excellent but the first page I was
greeted with was page cannot be displayed and none of the other references
go anywhere or do anything (and I took my firewall off temporarily to work
out why its not loading).
and then visit the official ASP documentation here:
http://msdn.microsoft.com/library/de...f33a651779.asp

Good luck


Thanks - I'm gonna need it..
Mar 23 '06 #7

<no****@nospam.com> wrote in message news:8d********************@bt.com...
try
redim yourArray(5,5)
<%
Dim mycartArray
Redim mycartarray(1,1)
mycartArray(0,0) = "this"
mycartArray(0,1) = "that"
mycartArray(1,0) = "them"
mycartArray(1,1) = "those"
redim mycartArray(1,1)

Response.Write "<table><tr>"
Response.Write "<td bgcolor=#dddddd>00" & mycartArray(0,0) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>01" & mycartArray(0,1) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>10" & mycartArray(1,0) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>11" & mycartArray(1,1) & "</td></tr>"
Response.Write "</table>"
%>

Result:
00
01
10
11
if you want to preserver the existing data

redim preserve yourArray(6,6)


<%
Dim mycartArray
Redim mycartarray(1,1)
mycartArray(0,0) = "this"
mycartArray(0,1) = "that"
mycartArray(1,0) = "them"
mycartArray(1,1) = "those"
redim preserve mycartArray(1,1)

Response.Write "<table><tr>"
Response.Write "<td bgcolor=#dddddd>00" & mycartArray(0,0) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>01" & mycartArray(0,1) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>10" & mycartArray(1,0) & "</td></tr>"
Response.Write "<td bgcolor=#dddddd>11" & mycartArray(1,1) & "</td></tr>"
Response.Write "</table>"
%>

Result:
00this
01that
10them
11those

I'm sorry to be thick but how is this deleting or preserving what I need
it to? I want to clear item (1,1) of the value "those" and retain all the
other information in the array.

ok
mycartArray(1,1) = ""

this is all listed in the vbscript file
<no****@nospam.com> wrote in message
news:pe******************************@bt.com...
I'm fairly new to ASP and must admit its proving a lot more
unnecessarily complicated than the other languages I know. I feel this
is because there aren't many good official resources out there to help
do the most basic things.

One of the "basic" things I haven't been able to find out how to do is
how to delete an item from a multidimensional array object and resize it
afterwards.

It seems so easy to conceive of the code to delete from a
multidimensional array but it just isn't working. Surely it should be as
easy as something like:

myArray.delete(1,0)
myArray.remove(5,7)

but what it is and how to find out - there just doesn't seem to be a
way. I reckon there must have been some collusion going on between m$
and the writers of books called things like "Learn ASP in 4 days!!!" to
stifle the spread of information in order to make money because this
language is unreal!



Mar 23 '06 #8
no****@nospam.com wrote:
You might also like to download the language reference for VBScript
from Microsoft (it's free, by the way) here:
http://www.microsoft.com/downloads/d...DisplayLang=en
Arrgh! I'm really not having any luck here. I followed your link and
it was just the lastest scripting installation package - no docs or help
concerning where it may or may not have installed any docs. But I found a
link
from that page which was for the documentation I think you mean to link me
to and


Was it this link?
http://www.microsoft.com/downloads/d...displaylang=en
then when I downloaded that it looked excellent but the first page I
was greeted with was page cannot be displayed and none of the other
references


Where did you install it? I've seen that in certain cases where I didn't
install the chm file to my local hard drive.

You can read the vbscript docs online at
http://msdn.microsoft.com/library/en...5acb52fc54.asp

This will be the same documentation that is included in the download in the
previous link.
In addition, you will find documentation for all MS developer technologies
at this website.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Mar 23 '06 #9
One of the "basic" things I haven't been able to find out how to do is how
to delete an item from a multidimensional array object and resize it
afterwards.


Using any syntax of any language with which you are currently familiar can
you post the code that would do this "basic" thing?

It's fairly easy to set the contents of an array element to a null or empty
value but I suspect what you really want to do is destroy the 'cell'
completely, moving all other cells up some how. You haven't specified how
exactly though.

For example in a 3x3 matrix if item(0,1) is destroyed does item(1,0) become
item(0,2)?

Anthony.
Mar 23 '06 #10
no****@nospam.com wrote:
I'm fairly new to ASP and must admit its proving a lot more
unnecessarily complicated than the other languages I know. I feel
this is because there aren't many good official resources out there
to help do the most basic things.

One of the "basic" things I haven't been able to find out how to do
is how to delete an item from a multidimensional array object and
resize it afterwards.

It seems so easy to conceive of the code to delete from a
multidimensional array but it just isn't working. Surely it should be
as easy as something like:

myArray.delete(1,0)
myArray.remove(5,7)


In whatever language you are used to using, this must be an easy task. It
sounds as if arrays in that language behave more like what would be called
"collection" in VB. With a collection, items can be removed from or inserted
into the "middle" of the collection. What I am going to talk about applies
to VB, VBA and vbscript, so for simplicity's sake, I am going to refer
simply to "VB" in the following.

With VB arrays, this is not possible. In VB, arrays are "simple" structures
that have no methods for manipulating them such as would be found with a
collection class. VB provides these statements for dealing with arrays
Dim ar([upper index][,...n]): initializes the variable. If an upper index
value is supplied, a fixed-size array is created. If no upper index is
provided, a dynamic array is created (this applies to vbscript - in VB, more
options exist)
ReDim [Preserve]: used to modify an existing array. If used without the
Preserve keyword, all the data in the array is clearedIt can only be used to
change the index of the last dimension in a multi-dimensional array.. In
addition, Preserve will only work when the last dimension in an array is
modified:

dim ar(1,1)
....
redim preserve ar(1,2) ' preserves existing data
redim preserve ar(1,0) 'removes last "row", preserves first "row"
redim preserve ar(2,2) ' clears all existing data (may return error)

Erase: "Reinitializes the elements of fixed-size arrays and deallocates
dynamic-array storage space"

In addition, the following functions exist:
Array(item1,...,itemN): "Returns a Variant containing an array"
LBound(array,[dimension number]): Returns the lowest bound (available
subscript) of the specified array's dimension - not useful in vbscript where
the lowest bound of an array's dimension is always 0
UBound(array,[dimension number]): Returns the upper bound (highest available
subscript) of the specified array's dimension

That's it. This is all you have to work with to manipulate arrays.

So, all you can do is

1. Modify the content of an array element
ar(1,1) = "this"
ar(1,1) = ""

2. Add new elements to the end of a dynamic array:
dim ar()
redim ar(0)
ar(0)="this"
redim preserve ar(1)
ar(1)="that"
Note: ReDim is an "expensive" operation. If you know how many elements will
be needed, you should resize the array in a single statement. Avoid using
redim in a loop:
dim ar()
for i =0 to 3
redim preserve ar(i)
ar(i) = i
next

Instead, do this:
dim ar()
'figure out what the upper bound should be, then
redim ar(3)
for i = 0 to 3
ar(i) = i
next

3. Remove elements from the end of the array (see above)

If you need to be able to remove elements from the middle of an array, you
have to write your own method to do that. Something like:

Sub RemoveAt(ByRef ar, index)
for i = index to ubound(ar) - 1
ar(i) = ar(i+1)
next
redim preserve ar(ubound(ar,1) - 1)
end sub

HTH,
Bob Barrows
--
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.
Mar 23 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TLOlczyk | last post by:
I have a brain cramp and I need some help. I have a chunk of code below which demonstrates a problem I have with multidimensional arrays. I want to keep it simple but something specific is...
1
by: Mark Smith | last post by:
I'm trying to copy data from a 1D array to a 2D array. The obvious thing doesn't work: int twoDee = new int; int oneDee = new int { 1, 2 }; Array.Copy(oneDee, 2, twoDee, 2, 2); This causes a...
2
by: chris | last post by:
Hi there, I created a Multidimensional array of labels Label lblMultiArray = new Label { {Label3, LblThuTotal}, {Label4,LblFriTotal} }; Now I would like to compare the values in the array,...
8
by: Skay | last post by:
Someone challenged me to create a dynamic multidimensional array using auto_ptr http://www.gotw.ca/gotw/042.htm Provides a good way to create a single dimensional array using an adapter. ...
4
by: Gregory.A.Book | last post by:
I'm working with displaying and manipulating very large image sets. The program handles anything from 2D images to 4D RGB volumes in a time-series. I've been using dynamically allocated arrays to...
1
by: Chuy08 | last post by:
If I have a multidimensional array like the following: Array $records =Array 0 = 30 year, 6.0; 1 = 30 year, 6.0; 2 = Pay Option, 1.0; 3 = Pay Option, 1.0; How could I flatten this to...
2
by: Snaggy | last post by:
I have a multidimensional array with a few entries I need to delete. Key and values are not unique in different sub arrays. As far as I know the filter function is not recursive and only deletes...
5
by: LittleCake | last post by:
Hi All, I have a multidimensional array where each sub-array contains just two entries, which indicates a relationship between those two entries. for example the first sub-array: =Array ( =30...
4
Jezternz
by: Jezternz | last post by:
First of all I am open to any suggestions and advice. If a javscript multidimensional array is a bad way to do this please say so. I considered XML but I wondered if this would be a bad idea as it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.