Disneyland 1972 Love the old s
/ /

XtScript Function: chr

Returns the character with the given numeric value.

chr is an XtScript function to call and return character in their hex or decimal numeric value.

XtScript chr function is pretty handy if you want to print or use a character that are illegal or reserved by XtScript like semicolon (;). This work for example by assigning a chr function with the character value in the argument, then use the variable instead the illegal character.

XtScript chr function basic syntax:

<!--parser:xtscript-->
	call chr $val=...
<!--/parser:xtscript-->

Learn XtScript chr function from examples

Print invalid or reserved characters in XtScript

- Code:
<!--parser:xtscript-->
	# Assigning a semicolon to a variable using its decimal value
	var $sem = call chr $val=59

	# Assigning a space to a variable using its hex value. Character hex value must be prefixed with "0x"
	var $spa = call chr $val=0x20

	# Print a semicolon
	print A semicolon is printed behind this line $sem
	print <br/><br/>

	# Normally, a space as the last character cannot be printed, but it can by assigning it into a variable
	print Linebeforespace$spa
	print LINEAFTERSPACE
<!--/parser:xtscript-->
- Result:
A semicolon is printed behind this line ;

Linebeforespace LINEAFTERSPACE

Print a series of letters using loop method and chr function.

- Code:
<!--parser:xtscript-->
	# Assign the start of character decimal value
	var $cha = 65

	# Assign the end of character decimal value
	var $end = 74

	# Create the jump point to loop the operation
	@print_more

	# Work the loop method and print the characters
	if $cha <= $end
		call chr $val=$cha
		print <br/>
		var $cha = ($cha + 1)
		goto @print_more
	else
		goto @print_end
	endif

	# Jump point where the operation end
	@print_end
	print Operation complete...
<!--/parser:xtscript-->
- Result:
A
B
C
D
E
F
G
H
I
J
Operation complete...

For a complete of all characters ASCII hex or decimal value, you can read it on ASCII Characters Entity Code table