Internet service
Use the Internet service to:
-
Display
a Web page in the default browser (HyperLinkToURL function, which
starts the default browser with the specified URL) -
Access the HTML for a specified page (GetURL function,
which performs an HTTP Get) -
Send data to a CGI, ISAPI, or NSAPI program (PostURL function,
which performs an HTTP Post)
Hyperlinking to a URL
You call the Internet service’s HyperLinkToURL function
to start the default browser with a specified URL.
To hyperlink to a URL:
-
Declare an instance or global variable
of type Inet:1Inet iinet_base -
Create the Internet service by calling the GetContextService function:
1THIS.GetContextService("Inet", iinet_base) -
Call the HyperLinkToURL function,
passing the URL of the page to display when the browser starts:1iinet_base.HyperlinkToURL &1   ("http://www.sybase.com")
Getting a URL
You call the Internet service’s GetURL function
to perform an HTTP Get, returning raw HTML for
a specified URL. This function returns the raw HTML using the InternetResult
object.
To perform an HTTP Get:
-
Declare an instance or global variable
of type Inet. Also declare an instance or global variable using
the descendent InternetResult object as the datatype (n_ir_msgbox in
this example):1Inet iinet_base1n_ir_msgbox iir_msgbox -
Create the Internet service by calling the GetContextService function:
1THIS.GetContextService("Internet", iinet_base) -
Create an instance of the descendent InternetResult
object:1iir_msgbox = CREATE n_ir_msgbox -
Call the GetURL function, passing
the URL of the page to be returned and a reference to the instance
of the descendent InternetResult object:1iinet_base.GetURL &1   ("http://www.sybase.com", iir_msgbox)When the GetURL function completes, it
calls the InternetData function defined in the
descendent InternetResult object, passing the HTML for the specified
URL.
Posting to a URL
You call the Internet service’s PostURL function
to perform an HTTP Post, sending data to a CGI,
ISAPI, or NSAPI program. This function returns the raw HTML using
the InternetResult object.
To perform an HTTP Post:
-
Declare an instance or global variable
of type Inet. Also declare an instance or global variable using
the descendent InternetResult object as the datatype (n_ir_msgbox in
this example):1Inet iinet_base1n_ir_msgbox iir_msgbox -
Create the Internet service by calling the GetContextService function:
1THIS.GetContextService("Internet", iinet_base) -
Create an instance of the descendent InternetResult
object:1iir_msgbox = CREATE n_ir_msgbox -
Establish the arguments to the PostURL function:
1Blob lblb_args1String ls_headers1String ls_url1Long ll_length1ls_url = "http://coltrane.sybase.com/"1ls_url += "cgi-bin/pbcgi80.exe/"1ls_url += "myapp/n_cst_html/f_test?"1lblb_args = Blob("")1ll_length = Len(lblb_args)1ls_headers = "Content-Length: " &<br>   + String(ll_length) + "~n~n" -
Call the PostURL function,
passing the URL of the routine to be executed, the arguments, the
header, an optional server port specification, and a reference to
the instance of the descendent InternetResult object:1iinet_base.PostURL &<br>   (ls_url, lblb_args, ls_headers, 8080, iir_msgbox)When the PostURL function completes, it
calls the InternetData function defined in the
descendent InternetResult object, passing the HTML returned by the
specified routine.
Using the InternetResult object
The GetURL and PostURL functions
both receive data in an InternetResult object. This object acts
as a buffer, receiving and caching the asynchronous data as it is
returned by means of the Internet. When all data is received, the InternetResult
object calls its InternetData function, which
you override to process the data as appropriate.
You implement this feature by creating standard class user
objects of type InternetResult. In each of these descendent user
objects, define an InternetData function to process
the passed HTML as appropriate.
To implement a descendent InternetResult object:
-
Create a standard class user object of
type InternetResult. -
Declare a new user object function as follows:
-
Name
InternetData
-
Access
Public
-
Returns
Integer
-
Argument name
Data, passed by value
-
Argument datatype
Blob
-
-
Add code to the InternetData function
that processes the returned HTML as appropriate. This example simply
displays the HTML in a MessageBox:1MessageBox("Returned HTML", &<br>   String(data, EncodingANSI!))1Return 1