$Web Sub: Difference between revisions
m (1 revision) |
m (→Syntax) |
||
(17 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:$Web_Sub}} | {{DISPLAYTITLE:$Web_Sub}} | ||
<span class="pageSubtitle" | <span class="pageSubtitle">Set delimiter for procedure text substitution</span> | ||
$Web_Sub sets the delimiter for designating text to be symbolically substituted when text is sent to the client from within | <var>$Web_Sub</var> sets the delimiter for designating text to be symbolically substituted when text is sent to the client from within <var class="product">Model 204</var> procedures. | ||
<var>$Web_Sub</var> is a [[Calling Sirius Mods $functions|callable]] $function, and it takes a single string argument and returns a status code. | |||
==Syntax== | ==Syntax== | ||
<p class="syntax">< | <p class="syntax"><span class="term">%rc</span> = <span class="literal">$Web_Sub</span>(<span class="term"> delimiter</span> ) | ||
< | </p> | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%rc</th> | |||
<td>A numeric [[#Status codes|status code]]. | |||
<tr><th>delimiter</th> | <tr><th>delimiter</th> | ||
<td>A 1- to 3-character string, or a null string. | <td>A 1- to 3-character string, or a null string. | ||
Line 16: | Line 18: | ||
</table> | </table> | ||
<table | ===Status codes=== | ||
<table> | |||
<tr><th>Code</th> | <tr><th>Code</th> | ||
< | <th>Meaning</th></tr> | ||
<tr><th>0</th> | <tr><th>0</th> | ||
<td>Substitution delimiter successfully set.</td></tr> | <td>Substitution delimiter successfully set.</td></tr> | ||
Line 26: | Line 29: | ||
<td>Invalid argument (more than 3 characters long)</td></tr> | <td>Invalid argument (more than 3 characters long)</td></tr> | ||
</table> | </table> | ||
If not null, | ==Usage notes== | ||
<ul> | |||
<li>If not null, <var class="term">delimiter</var> is used to identify the text strings in a <var class="product">Model 204</var> procedure that should be symbolically substituted before presentation to the client. Strings that begin with the given delimiter and end with an exclamation mark ( ! ) will be matched against the Global Variable Table (GTBL), and the value of any such global variables will be substituted for the string. | |||
<li>Symbolic substitution performed by the <var>$Web_Sub</var> setting only affects lines sent to the client by <var>$Web_ProcSend</var> or by the SEND subcommand in the ON rule chosen for the URL. | |||
<li>Until <var>$Web_Sub</var> is called, <var class="product">[[Janus Web Server]]</var> does not perform any substitution of strings into procedures sent to the client. Setting <var>$Web_Sub</var> to null also turns off substitution. | |||
<li>As with all $WEB_ functions, <var>$Web_Sub</var> can be invoked by CMD processing, which is specified either in the ON rule for the URL or in the JANUS DEFINE ... WEB command for the port. Note that <var>$Web_Sub</var> can only affect procedures referenced in SEND rules if <var>$Web_Sub</var> is called due to the JANUS DEFINE ... WEB command. | |||
</ul> | |||
==Examples== | |||
<p class="code"> <HTML> | <p class="code"><HTML> | ||
<p>Greetings from @LOCATION!. | |||
<p>Having a @QUALITY! time. | |||
<p>Wish you were @WISHLOC!. | |||
</HTML> | |||
. . . | . . . | ||
%X = $SETG('LOCATION','Springfield') | |||
%X = $SETG('QUALITY','nice') | |||
%X = $SETG('WISHLOC','rich') | |||
%X = $Web_Sub('@') | |||
%X = $Web_ProcSend( 'HTMLFILE', 'GREETING' ) | |||
</p> | </p> | ||
<p> | |||
In the example above, an at sign (<tt>@</tt>) is used as the substitution indicator for global names in procedure text. The client would see: | In the example above, an at sign (<tt>@</tt>) is used as the substitution indicator for global names in procedure text. The client would see: </p> | ||
<p class="code">Greetings from Springfield. | |||
<p class="code"> Greetings from Springfield. | Having a nice time. | ||
Wish you were rich. | |||
</p> | </p> | ||
[[Category:Janus Web Server $functions|$Web_Sub]] | [[Category:Janus Web Server $functions|$Web_Sub]] |
Latest revision as of 21:55, 5 June 2013
Set delimiter for procedure text substitution
$Web_Sub sets the delimiter for designating text to be symbolically substituted when text is sent to the client from within Model 204 procedures.
$Web_Sub is a callable $function, and it takes a single string argument and returns a status code.
Syntax
%rc = $Web_Sub( delimiter )
%rc | A numeric status code. |
---|---|
delimiter | A 1- to 3-character string, or a null string. |
Status codes
Code | Meaning |
---|---|
0 | Substitution delimiter successfully set. |
-1 | Invalid call, not a Web thread |
-4 | Invalid argument (more than 3 characters long) |
Usage notes
- If not null, delimiter is used to identify the text strings in a Model 204 procedure that should be symbolically substituted before presentation to the client. Strings that begin with the given delimiter and end with an exclamation mark ( ! ) will be matched against the Global Variable Table (GTBL), and the value of any such global variables will be substituted for the string.
- Symbolic substitution performed by the $Web_Sub setting only affects lines sent to the client by $Web_ProcSend or by the SEND subcommand in the ON rule chosen for the URL.
- Until $Web_Sub is called, Janus Web Server does not perform any substitution of strings into procedures sent to the client. Setting $Web_Sub to null also turns off substitution.
- As with all $WEB_ functions, $Web_Sub can be invoked by CMD processing, which is specified either in the ON rule for the URL or in the JANUS DEFINE ... WEB command for the port. Note that $Web_Sub can only affect procedures referenced in SEND rules if $Web_Sub is called due to the JANUS DEFINE ... WEB command.
Examples
<HTML>
Greetings from @LOCATION!.
Having a @QUALITY! time.
Wish you were @WISHLOC!. </HTML> . . . %X = $SETG('LOCATION','Springfield') %X = $SETG('QUALITY','nice') %X = $SETG('WISHLOC','rich') %X = $Web_Sub('@') %X = $Web_ProcSend( 'HTMLFILE', 'GREETING' )
In the example above, an at sign (@) is used as the substitution indicator for global names in procedure text. The client would see:
Greetings from Springfield. Having a nice time. Wish you were rich.