XtScript: Include
Learn how to load and read XtScript file from an external file using Include command
Having a long XtScript codes in one block could be confusing and hard to manage especially on mobile device with small screen. That's when the include command come in handy.
We can load external XtScript file and use on our codes using include command. XtScript file has .xt extension.
After we have included an XtScript file, the command and script written in the file will be executed and run normally.
We also can access the variable declared in the included XtScript file by adding @ prefix to the variable name (e.g. @$variable).
Learn XtScript Include from example
Include an XtScript file named "xtscript-include.xt" at /demo/ directory on this site.
- Code:
Here is what is written inside the included XtScript file:
- Code:
<!--parser:xtscript--> # Include an XtScript file. The path is relative to this site directory include /demo/xtscript-include.xt # Use "@" prefix to access the variable in the included XtScript file print <p><b>I am playing games using my @$device</b></p> <!--/parser:xtscript-->- Result:
This is some parapraph from $text variable written in a file named "xtscript-include.xt" that located at /demo/ directory on this site.
I am playing games using my Tablet
var $text = <p>This is some parapraph from \$text variable written in a file named "xtscript-include.xt" that located at <i>/demo/</i> directory on this site.</p> var $device = Tablet print $text
Last edited on