<!-- pragma [push|pop] name [value] -->
pragma directive, unlike any other directive, can appear
anywhere in the script, including inside a function. Pragmas
typically alter the way code is lexically analyzed, so that the pragma
can be applied only to certain code sections if desired. Since they
appear in comments, earlier Vortex versions that are not aware of a
particular pragma will ignore them silently (unless
--warn-unknown-pragma is in effect,
here). The pragmas available are:
strictcomment on|offTurn on or off strict comment parsing. With strict comments on, comments must start with "
<!--", not just "
<!"; thus tags such as "
<!DOCTYPE>" are directly printable and do not get interpreted as comments. The default is on. Added in version 3.01.986950000 20010410.
nestcomment on|offTurn on or off nesting of comments. With nesting on, comments may be nested. The default is off. Added in version 3.01.986950000 20010410.
literalprint on|offWhether to allow literal text and/or variable printing. With literal printing off, printing text or variables by simply placing literal text or -var references in the code is not allowed and will generate the compile error "Literal/variable printing not allowed when pragma literalprint off". Whitespace is still allowed but is silently ignored (instead of being output where not part of indentation); comments are also still permitted and ignored.
Turning off literal printing can be useful in some situations -
such as when generating an image - to ensure that all output
is being generated by explicit code, e.g. via
<fmt>, and no
inadvertent whitespace or mistyped code is causing extraneous
output, e.g. calls to non-existent functions being interpreted
as literal tags.
The default is on. Added in version 5.01.1223689000 20081010.
compilesqlexpressions on|offWhether to compile SQL expressions into the
.vtxobject file where possible, rather than interpret them on the fly at run-time. SQL expressions are used in parenthetical variable assignments (e.g. <x = (y + 5)>) and complex
<if>statements, amongst other places. Compiling them speeds up script execution, as the original expression then does not need to be re-interpreted by the SQL engine every time the statement is run. The default is the value of the
texis.inisetting [Texis] Compile SQL Expressions; if that is unset, the default is on. Added in version 6.01.
In version 7 and later, pragmas can be pushed or popped on a stack. Pushing a pragma sets the value given, but first preserves the current value; popping restores that previous value. Pushes may be nested to any depth. This allows local sections of code to alter a pragma's value, while still preserving and restoring the outer code's value (without needing external "magic" knowledge of what it is):
literalprint could be on or off here (original value)
<!-- pragma push literalprint off -->
<!-- literalprint is off here -->
<!-- pragma pop literalprint -->
literalprint is back to its original value
Each pragma has its own independent stack, which starts out empty
(causing the pragma's default value to be in effect). A normal pragma
"set" directive (i.e. a pragma with neither
pop) acts as a
pop (if stack is not empty), followed by
push. It is an error to explicitly
pop a pragma when
its stack is empty.
In this example, nestable comments are turned on. Thus the "
print bio of author" comment, which is inside a larger
comment, nests properly, and the entire inner
is commented out:
<!-- pragma nestcomment on -->
<SQL "select Title, Author from books
where Keywords like $query">
Title: $Title <!-- print title -->
Author: $Author <!-- print author -->
<!-- this section commented out:
<SQL "select Details from author
where Author = $Author">
Bio: $Details <!-- print bio of author -->