Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Newbie: Nested dynamic arrays

Reply
Thread Tools

Newbie: Nested dynamic arrays

 
 
Neil
Guest
Posts: n/a
 
      01-11-2004
Hi Folks,

In a nutshell...

I have 6 pieces of info describing products in an array which is
carried between asp pages in session arrays.

e.g.
localcart(x,i)
For...
localcart(ProdID,i)=ProdID
localcart(Size,i)=Size
etc..
Loop

then..

session("cart")= localCart (to carry the info between pages)

This has worked fine, but I want to add options that further describe
the product. Now, depending on the product type, a different number of
options are available, determined from a recordset, e.g. length,
weight, voltage, etc. which are rendered to form elements - e.g.
length=100, weight=50 etc.

My question is this.
How can my localcart array, which contains a fixed number of fields to
identify the products in the cart, contain another dynamic array which
may have 4 to 12 pieces of additional information, depending on the
product(s) selected?

If I could have a dimension in the original array, say
localcart(Options,i), which could hold the contents of a dynamic array
localOptions(), this might help - but I can't figure out a way to do
it!

I hope this is clear - appreciate your help



NMF
 
Reply With Quote
 
 
 
 
Alex G
Guest
Posts: n/a
 
      01-12-2004
What you want to do is ReDim the array with the new number of fields
each time one is added, do a search on "ReDim Array" for more
information.

http://www.velocityreviews.com/forums/(E-Mail Removed) (Neil) wrote in message news:<(E-Mail Removed). com>...
> Hi Folks,
>
> In a nutshell...
>
> I have 6 pieces of info describing products in an array which is
> carried between asp pages in session arrays.
>
> e.g.
> localcart(x,i)
> For...
> localcart(ProdID,i)=ProdID
> localcart(Size,i)=Size
> etc..
> Loop
>
> then..
>
> session("cart")= localCart (to carry the info between pages)
>
> This has worked fine, but I want to add options that further describe
> the product. Now, depending on the product type, a different number of
> options are available, determined from a recordset, e.g. length,
> weight, voltage, etc. which are rendered to form elements - e.g.
> length=100, weight=50 etc.
>
> My question is this.
> How can my localcart array, which contains a fixed number of fields to
> identify the products in the cart, contain another dynamic array which
> may have 4 to 12 pieces of additional information, depending on the
> product(s) selected?
>
> If I could have a dimension in the original array, say
> localcart(Options,i), which could hold the contents of a dynamic array
> localOptions(), this might help - but I can't figure out a way to do
> it!
>
> I hope this is clear - appreciate your help
>
>
>
> NMF

 
Reply With Quote
 
 
 
 
Neil
Guest
Posts: n/a
 
      01-12-2004
Thanks for this pointer Alex.

I understand how to redim an array - however, I'm not sure of if it is
possible for an element in one array to hold the contents of another
(<===).

e.g.
....
LocalCart(0,1) = "ProductX"
LocalCart(0,2) = "Widget"
LocalCart(0,3) = "Blue"
LocalCart(0,4) = localOptions(ProductX,i) <===
'(localOptions being a 2-dim, dynamic array)

LocalCart(1,1) = "ProductY"
LocalCart(1,2) = "Thingy"
LocalCart(1,3) = "Red"
LocalCart(0,4) = localOptions(ProductY,i) <===

....

Is it possible and what is the syntax.

Thanks for your help

Neil

(E-Mail Removed) (Alex G) wrote in message news:<(E-Mail Removed). com>...
> What you want to do is ReDim the array with the new number of fields
> each time one is added, do a search on "ReDim Array" for more
> information.
>
> (E-Mail Removed) (Neil) wrote in message news:<(E-Mail Removed). com>...
> > Hi Folks,
> >
> > In a nutshell...
> >
> > I have 6 pieces of info describing products in an array which is
> > carried between asp pages in session arrays.
> >
> > e.g.
> > localcart(x,i)
> > For...
> > localcart(ProdID,i)=ProdID
> > localcart(Size,i)=Size
> > etc..
> > Loop
> >
> > then..
> >
> > session("cart")= localCart (to carry the info between pages)
> >
> > This has worked fine, but I want to add options that further describe
> > the product. Now, depending on the product type, a different number of
> > options are available, determined from a recordset, e.g. length,
> > weight, voltage, etc. which are rendered to form elements - e.g.
> > length=100, weight=50 etc.
> >
> > My question is this.
> > How can my localcart array, which contains a fixed number of fields to
> > identify the products in the cart, contain another dynamic array which
> > may have 4 to 12 pieces of additional information, depending on the
> > product(s) selected?
> >
> > If I could have a dimension in the original array, say
> > localcart(Options,i), which could hold the contents of a dynamic array
> > localOptions(), this might help - but I can't figure out a way to do
> > it!
> >
> > I hope this is clear - appreciate your help
> >
> >
> >
> > NMF

 
Reply With Quote
 
