


Variables are declared with a $
sign at the start of them,
as with PHP, Perl, Bash and many other scripting languages.
Variables should not be names of keywords, e.g.
$is
or $list
is
not a valid name for a variable.
$a = 43 $b = true $c = false $d = "Hello" $e = $a || $b $f = $c
As of version 1.5.3 the variable index syntax has been included, however, it should be avoided before version 1.6.3 since it was buggy.
$a = [43, 44, 45] print($a[1])
Version 1.5.0 added support for hexadecimal and octal values straight from the compiler. The compiler works these out and transforms them to their integer equivalents during compile time.
The following sample shows this:
$hex = 0x43 $octal = 033
Hexadecimal numbers start with a 0 followed by an x followed by an hexadecimal values.
Octal numbers start with a 0 followed by any octal numbers.
These styles were borrowed from C.
ZPE 1.6.7 adds support for typing through the TYPO system. TYPO is a compiler-based typing system designed for educational use but also to add stricter programming practices to ZPE.
ZPE has 8 primitive types as of version 1.6.7 (prior to that it had several others, but most have since been combined into the object syntax such as the image type).
The types are as follows:
ZPE does not distinguish the difference between an integer value and a double value until assignment has taken place. The same goes for lists and maps, which both come under the List type but are represented differently in memory.
$a as string = "Hello" $b as number = 10 $c as number = 10.5 $d as boolean = true $e as list = ["Hello", "World"] $f as list = ["Hello" => "World"] $g as function = function() { print("Hello world") } $h as object = {name : "Jamie"}
As with all built-in ZPE keywords, types and the as
keywords are all lowercase when using the case sensitive compiler.
Version 1.6.7 also added inline assignment which was originally thought to be a complicated procedure but ended up being relatively simple. This syntax allows declarations to take place within other expressions, e.g. an if statement:
$f = new ZPESequentialFile() $f->open("list.txt") while (($check = $f->has_next()) == true) print($f->read_line()) end while
Notice that the assignment is bracketted! This is so important to prevent the compiler parsing it as a boolean assignment.
$x = get_input("Insert a value.") if (($v = $x + 3) == 10) print($v) end if
This type of assignment was added in ZPE 1.6.7 and improved over time.
Actually seen as an odd side effect of the compiler (and I'm not entirely sure which version added support for it as of yet), multiple assignment in ZPE/YASS is very easy:
$w = $x = $y = $z = 10 print($w) print($x) print($y) print($z)
As mentioned above, I am not sure which version this was added in since it is a side-effect of some other compiler feature and was not intentional.
Use this form to test a variable name.
Use this tool to test a variable name for validity.
![]() | Happy New Year everyone! #2021NewYear 14 days ago |
![]() | Happy New Year everyone! All the best, Jamie Balfour. 14 days ago |
![]() | Retweet @PCMag: Adobe Flash support officially ends today. https://t.co/NNLcFK2yPx ![]() 14 days ago |
There are no comments on this page.