Text and Html statements
The HTML or TEXT statement
The Html (or Text) statement in User Language is a general purpose alternative to a series of Print statements for producing a fair amount of literal data. Primarily for use with Janus Web Server (hence the name Html), it is available with many Sirius products. It is most useful when PRINT output is captured or directed by some means. It is also quite useful for populating a StringList with a large amount of mostly constant text. This latter capability is provided by the To option of the Html/Text statement.
In this section, “HTML block” refers to either the Html or Text block.
The Html block can be used to produce print output of largely literal or static data. For example, sending output to a browser with Janus Web Server often requires a significant quantity of static text for HTML directives. Rather than placing this static data inside quotes in a Print statement, the Html block will automatically assign text as print output. Any Model 204 expression, including simple %variable values or $function invocations, can be placed inside an Html block, as long as it is enclosed inside the expression start and end characters. The default start and end characters are the curly brackets ( { ) and ( } ).
The following is an example of an Html statement specification:
HTML <form method="POST" action="processform">
Last name: <input type="text" name="lname" value="{%LNAME}"> </form> END HTML
The syntax of the Html and Text blocks is shown below:
HTML [options] body block_end_line
or
TEXT [options] body block_end_line
options, body, and block_end_line are discussed below.
The components of the Html or Text block are discussed in the following sections. The Html (or Text) block can be used in contexts other than the production of a web page. For example, it can be used:
- To store lines in a temporary procedure or sequential dataset, using the USE command
- To populate a StringList, using the To option on the Html/Text statement
- To populate a $list, using the $LIST_CAPTURE function
- To send lines over a Janus Sockets connection, using the $SOCK_CAPTURE function
- To prepare output processed by some other program, when the output is created by something like a BATCH2 or RCL connection to Model 204 Here are some advantages of the Html/Text block:
- User Language is visually close to the output.
- Literal text does not need to be enclosed in apostrophes.
- The Print keyword is not necessary.
- Any valid Model 204 expression can be included inside an Html block, not just literals, %variables, fieldnames, $functions, and a few other constructs.
- The With and And keywords are not needed between expressions.
- Apostrophes do not need to be doubled, as in:
PRINT 'Just say ''No'''
The following is an example of an Html block using JavaScript to illustrate applications of the Html/Text options:
HTML NOCONT EXPRS '!{' EXPRE '}!' <html> <head> <title>My Javascript Page</title> </head> !{$SIR_DATE('Wkd Mon DD YYYY HH:MI:SS')}! <br> <body> <script> <!-- name=prompt("Person's name","Type name here"); END HTML %S1='if (name=="' FR WHERE RECTYPE=PHONE PRINT %S1 WITH NAME - WITH '") {document.write("' WITH EXTN WITH '")}' %S1='else if (name=="' END FOR HTML NOCONT EXPRS '!{' EXPRE '}!' else {alert ("Unkown person")}; --> </script> </body> </html> END HTML
Html statement options used in this example:
- Nocont is used to turn off continuations signified by trailing dashes. In the JavaScript, dashes are used in an input line that prevents browsers without JavaScript from displaying script as literal output.
- Exprs and Expre let you use characters other than the curly brackets ( { } ) to demarcate expressions. The curly bracket characters are necessary in JavaScript.
New in Sirius Mods version 6.0, the Html block is available to any customer who owns any of the following products:
- Fast/Unload User Language Interface
- Janus SOAP
- Janus Sockets
- Janus Web Server
- Sirius Functions
The Html block is also available if the Limited Janus Web Server capability is available.
Options: Html or Text block options
The various options for an Html or Text block are introduced after the Html or Text keyword. They are described in the following subsections.
Data, Print, Audit, or Trace
These keywords indicate that the Html block consists of only the text that follows the keyword on the logical line: that is, there is no End Html statement to end the block.
Prior to Sirius Mods version 7.2, only the Data keyword had this effect, and the Print, Audit, and Trace keywords did not exist.
Any Html statement keywords that appear after a Data, Print, Audit, or Trace keyword are processed not as keywords but simply as text. If you want to specify keywords in addition to a Data, Print, Audit, or Trace keyword, they must appear before Data, Print, Audit, or Trace to be treated as a keyword.
All other Html block processing, including expression processing, is performed on the line as if it were inside an Html block. The exception is Nodummy processing, because dummy string replacement is performed before the Html statement is parsed.
Data or Print
Either of these keywords can be thought of as providing a single-line Html/Text statement which can still be much easier to type and read than a User Language PRINT statement, as in:
HTML DATA Don't need to worry about apostrophes TEXT PRINT {%I} + {%J} = {%I + %J}
The following is an equivalent alternative to the second statement in the preceding example.
PrintText {%I} + {%J} = {%I + %J}
The PrintText statement has the same effect as a Text Print statement. The PrintText keyword is simply a merging and reordering of Text Print to emphasize the principle action. The lone difference between PrintText and Text Print is that PrintText cannot be used if you want to include other Html/Text options, as in:
text noexpr print The set is {2, 3, 5, 8, 13, ...}
The Data keyword is available in Sirius Mods 6.2 and later. The Print and PrintText keywords are available in Sirius Mods 7.2 and later.
Audit
This keyword provides a single-line Html/Text statement that functions like a User Language AUDIT statement, that is, routing subsequent text to the audit trail.
For example, this statement directs the text content to the audit trail:
text audit It ({$time}) was the best of times
The following is an equivalent alternative to the preceding example.
AuditText It ({$time}) was the best of times
As with the PrintText keyword above, the AuditText statement has the same effect as a Text Audit statement, except it cannot be used if you want to include additional Html/Text options.
The Audit keyword is available in Sirius Mods 7.2 and later. The AuditText keyword is available as of Sirius Mods 7.2.
Trace
This keyword provides a single-line Html/Text statement that is the same as a User Language TRACE statement, that is, routing subsequent text to the trace destination (which may be the audit trail, print device, or CCATEMP trace table, or a combination of them). For example, this statement directs the text content by default to the audit trail:
text trace This day ({$date}) is unlike any other
The following is an equivalent alternative to the preceding example.
TraceText This day ({$date}) is unlike any other
As with the PrintText and AudiText keywords above, the TraceText statement has the same effect as a Text Trace statement, except it cannot be used if you want to include additional Html/Text options. The Trace and TraceText keywords are available as of Sirius Mods 7.2. The Trace statement is described in detail in the SirFact Reference Manual.
Ent_print
The Ent_print keyword overrides the current $ENT_PRINT setting for character entity translation over the Html block. Ent_print must be followed by one of these keywords:
Off | No character entity translation will occur over the Html block. |
On | All data printed by the Html statement will undergo character entity translation. |
Var | Only the results of expressions will undergo character entity translation. |
Character entity translation is the process of converting a single character that might be problematic in certain contexts to a more verbose but non-problematic equivalent. For example, if a “less than” sign (<) appears in HTML text, it should typically be represented as “<” to prevent an HTML processor from mistakenly interpreting it as the start of an HTML tag.
When entity translation is performed, the default translations are “&” to “&”, “<” to “<” and the double quotation mark character (") to “"”. These defaults should be sufficient for most HTML and XML applications (though XML might also require translation of the single quotation mark character (') to “'” if attributes are enclosed in single quotation marks), but they can be modified with the $ENT_TAB function.
The Ent_print keyword is a compile-time option that affects only what is inside the Html block and that is not affected by evaluation time setting of $ENT_PRINT, even within the Html block. If no Ent_print keyword is present on the Html statement, character entity translation is controlled by the evaluation-time $ENT_PRINT setting. Automatic character entity translation and the Ent_print keyword on the Html/Text statement are only available in Sirius Mods 6.2 and later.
LiteralsToTemp
The LiteralsToTempt option indicates that the literal data in the statement is stored in CCATEMP rather than STBL, avoiding excessive demands on STBL space. Designed for a Text statement with an unusually large amount of literal data, this is an alternative to setting the X'01' bit of the SIRCOMP user parameter (which performs the same function).
Nocom or Nocomments
The Nocomments (abbreviated Nocom) option indicates that lines beginning with an asterisk (*) are not comment lines. For example:
HTML NOCOM * This line will go to the output END HTML
Nocont or Nocontinuations
The Nocontinuations (abbreviated Nocont) option causes trailing dashes to cease being treated as line continuations. For example, the following statement will cause the output to appear on two separate lines:
HTML NOCONT English: B- Social Studies: C END HTML
Nodum or Nodummy
The Nodummy (abbreviated Nodum) option stops dummy string substitution. For example, the following statement will cause the literal string ?&W to be output without global variable substitution:
HTML NODUM Hello, ?&W END HTML
Noell or Noellipses
With the Noellipses (abbreviated Noell) option, a trailing ellipsis (...) is not treated as a concatenation operator. For example:
HTML NOELL These lines are not joined... They will appear on different lines. END HTML
Noexpr or Noexpressions
If you do not want expression substitution, specify Noexpr or Noexpressions. For example:
HTML NOEXPR {This will be sent directly to output} END HTML
Raw
The Raw option acts as Nocom, Nocont, Nodum, Noell, and Noexpr all at once.
====Noend====
The Noend option eliminates the block end line. Thus, the block will terminate at the end of the procedure. For example:
PROC FOO HTML NOEND Now we are in HTML. END HTML Still in HTML. END PROC
Exprs or Exprstart
The Exprstart (abbreviated Exprs) option specifies a string, up to three characters long, that begins an expression within the block body. The default is a left curly brace ( { ). For example:
HTML EXPRS go EXPRE stp The answer is go8*9stp HTML END
It is probably best to use start and end sequences that are not likely to occur in the literal text in the Html/Text block and that clearly demarcate expressions from literal text. The go and stp in the example above are actually not very good choices.
If the expression start string occurs in the input text, you can “double” the expression start and end strings, instead of using the Exprs and Expre options. For example:
HTML <script> {{alert("User error")}} <script> END HTML
An alternative way to handle the curly braces in the script above is shown in the Html block example at the beginning of this chapter: that is, specifying HTML EXPRS '!{'EXPRE '}!' and !{alert("User error")!}.
Note: If you use multiple special characters to demarcate expressions, you are advised to enclose those characters in single quotation marks (as above) in your Exprs and Expre specifications. Otherwise, multiple-character combinations involving certain special characters (including these six, for example: = ¬ ( ) < > ) cause M204.0580 errors.