Alex G
Guest
Posts: n/a
 
      01-13-2004
I have never tried to do this, but i assume that if:

localOptions(ProductX,i) = "Option 1"

and you then

LocalCart(0,4) = localOptions(ProductX,i)

that

LocalCart(0,4) will then hold "Option 1"

i take it this isn't what you want? because not all products will hold
the same number of options, which will result in the 2nd dimension
being different sizes?

They I would maybe do it (but seems a bit messy, probably a much
better way) would be to have the localCart array store a string with
the corresponding values in the "one-dimensional" localOptions Array,
e.g.

localCart(0,4) = "0,1,2,3"

localCart(1,4) = "4,5,6"

localOptions(0) = "option1 for Product X"
localOptions(1) = "option2 for Product X"
localOptions(2) = "option3 for Product X"
etc.....

then when you want to pull the data grab the string from localCart,
split it on the commma to form another array which you use to extract
information from localOptions

tempArray = Split(localCart(0,4))

'will write out each option for the first product
for i = 0 to UBound(tempArray)
Response.Write(localOptions(tempArray(i))
Next


I haven't tested any of this so it may possibly not work or throw some
error up.

Hope it helps


(E-Mail Removed) (Neil) wrote in message news:<(E-Mail Removed) om>...
> Thanks for this pointer Alex.
>
> I understand how to redim an array - however, I'm not sure of if it is
> possible for an element in one array to hold the contents of another
> (<===).
>
> e.g.
> ...
> LocalCart(0,1) = "ProductX"
> LocalCart(0,2) = "Widget"
> LocalCart(0,3) = "Blue"
> LocalCart(0,4) = localOptions(ProductX,i) <===
> '(localOptions being a 2-dim, dynamic array)
>
> LocalCart(1,1) = "ProductY"
> LocalCart(1,2) = "Thingy"
> LocalCart(1,3) = "Red"
> LocalCart(0,4) = localOptions(ProductY,i) <===
>
> ...
>
> Is it possible and what is the syntax.
>
> Thanks for your help
>
> Neil
>
> (E-Mail Removed) (Alex G) wrote in message news:<(E-Mail Removed). com>...
> > What you want to do is ReDim the array with the new number of fields
> > each time one is added, do a search on "ReDim Array" for more
> > information.
> >
> > (E-Mail Removed) (Neil) wrote in message news:<(E-Mail Removed). com>...
> > > Hi Folks,
> > >
> > > In a nutshell...
> > >
> > > I have 6 pieces of info describing products in an array which is
> > > carried between asp pages in session arrays.
> > >
> > > e.g.
> > > localcart(x,i)
> > > For...
> > > localcart(ProdID,i)=ProdID
> > > localcart(Size,i)=Size
> > > etc..
> > > Loop
> > >
> > > then..
> > >
> > > session("cart")= localCart (to carry the info between pages)
> > >
> > > This has worked fine, but I want to add options that further describe
> > > the product. Now, depending on the product type, a different number of
> > > options are available, determined from a recordset, e.g. length,
> > > weight, voltage, etc. which are rendered to form elements - e.g.
> > > length=100, weight=50 etc.
> > >
> > > My question is this.
> > > How can my localcart array, which contains a fixed number of fields to
> > > identify the products in the cart, contain another dynamic array which
> > > may have 4 to 12 pieces of additional information, depending on the
> > > product(s) selected?
> > >
> > > If I could have a dimension in the original array, say
> > > localcart(Options,i), which could hold the contents of a dynamic array
> > > localOptions(), this might help - but I can't figure out a way to do
> > > it!
> > >
> > > I hope this is clear - appreciate your help
> > >
> > >
> > >
> > > NMF

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
Nested Vector Nester Classes are Nested in my Brain Chad E. Dollins C++ 3 11-08-2005 04:46 AM
A nested dynamic checkbox inside my dynamic form. pizzy Javascript 5 04-12-2005 02:55 PM
How to have a nested dynamic checkbox inside my dynamic form. pizzy Javascript 0 03-23-2005 03:32 AM
Nested iterators (well, not nested exactly...) Russ Perry Jr Java 2 08-20-2004 06:51 PM



Advertisments