PicLan-IP Dynamic Web Content
1 2 3 4 5 6 7 8 9 10 11 12
Contents
7. Special Statements and Functions
In order to make it easier to build HTML documents and handle form input,
a number of special BASIC statement and function extensions are available
to your embedded Pick BASIC code:
-
ans = PL_HEX(x) - Convert a string from ASCII to HEX. This is the
same as an OCONV(...,'MX') conversion but works around implementation bugs
present on some Pick hosts.
-
ans = PL_QUOTE(x) - Converts a string from ASCII into quoted HTML-compatible
ASCII. This allows characters such as < and > to be displayed
in an HTML document.
-
ans = PL_UNQUOTE(x) - Converts HTML-compatible ASCII into normal
ASCII.
-
ans = PL_AMTOCRLF(x) - Converts attribute marks into CRLF sequences.
-
ans = PL_CRLFTOAM(x) - Converts CRLF sequences into attribute marks.
-
PL_GETVAR ans FROM varname THEN/ELSE ... - Reads an input field
variable.
PL_PUTVAR var IN varname THEN/ELSE ... - Write an input field
variable. This statement is only used when you wish to chain to another
page and supply input field variables.
7.1 Reading HTTP Header Fields
HTTP header fields are available to embedded MV/Basic code using the helper
function:
PL_GET_HDR VAR FROM "USER-AGENT" THEN/ELSE ...
This statement will stores into variable VAR the string associated
with the HTTP header fields "USER-AGENT". If the "USER-AGENT" fields
is not present, then the ELSE clause will execute. If more
than one header field is tagged as "USER-AGENT", then VAR will contain
each value as multiple MV attributes. HTTP header field names (but
not values) are also automatically converted to UPPER CASE.
If you wish to access all of the HTTP header fields, you can query
the variables ST$HTTP.HDR and ST$HTTP.VAL. The ST$HTTP.HDR
variable contains all of the header field names in a multi-valued dynamic
array. The ST$HTTP.VAL variable contains all of the associated
header field values in a multi-valued dynamic array with duplicate entries
stored as sub-values. This data is stored in this manner so that
applications can use the MV/Basic LOCATE(...) statement to quickly
query a header value without having to search through a list.
7.2 Generating HTTP Header Fields
You can specify additional HTTP header fields within embedded MV/Basic
code. The following statement will add an HTTP header line:
PL_ADD_HDR 'Location: http://modsoft.com/new.htm'
This example will add an HTTP "Location: ..." header field. You can
add whatever HTTP header fields you application needs. In general,
the following two types of fields can be used:
-
Location: For use with 302 FOUND redirection responses.
-
Set-Cookie: For use with setting client-side persistent state "cookies".
7.3 COOKIES
The PicLan-IP Web Server provides several functions that make setting and
retrieving cookie values easy.
To set a COOKIE, include the following statement in your embedded MV/Basic
code:
PL_SET_COOKIE "VALUE" TO "NAME"
To read a cookie use the statement:
PL_GET_COOKIE VALUE FROM "NAME" THEN/ELSE
The PL_SET_COOKIE helper function uses the default, non-persitant, cookie
mechanism. If you want to use all of the features of cookies, you
can specify the Set-Cookie HTTP header manually as in:
PL_ADD_HDR 'Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT'
More information on cookies is available in NetScape's cookie specification:
http://home.netscape.com/newsref/std/cookie_spec.html
1 2 3 4 5 6 7 8 9 10 11 12
Contents
© Copyright 1996-1997 Modular Software Corporation.All
rights Reserved.