Author |
Topic |
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-12-05 : 13:44:45
|
Hello,Am have a slight problem parsing a request.form object results for VB Script line feeds.PROBLEM:If i put numbers in a textbox seperated by a comma e.g. 2452452,42542542,24524524 once i retrieve and iterate through the results set i can easily parse them. Using the split funtion and checking through each value in an array e.g.numbers = request.form("results")split(numbers)total = ubound(numbers)for i = 0 to totalresponse.write(numbers(i))next However, when i use a line feed. e.g.45245245,25254254,254254254The result set adds a space before the number(i) valueI have tried using both replace and trim function, to remove the space, but it appears the space is a server encode character.I tried using the server.HTMLEncode(number(i)) to see what the value is, but nothing is written.PROBLEMThe result set no longer is a numeric value. How do i solve this ?QUITE COMPLEX Any ideas, thanksAfrika |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 15:07:42
|
In VB there is a CSTR function. Try that for VBScript too.Peter LarssonHelsingborg, Sweden |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-12-05 : 15:25:10
|
cstr means to convert to a string. I had tried it before, something likenumbers = request.form("results")split(numbers)total = ubound(numbers)for i = 0 to totalcstr(numbers(i))response.write(numbers(i))next Still does not remove the invalid character. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 15:36:39
|
numbers = request.form("results")split(numbers)total = ubound(numbers)for i = 0 to totalresponse.write(CSTR(numbers(i)))nextPeter LarssonHelsingborg, Sweden |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-12-05 : 16:00:07
|
Hi Peter, i ran a couple of tests,...still does not remove the invalid character. I get something like thisFAILURE : 23480353tyrt82335/9,234803312325s0/9,234803312325s0/9,234803312325=0/9,23480331232500/2,2348033123250.2348033123250/2,JKLKJKLJKLLKJ/9,2345902222222/1,2348033123250./2, 2348023265551/4, 2348023265551/4, 2348023265551/4The code above is a result set, of values that dont meet the numeric character or length above 13 characters, which is the maximum length for a phone number value.The last sets in red are from "line feed" values, if you notice there is a space before the numbers and the value "/4" tells me its longer than 13 characters, (reason for failure to meet the test)I tried using cstr to remove it and also tried trim and replace and it still does not work.Afrika |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 16:07:09
|
numbers = request.form("results")split(numbers)total = ubound(numbers)for i = 0 to totalresponse.write(ASC(LEFT(CSTR(numbers(i)), 1)))nextPeter LarssonHelsingborg, Sweden |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-12-05 : 16:21:45
|
I get the value 13. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 16:25:22
|
That means that the first character is CR.numbers = request.form("results")split(numbers)total = ubound(numbers)for i = 0 to totalresponse.write(REPLACE(CSTR(numbers(i)), CHR(13), ''))nextPeter LarssonHelsingborg, Sweden |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 16:32:24
|
Since your code, or VBscript, obviously adds a CR to the output, replace the CR with empty string as my previous post.Peter LarssonHelsingborg, Sweden |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-12-05 : 16:40:43
|
Sorry am a bit lost here.1st of all, your code is meant to readresponse.write(REPLACE(CSTR(numbers(i)), CHR(13), ""))notresponse.write(REPLACE(CSTR(numbers(i)), CHR(13), ''))As single quotation marks are for variables in SQL not VB script Secondly,What do you mean replace the CR with an empty string. Am a bit lost here rgdsEhi |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-12-05 : 16:43:30
|
Instead of "CR" am guessing you mean the value for carriage return constats which is Chr(13) ? Is this what you mean ? ... Am still testing the code |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 16:46:24
|
Yes. Sorry. I am still in "SQL mode". The replacement should be two double quotes.Peter LarssonHelsingborg, Sweden |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-12-05 : 16:54:23
|
Yesssssssssssssssss !!!!!!!!!!!!!!!!!!!!!IT WORKED !Peter, i must admit. you are a genius. Great Guy !!!Thanks a great deal.This is the final codecheck(i) = (REPLACE(CSTR(check(i)), CHR(13), ""))check(i) = (REPLACE(CSTR(check(i)), CHR(10), "")) I noticed a change of failed values in my test, for (failed numbers) which is in my 3rd post above, ... ... The value changed from , 23802365551/4 to , 23802365551/2 And the space was still there. So i looked up the values for carriage return and linefeed (Newline) values and as you said, it was Chr(13) & Chr(10)So i replaced them, and it works like a charmThanks a great dealEhi |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 17:03:27
|
Happy to help you.Good luck.Peter LarssonHelsingborg, Sweden |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-12-05 : 17:06:44
|
Am very grateful, thanks a great deal Here's one on me |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-12-06 : 03:12:25
|
hi Peter,i just found another way of achieving the same resultscheck(i) = (REPLACE(CSTR(check(i)), vbCrLf, ""))Have a great dayEhi |
|
|
|