Splitting Session Variable into several variables (array?) 
Author Message
 Splitting Session Variable into several variables (array?)

Hi Everyone,

We are trying to split up a session variable (result returned by our credit card
processor) containing multiple elements into seperate variables.

I have got this to work fine when all 8 elements are present, but not all of the
elements to the string are always present. Sometimes only one or two of the items
in the sample string below are present, so when not all 8 are present, I get
a 'out of range error' because i have hardcoded the results from the entire
array.

Does anyone know how I can split this into session variables so that it will work
regardless of how many elements their are in the string and array?

==== Begin Code ====
<% Session("SampleString") = "ZipCode, AddressCode, AuthCode, Auth2Code, TFICode,
Amount, Approved, Result" %>

<%

MyArray = Split(Session("SampleString"),", ")
Session("8") = MyArray(7)
Session("7") = MyArray(6)
Session("6") = MyArray(5)
Session("5") = MyArray(4)
Session("4") = MyArray(3)
Session("3") = MyArray(2)
Session("2") = MyArray(1)
Session("1") = MyArray(0)

%>

==== End Code ====

Thanks,
Andy Wolkin



Mon, 28 Jul 2003 23:55:35 GMT  
 Splitting Session Variable into several variables (array?)
After the Split, check UBound(MyArray).  If it isn't 7 then one or more of the 8 parts are missing.
If the missing parts are predictable based solely on the value returned by UBound(), then assign
session variables accordingly and use appropriate default values for those that are missing.  If
there is no predictability, then buy a crystal ball ;-)...

--
Michael Harris
Microsoft.MVP.Scripting
--

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


Hi Everyone,

We are trying to split up a session variable (result returned by our credit card
processor) containing multiple elements into seperate variables.

I have got this to work fine when all 8 elements are present, but not all of the
elements to the string are always present. Sometimes only one or two of the items
in the sample string below are present, so when not all 8 are present, I get
a 'out of range error' because i have hardcoded the results from the entire
array.

Does anyone know how I can split this into session variables so that it will work
regardless of how many elements their are in the string and array?

==== Begin Code ====
<% Session("SampleString") = "ZipCode, AddressCode, AuthCode, Auth2Code, TFICode,
Amount, Approved, Result" %>

<%

MyArray = Split(Session("SampleString"),", ")
Session("8") = MyArray(7)
Session("7") = MyArray(6)
Session("6") = MyArray(5)
Session("5") = MyArray(4)
Session("4") = MyArray(3)
Session("3") = MyArray(2)
Session("2") = MyArray(1)
Session("1") = MyArray(0)

%>

==== End Code ====

Thanks,
Andy Wolkin



Tue, 29 Jul 2003 12:56:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing Array to Session Variable Then back to Array

2. split string variable into array?

3. Type mismatch when comparing session variable to page variable

4. ASP - Array in Session Variable ? (JScript)

5. Session variables and Arrays

6. Storing JScript Arrays in a Session Variable

7. storing a 2 dimensional array in a session variable

8. Multi-dimentional Arrays in Session Variables?

9. Help! Storing Arrays in Session Variables - problem

10. Session Variables and Arrays

11. How can I use an array as variable Session

12. Create a dynamic array from set of Session variables

 

 
Powered by phpBB® Forum Software