The OPEN WEB URL Command
By Steve Hussey, CEO, Alto Stratus LLC
Technical Note 01-15
Technical Notes for Technical Notes for 01-03 March 2001
Introduction
The OPEN WEB URL command can be used to connect to an external web URL using your computer's default web browser. It will also allow you to create e-mail messages using your default e-mail client, connect to ftp sites and even open html-based help pages on your local computer. This technical note discusses how to implement each of these solutions.
Note: To use this command you must have the appropriate applications installed and set as the default application for the URL type. For example to connect to a http URL you must have a web browser installed and configured as the default web browser. For a mailto link you will need an e-mail client, and so on.
You can have more than one application of the same type installed but 4D will only use the default application.
Connecting to an external web site
You can specify the full URL for the web site. Doing this supports web browsers that require the full URL.
OPEN WEB URL ("http://www.jumpstart-4d.com")
Many web browsers support partial URL's (you can ignore the http:// prefix). In this case you can just pass the actual web domain and path (if any).
OPEN WEB URL ("www.jumpstart-4d.com")
The URL can, of course, be stored in either a variable or field:
$URL_Name:= "www.jumpstart-4d.com" OPEN WEB URL ($URL_Name)
or
[Table]URL_Field:= "www.jumpstart-4d.com" OPEN WEB URL ([Table]URL_Field)
When the OPEN WEB URL command is executed, 4D will launch the default web browser (if not already running) and pass the URL to it. The URL is not checked by 4D in anyway. You may wish to check the URL's syntax.
The web browser will then attempt to open the URL. The web browser will have now become the frontmost application.
For this operation to succeed you must have sufficient RAM for the web browser to launch, and the URL must be syntactically correct and exist. If the URL is incorrect, or non-existent, the web browser will display the appropriate error message.
Creating e-mail messages
You can create a blank, untitled e-mail message in your default mail client by using the 'mailto:' link.
OPEN WEB URL ("mailto:shush@harborside.com")
The mailto link can also be contained in a field or variable.
You can use an extended syntax to create a message that also has a subject line and body, this is easier if created in a variable or field first and then passed to the OPEN WEB URL command:
$Email:="mailto:shush@harborside.com" $Email:=$Email+"?subject=Test email message" $Email:=$Email+"?body=This is a test email message." OPEN WEB URL ($Email)
This code will create a new email message to the recipient specified in the mailto link, with the subject line that reads "Test email message". The body of the message will contain the text "This is a test email message."
The ? symbol acts as a marker that is followed by the keyword subject or body.
You cannot include the ASCII characters for carriage return (ASCII 13) or line feed (ASCII 10) using 4D's syntax. You can include them using the standard web encoding:
$CarriageReturn:="%0D" $LineFeed:="%0A" `On Mac OS $Email:="mailto:shush@harborside.com" $Email:=$Email+"?subject=Test email message" $Email:=$Email+"?body=This is a test email message."+$CarriageReturn+"Second line of test message." OPEN WEB URL ($Email) `On Windows $Email:="mailto:shush@harborside.com" $Email:=$Email+"?subject=Test email message" $Email:=$Email+"?body=This is a test email message."+$CarriageReturn+$LineFeed+"Second line of test message." OPEN WEB URL ($Email)
Connecting to ftp sites
Use the syntax:
OPEN WEB URL ("ftp.4d.com")
Opening local html files
You can open local html files using your web browser using the following syntax:
$URL:="file:///MyDrive/myfolder/file.html"
Note the prefix "file": this indicates to the browser that it is a local file that is to be opened.
// is the standard web separator used between the protocol (http/ftp etc.) and start of the URL or file name.
The next / indicates that the path starts at the root level of the computer (therefore you can specify any mounted volume on the computer).
MyDrive is the specific volume name, followed by the full path to the file. Note that the standard Unix '/' delimiter is used rather than the Mac OS or Windows path delimiter. If you have multiple disk volumes mounted on your dekstop you can specify whichever volume you prefer, followed by the path to the specific file.
Opening local HTML files is one way to build a context-sensitive help system into your 4D application. You can create HTML help pages that are located in a suitable location on the application's hard drive. On each page of the 4D application you can have a button that opens the relevant HTML page. Once open the user can navigate within the help system using the familiar interface of their preferred web browser.
Summary
This tech note summarizes the uses of the OPEN WEB URL command. Included are examples for opening the default web browser on the user's machine and connecting to a web site, navigating to an ftp site, and sending e-mail.