$Web Put Text: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{DISPLAYTITLE:$Web_Put_Text}} <span class="pageSubtitle"><section begin="desc" />Add text string to response buffer<section end="desc" /></span> $Web_Put_Text sends a text st...") |
m (→Syntax) |
||
(26 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:$Web_Put_Text}} | {{DISPLAYTITLE:$Web_Put_Text}} | ||
<span class="pageSubtitle" | <span class="pageSubtitle">Add text string to response buffer</span> | ||
<var>$Web_Put_Text</var> sends a text string to the client buffer. | |||
<var>$Web_Put_Text</var> is a [[Calling Sirius Mods $functions|callable]] $function, and it takes a single required string argument and returns a status code. | |||
==Syntax== | ==Syntax== | ||
<p class="syntax">< | <p class="syntax"><span class="term">%rc</span> = <span class="literal">$Web_Put_Text</span>(<span class="term"> string</span> ) | ||
< | </p> | ||
===Syntax terms=== | |||
<table class="syntaxTable"> | |||
<tr><th>%rc</th> | |||
<td>A numeric [[#Status codes|status code]]. | |||
<tr><th>string</th> | <tr><th>string</th> | ||
<td>A text string that is translated from EBCDIC to ASCII and added to the client buffer. | <td>A text string that is translated from EBCDIC to ASCII and added to the client buffer. Under ''[[Sirius Mods]]'' Version 6.7 and later, <var>$Web_Put_Text</var> is longstring capable: it can send a longstring with a length greater than 255 bytes. | ||
</td></tr></table> | </td></tr> | ||
</table> | |||
===Status codes=== | |||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>Code</th> | <tr><th>Code</th> | ||
< | <th>Meaning</th></tr> | ||
<tr><th>0</th> | <tr><th>0</th> | ||
<td>String sent to the client buffer.</td></tr> | <td>String sent to the client buffer.</td></tr> | ||
Line 25: | Line 30: | ||
<tr><th>-4</th> | <tr><th>-4</th> | ||
<td>Missing argument</td></tr> | <td>Missing argument</td></tr> | ||
</table> | </table> | ||
==Usage notes== | |||
The primary uses for <var>$Web_Put_Text</var> are: | |||
<ul> | |||
<li>To send text to a browser when [[$Web_Off]] is set: it might be easier to do a <var>$Web_Put_Text</var> than a [[$Web_On]], PRINT, [[$Web_Off]] sequence. | |||
<li>To have text that is to be sent to a browser embedded in code that is also used in non-browser (for example, 3270 or BATCH2) mode. <var>$Web_Put_Text</var> acts as a no-op when executed on a non-web thread so can be used instead of an IF test (to determine if running on a web thread) followed by a PRINT statement. | |||
</ul> | |||
==Examples== | |||
The following example shows an entire HTML document being sent to the client, a line at a time. Note that you could also direct HTML to the client by sending a procedure that contains HTML (using <var>[[$Web_Proc_Send]]</var>) or simply with PRINT statements (unless <var>$Web_Off</var> has been issued). | |||
<p class="code">%X = $Web_Type('text/HTML') | |||
<p class="code"> %X = $Web_Type('text/HTML') | %X = $Web_Put_Text( '<HTML>' ) | ||
%X = $Web_Put_Text( '<p>' ) | |||
%X = $Web_Put_Text( 'Hello World' ) | |||
%X = $Web_Put_Text( '</HTML>' ) | |||
STOP | |||
</p> | </p> | ||
==See also== | |||
<ul> | |||
<li><li><var>[[$Web_Proc_Send]]</var> can be used to send the contents of a <var class="product">Model 204</var> procedure, either as binary (that is, without translation) or translating from EBCDIC to ASCII. | |||
<li><var>[[$Web_Put_Binary]]</var> adds a string to the web output buffer without translation. | |||
</ul> | |||
< | |||
<li> | |||
<li> | |||
</ | |||
[[Category:Janus Web Server $functions|$Web_Put_Text]] | [[Category:Janus Web Server $functions|$Web_Put_Text]] |
Latest revision as of 22:09, 5 June 2013
Add text string to response buffer
$Web_Put_Text sends a text string to the client buffer.
$Web_Put_Text is a callable $function, and it takes a single required string argument and returns a status code.
Syntax
%rc = $Web_Put_Text( string )
Syntax terms
%rc | A numeric status code. |
---|---|
string | A text string that is translated from EBCDIC to ASCII and added to the client buffer. Under Sirius Mods Version 6.7 and later, $Web_Put_Text is longstring capable: it can send a longstring with a length greater than 255 bytes. |
Status codes
Code | Meaning |
---|---|
0 | String sent to the client buffer. |
-1 | Invalid call, not a Web thread |
-4 | Missing argument |
Usage notes
The primary uses for $Web_Put_Text are:
- To send text to a browser when $Web_Off is set: it might be easier to do a $Web_Put_Text than a $Web_On, PRINT, $Web_Off sequence.
- To have text that is to be sent to a browser embedded in code that is also used in non-browser (for example, 3270 or BATCH2) mode. $Web_Put_Text acts as a no-op when executed on a non-web thread so can be used instead of an IF test (to determine if running on a web thread) followed by a PRINT statement.
Examples
The following example shows an entire HTML document being sent to the client, a line at a time. Note that you could also direct HTML to the client by sending a procedure that contains HTML (using $Web_Proc_Send) or simply with PRINT statements (unless $Web_Off has been issued).
%X = $Web_Type('text/HTML') %X = $Web_Put_Text( '<HTML>' ) %X = $Web_Put_Text( '
' ) %X = $Web_Put_Text( 'Hello World' ) %X = $Web_Put_Text( '</HTML>' ) STOP
See also
- $Web_Proc_Send can be used to send the contents of a Model 204 procedure, either as binary (that is, without translation) or translating from EBCDIC to ASCII.
- $Web_Put_Binary adds a string to the web output buffer without translation.