Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Url Parsing VFP

Status
Not open for further replies.

louie728

Programmer
Feb 4, 2004
27
US
Hello all,

I am developing an application that will send via a url querystring a path to a file for upload to a webpage. (example: The path will have spaces because it will be sending files from the users my documents folder, right now I am just using STRTRAN to replace spaces with "%20", but would like to know if there is some built in routine or if someone knew of one that I could use for url parsing.

Any help is greatly appreciated......
 
louie728

You may want to look at faq184-4666 to get some ideas on sending URLs to a webpages.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
In general, you could simply parse the string and convert any characters outside a given range to it's hex equivalent. Something like this should work:
Code:
* ConvURL.PRG
LPARAMETERS p_cURL
#DEFINE cLowASCII 33 && greater than Space
#DEFINE cHighASCII 126 && less than DEL
LOCAL l_cResultURL, l_cChr

l_cResultURL = ""
FOR lnii = 1 TO LEN(p_cURL)
   l_cChr = SUBSTR(p_cURL, lnii, 1)
   IF !BETWEEN(ASC(l_cChr), cLowASCII, cHighASCII)
      l_cChr = "%"+RIGHT(TRANSFORM(ASC(l_cChr), "@0"),2)
   ENDIF
   l_cResultURL = l_cResultURL + l_cChr
ENDFOR

RETURN l_cResultURL

*EOP: ConvURL.PRG
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top