Create a dynamic array from set of Session variables 
Author Message
 Create a dynamic array from set of Session variables

Hi group,

i have a lil problem creating a (dynamic array)  based on a set of session
varibales that are created.

During the browser session, several session variables are created by a
looping function.
Each time a loop passes, the result is writen to an according session
variable for later reference.

e.g.
session("1")="1"
session("2")="2"
session("2")="2"
session("2")="2"
session("2")="2"
/e.g.

But I dont know in front how many will be created. At the end of the
function I need to get these variables into an array, and list them

e.g.:
You choose the following:
item 1 = 1
item 2 = 2
item 3 = 3
item 4 = 4
item 5 = 5
/e.g.

How exactly would I achieve this? I tried  with the regular array function,
but it only works, if i know the number of values for it.
Ad the property for the Dynamic Array  (Dim MyArray() )
also  produced an error.(Microsoft VBScript runtime error '800a0009'  -
Subscript out of range )

=== Code ===
Dim MyArray(Session.Contents)
   For each i In MyArray()
    Response.Write(" Item " & MyArray(i) & ": " & MyArray(i))
  Next
=== End Code ====

some advice on this would be perfect :-)

Jim



Tue, 28 Oct 2003 21:45:35 GMT  
 Create a dynamic array from set of Session variables
...in the first page...

set myDictionary = createobject("scripting.dictionary")

...some loop construct...
  ...
  myDictionary(myDictionary.count) = "some loop dependent value"
  ...
...end of loop...

Session("myItems") = myDictionary.Items

...in another page...

myItemsArray = Session("myItems")

Item0 = myItemsArray(0)
...
..
.

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> Hi group,

> i have a lil problem creating a (dynamic array)  based on a set of session
> varibales that are created.

> During the browser session, several session variables are created by a
> looping function.
> Each time a loop passes, the result is writen to an according session
> variable for later reference.

> e.g.
> session("1")="1"
> session("2")="2"
> session("2")="2"
> session("2")="2"
> session("2")="2"
> /e.g.

> But I dont know in front how many will be created. At the end of the
> function I need to get these variables into an array, and list them

> e.g.:
> You choose the following:
> item 1 = 1
> item 2 = 2
> item 3 = 3
> item 4 = 4
> item 5 = 5
> /e.g.

> How exactly would I achieve this? I tried  with the regular array function,
> but it only works, if i know the number of values for it.
> Ad the property for the Dynamic Array  (Dim MyArray() )
> also  produced an error.(Microsoft VBScript runtime error '800a0009'  -
> Subscript out of range )

> === Code ===
> Dim MyArray(Session.Contents)
>    For each i In MyArray()
>     Response.Write(" Item " & MyArray(i) & ": " & MyArray(i))
>   Next
> === End Code ====

> some advice on this would be perfect :-)

> Jim



Wed, 29 Oct 2003 09:24:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. setting session variables with dynamic identifiers?

2. Splitting Session Variable into several variables (array?)

3. Passing Array to Session Variable Then back to Array

4. Session("Variable") as Array ...ASP

5. Storing arrays in a Session Variable

6. ASP Session Variables / Arrays

7. dotnet Session variable set too late - Error Page Description related

8. Setting Dynamic Variables

9. there is a variables when i dim a dynamic array

10. How to create a truly dynamic array?

11. Create Array with Dynamic Elements

12. How to create a truly dynamic array?

 

 
Powered by phpBB® Forum Software