XtScript basics
print
print and print_raw sends output to the page
Syntax
print [...][...] optional · ... your value
Notes
print is probably the most important command in Xtscript
In Xtscript print Certain characters and constructs are reserved
- print cannot be used directly with functions
you need to assign the function to a variable and then print the variable
Although if you call a funtion direct the result is printed anyway
- The reserved constructs $name and ( expression ) can be printed by escaping them with a \
It is usually enough to escape only the opening (
- print $variable_name will print the value of the named variable
- print \$variable_name will print $variable_name
- print (3+4) will print the evaluated result of the contents of the brackets ie. 7
- print \(3+4) will print (3+4)
- multi line print is achieved by wrapping the text in doubled curly brackets ie.
print {{ Print
on
multiple
lines }}
The newlines are not converted to linebreaks
- { and } may need to be converted to their html entities depending on circumstances
{ = { {
} = } }
- A semicolon ;cannot be the last character of a print line
The ; can be assigned to a variable using the chr function and then that is used in its place
- print_raw will output the string unparsed Except for "get" variables and {{ }} wrappers
Example
<!--parser:xtscript-->
var $variable=test value
print Usually you only need to escape the first bracket<br />
print This \$variable and \(3+4) are escaped with \<br />
print This "$variable" and "(3+4)" have not been escaped<br />
print The "get" variables break as \ is not a valid character here and the \$variable is escaped<br />
print {_$\$variable|default} and {_\$func|default}<hr />
#A direct function call prints the result
print Direct function call<br />
call strrev $val=$variable
print <hr />
# Use ; ;(semicolon space semicolon) for semicolons at the end of a print line
print This will still work on some browsers but the ; will be missing in the source code &
print <br />add a semicolon to an end of line entity & ;
# Multi line print
print {{<br />printing
on multiple
lines<br />}}
# Print_raw
print_raw {{print_raw prints
everything like $variable and (3+4) unparsed<br />
it will still parse {{ }} wrappers and "get" variables
"{_$$variable|default}" and "{_$func|default}"<br />
To show the text use an entity to replace {<br />
"{_$$variable|default}" and "{_$func|default}"}}
<!--/parser:xtscript-->Copy as text
Usually you only need to escape the first bracket
This $variable and (3+4) are escaped with \
This "test value" and "7" have not been escaped
The "get" variables break as \ is not a valid character here and the $variable is escaped
default and print
Direct function call
eulav tset
This will still work on some browsers but the ; will be missing in the source code &
add a semicolon to an end of line entity &
printing
on multiple
lines
print_raw prints
everything like $variable and (3+4) unparsed
it will still parse {{ }} wrappers and "get" variables
"default" and "print"
To show the text use an entity to replace {
"{_$$variable|default}" and "{_$func|default}"
Related