Forum Moderators: open
I need to extract information from a cookie string from a shopping cart. It just adds all the information on the end of the string, i need to extract the 5 details from it, and repeat the process over again for the next product sold
the cookie will look something like this for 3 products sold, seperated by a ¦ at the moment
.[DiningCard¦35¦102¦1¦1][EntertainmentCard¦35¦101¦1¦1][LivingCard¦35¦103¦1¦1]
SO i need it to search for a seperater key and pull out information from there and save into variables...i am not good with VB so would like to see how you do this in a For Loop or whatever , i dont know to figure out length of a cookie in VB and how to search for "¦" and seperate it etc....well maybe you understand my situation :)
Thanks for your help :)
the cookie is made in Javascript using a cart that does not save to the database so i need to figure out how to do that :)
Thanx
[edited by: powerslave at 11:05 am (utc) on April 21, 2005]
<%
sTempBuff = "[DiningCard¦35¦102¦1¦1][EntertainmentCard¦35¦101¦1¦1][LivingCard¦35¦103¦1¦1]"
vTempArr = Split(sTempBuff, "[")
' Clean inner loop items
Function c(in_string)
If InStr(1, in_string, "]") <> 0 Then
retVal = Replace(in_String, "]", "")
Else
retVal = in_string
End If
c = retVal
End Function
'Clean outer loop base item
Function o(in_string)
pipePos = Instr(1,in_string, "¦")
If pipePos <> 0 Then
retVal = left(in_String, pipePos - 1)
Else
retVal = in_string
End If
o = retVal
End Function
For x = 1 To ubound(vTempArr)
Response.Write o(vTempArr(x)) & "<br>"
sInnerTemp = Split(vTempArr(x), "¦")
for y = 1 to ubound(sInnerTemp)
Response.Write c(sInnerTemp(y)) & "<br>"
next
Response.Write "<br><br>"
Next
%>
I havent tried it yet because i found it some theory on VB and used that
ive got it work up until trying to figure out the length of an array
could u please give me some code to tell me the size of an array? the array of the cookie I splitted....
So then i can know when to stop my loop that inserts into the Database
I suspect it has somthing to do with the
For x = 1 To ubound(vTempArr)
line u have there....ill play around with it but if u could help that would be good :)
Thanks :)