loadurl
VARIABLE
,
URL

The loadurl statement loads a resource from the internet.


Parameters

This statement has two parameters:

variable – is the name of the field or variable into which you wish to place the downloaded resource (usually text).

url – is the address of the resource to be loaded, for example "http://www.apple.com".


Description

This statement loads a resource from the internet, for example a web page or an image. For example, this procedure will display the home page of the Apple web site.

local webPage
loadurl webPage,"http://www.apple.com"
displaydata webPage

Note that when we say “display”, we actually mean it displays the HTML source of the page, not what you would see in a web browser. (Of course you can use Panorama’s Web Browser object to actually display a web page in a form.

Unlike Panorama 6.0 and earlier, the loadurl statement doesn’t always return text – it can also return binary data. This can be handy if you are downloading a non-text resource, for example an image. However, in some cases loadurl will return binary data when you expect text – it depends on the attributes returned by the web server. For example, loading a page from apple.com or google.com results in text, but loading a page from provue.com or nshipster.com returns binary data (at the time this was written). If you know that the data is text, you can just use it as text and it will be converted automatically, or you can use the binarytotext( function to do so explicitly.

local webPage
loadurl webPage,"http://www.apple.com"
displaydata binarytotext(webPage)

Note: If you need more control over loading the resource, use the url( function instead.

Note: The loadurl statement uses HTTP GET to retrieve the resource. If you want to use HTTP PUT, use the posturl(, url( or urltask( function.

Note: The loadurl statement is synchronous. This means that Panorama stops in its tracks until the communication is complete, so you should avoid this function if possible and use urltask( instead.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but now can return binary data as well as text.