can Session.Contents can be a string array?

  • Thread starter Bart Plessers \(artabel\)
  • Start date
B

Bart Plessers \(artabel\)

Hello,

My script builds a list of files in a folder.
These files are stored in an 2-dimensional array, called "a_files".

To speed up the script, I don't want the filelist everytime being read on
the server.
Therefore I wanted to send the contents of a_files to a session variable.

However, with
Session.Contents("sFiles") = a_files

I get the following error message:
***********************
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered.
***********************

Is it impossible to store an array to a session var?
Is there another way to store the array somewhere in memory so it has not to
be rebuild everytime?

tia

bartp
 
R

Ray at home

Bart Plessers (artabel) said:
Therefore I wanted to send the contents of a_files to a session variable.

However, with
Session.Contents("sFiles") = a_files

I get the following error message:
***********************
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered.
***********************

Is it impossible to store an array to a session var?

Yes, you can.<%
Dim x(2)
x(0) = "a"
x(1) = "b"
x(2) = "c"

Session("arr") = x

Response.write Session("arr")(0)
Response.write Session("arr")(1)
Response.write Session("arr")(2)
%>

What is the rest of your code?


Is there another way to store the array somewhere in memory so it has not to
be rebuild everytime?

A database is another option.

Ray at home
 
B

Bart Plessers \(artabel\)

hmm,
you build the array in memory.

I have build the array in code:

'**********************************
Dim a_files()
i_dim = 3 'geeft het aantal gegevens aan per j in de array. Opgelet, indien
4 gegevens nodig, dan
i_name = 0 'gives posistion in array
i_size = 1 'gives posistion in array
i_type = 2 'gives posistion in array
i_date = 3 'gives posistion in array

j = 0
For each oFile in oFiles
ReDim Preserve a_files(i_dim,j)
a_files(i_name,j) = oFile.Name
a_files(i_size,j) = oFile.Size
a_files(i_type,j) = oFile.Type
a_files(i_date,j) = oFile.DateLastModified
j = j + 1
Next
'**********************************


Then I want to pass the a_files() to a session string



Can this also be done?
Syntax if?


tia

bartp
 
B

bart plessers

do you have any idea why i get the error

***********************
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered.
***********************

Session.Contents("sFiles") = a_files


Do I have do Dim the sFiles before?

--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================
 
B

Bob Barrows

I don't know. I've tried your code and do not get the error. Here is what I
tried:

Dim a_files()
i_dim = 3 'geeft het aantal gegevens aan per j in de array. Opgelet, indien
4 gegevens nodig, dan
i_name = 0 'gives posistion in array
i_size = 1 'gives posistion in array
i_type = 2 'gives posistion in array
i_date = 3 'gives posistion in array
set fso=Server.CreateObject("scripting.filesystemobject")
set oFldr = fso.GetFolder(server.MapPath("."))
set oFiles = oFldr.Files
j = 0
For each oFile in oFiles
ReDim Preserve a_files(i_dim,j)
a_files(i_name,j) = oFile.Name
a_files(i_size,j) = oFile.Size
a_files(i_type,j) = oFile.Type
a_files(i_date,j) = oFile.DateLastModified
j = j + 1
Next


Session.contents("arr") = a_files
for i = 0 to ubound(session("arr"),2)
for j = 0 to ubound(session("arr"),1)
Response.Write session("arr")(j,i) & "<BR>"
next
next

It seems like you don't have an array. Have you used IsArray to verify that
a_files is an array?

Bob Barrows
 
B

bart plessers

bob,


STUPID ME!!!!!!!!!

sorry to bother you with this.
The problem was that -for debugging- I had included a file "_debug.asp"
In this file, there was a line :

response.write(session("SFiles"))

just becaus SFiles was an array, the response.write could not handle
this.......


anyway,
your code pointed me to reconstruct the array, and not write it itself, so
it was very helpfull!

sorry to bother you
thanx again,

bartp





--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,627
Members
45,329
Latest member
InezZ76898

Latest Threads

Top