SetURLPart()

Syntax

Result$ = SetURLPart(URL$, Parameter$, Value$)
Description
Set a specific part of the given URL$.

Parameters

URL$ The URL to modify. A URL$ may contain parameters, which are useful when a scripting language such as: (PHP) is being used on that server. The syntax is as follows: (http://www.purebasic.com/index.php3?test=1) Here, the parameter is named "test" and its associated value is "1".

In order to set a specific part of a URL, the information provided within "URL$" must (at the minimum), be of the following format: ("http://www.purebasic.com")
Parameter$ The parameter to modify. The parameters are not case-sensitive. Moreover, Parameter$ may be one of the following constants:
  #PB_URL_Protocol: change the protocol of the URL$
  #PB_URL_Site: change the site of the URL$
  #PB_URL_Port: change the port of the URL$ (or adds it if not specified)
  #PB_URL_Parameters: changes all the parameters of the URL$ (or adds it if not specified)
  #PB_URL_Path: changes the path of the URL$ (or adds it if not specified)
  #PB_URL_User: changes the username of the URL$ (or adds it if not specified)
  #PB_URL_Password: changes the password of the URL$  (or adds it if not specified - the "user" needs to exist)
Value$ The value to assign to the given parameter or URL part.

Return value

Returns the modified URL.

Example

  URL$ = "http://www.test.com/hello.php3"

  URL$ = SetURLPart(URL$, #PB_URL_Protocol, "ftp")
  URL$ = SetURLPart(URL$, #PB_URL_Site, "www.purebasic.com")
  URL$ = SetURLPart(URL$, #PB_URL_Port, "80")
  URL$ = SetURLPart(URL$, #PB_URL_Path, "english/index.php3")
  URL$ = SetURLPart(URL$, #PB_URL_User, "user")
  URL$ = SetURLPart(URL$, #PB_URL_Password, "pass")
  URL$ = SetURLPart(URL$, "test", "1")
  URL$ = SetURLPart(URL$, "ok", "2")

  Debug URL$ ; Will print "ftp://user:pass@www.purebasic.com:80/english/index.php3?test=1&ok=2"

See Also

GetURLPart(), URLEncoder()

Supported OS

All

<- ReceiveHTTPMemory() - Http Index - URLDecoder() ->