raj2000
Jun 21st, 2000, 04:13 PM
The code below should separate the values as follows:-
name is [res], value is [map is 0s2000.map]
name is [map0], value is [2]
name is [lat1], value is [50.708286]
etc
But it outputs data as at the bottom of this message.
What changes do I need to make to my program in order to get the correct data out?
<% @Language = "VBScript" %>
<% Response.buffer = true %>
Dim sString ' a variable to hold the original string value
Dim arrWork1 ' a variable to hold the split array of pairs
Dim arrWork2 ' a variable to hold the split array of name/value
Dim i ' a loop counter
' assume that the contents are all in a string called sString
sString = "Res=Map=OS2000.Map, MapO=2, Lat1=50.708286, " & _
"Lat2=50.798220, " & vbcrlf & _
"Lat3=50.797615, Lat4=50.707683, Lon1=-001.575082, " & _
"Lon2=-001.574267, " & vbcrlf & _
"Lon3=-001.432362, Lon4=-001.433449 , Page=7, XCur=14, " & _
"YCur=45, Col= H, " & vbcrlf & _
"Row= 5 , Page=12, XCur=14, YCur=45, Col= G, Row= 7"
' next, let's get rid of all the spurious carriage returns and line
'feeds...
sString = Replace(sString, vbCrfl, "")
'split the string into an array at each comma
arrWork1 = Split(sString, ",")
For i = LBound(arrWork1) to UBound(arrWork1)
' split the current pair into name and value
' at the first equals sign...
arrWork2 = Split(arrWork1(i), "=", 2)
Response.Write "Name is [" & _
Trim(arrWork2(LBound(arrWork2))) & "]"
Response.Write ", Value is [" & _
Trim(arrWork2(UBound(arrWork2))) & "]<BR"
Erase arrWork2 ' clear the array
Next
Erase arrWork1 ' clear the array
%>
<%="ret="&sString%>
This is the output I am receiving from the above code.
' declare all of our variables... Dim sString ' a variable to hold the original string value Dim arrWork1 ' a variable to hold the split array of pairs Dim arrWork2 ' a variable to hold the split array of name/value Dim i ' a loop counter ' assume that the contents are all in a string called sString ' for fun, let's encode your sample contents into that string... sString = "Res=Map=OS2000.Map, MapO=2, Lat1=50.708286, " & _ "Lat2=50.798220, " & vbcrlf & _ "Lat3=50.797615, Lat4=50.707683, Lon1=-001.575082, " & _ "Lon2=-001.574267, " & vbcrlf & _ "Lon3=-001.432362, Lon4=-001.433449 , Page=7, XCur=14, " & _ "YCur=45, Col= H, " & vbcrlf & _ "Row= 5 , Page=12, XCur=14, YCur=45, Col= G, Row= 7" ' next, let's get rid of all the spurious carriage returns and line 'feeds... sString = Replace(sString, vbCrfl, "") 'split the string into an array at each comma arrWork1 = Split(sString, ",") For i = LBound(arrWork1) to UBound(arrWork1) ' split the current pair into name and value ' at the first equals sign... arrWork2 = Split(arrWork1(i), "=", 2) Response.Write "Name is [" & _ Trim(arrWork2(LBound(arrWork2))) & "]" Response.Write ", Value is [" & _ Trim(arrWork2(UBound(arrWork2))) & "] ret=
name is [res], value is [map is 0s2000.map]
name is [map0], value is [2]
name is [lat1], value is [50.708286]
etc
But it outputs data as at the bottom of this message.
What changes do I need to make to my program in order to get the correct data out?
<% @Language = "VBScript" %>
<% Response.buffer = true %>
Dim sString ' a variable to hold the original string value
Dim arrWork1 ' a variable to hold the split array of pairs
Dim arrWork2 ' a variable to hold the split array of name/value
Dim i ' a loop counter
' assume that the contents are all in a string called sString
sString = "Res=Map=OS2000.Map, MapO=2, Lat1=50.708286, " & _
"Lat2=50.798220, " & vbcrlf & _
"Lat3=50.797615, Lat4=50.707683, Lon1=-001.575082, " & _
"Lon2=-001.574267, " & vbcrlf & _
"Lon3=-001.432362, Lon4=-001.433449 , Page=7, XCur=14, " & _
"YCur=45, Col= H, " & vbcrlf & _
"Row= 5 , Page=12, XCur=14, YCur=45, Col= G, Row= 7"
' next, let's get rid of all the spurious carriage returns and line
'feeds...
sString = Replace(sString, vbCrfl, "")
'split the string into an array at each comma
arrWork1 = Split(sString, ",")
For i = LBound(arrWork1) to UBound(arrWork1)
' split the current pair into name and value
' at the first equals sign...
arrWork2 = Split(arrWork1(i), "=", 2)
Response.Write "Name is [" & _
Trim(arrWork2(LBound(arrWork2))) & "]"
Response.Write ", Value is [" & _
Trim(arrWork2(UBound(arrWork2))) & "]<BR"
Erase arrWork2 ' clear the array
Next
Erase arrWork1 ' clear the array
%>
<%="ret="&sString%>
This is the output I am receiving from the above code.
' declare all of our variables... Dim sString ' a variable to hold the original string value Dim arrWork1 ' a variable to hold the split array of pairs Dim arrWork2 ' a variable to hold the split array of name/value Dim i ' a loop counter ' assume that the contents are all in a string called sString ' for fun, let's encode your sample contents into that string... sString = "Res=Map=OS2000.Map, MapO=2, Lat1=50.708286, " & _ "Lat2=50.798220, " & vbcrlf & _ "Lat3=50.797615, Lat4=50.707683, Lon1=-001.575082, " & _ "Lon2=-001.574267, " & vbcrlf & _ "Lon3=-001.432362, Lon4=-001.433449 , Page=7, XCur=14, " & _ "YCur=45, Col= H, " & vbcrlf & _ "Row= 5 , Page=12, XCur=14, YCur=45, Col= G, Row= 7" ' next, let's get rid of all the spurious carriage returns and line 'feeds... sString = Replace(sString, vbCrfl, "") 'split the string into an array at each comma arrWork1 = Split(sString, ",") For i = LBound(arrWork1) to UBound(arrWork1) ' split the current pair into name and value ' at the first equals sign... arrWork2 = Split(arrWork1(i), "=", 2) Response.Write "Name is [" & _ Trim(arrWork2(LBound(arrWork2))) & "]" Response.Write ", Value is [" & _ Trim(arrWork2(UBound(arrWork2))) & "] ret=