Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Official ZPE/YASS documentationIncluding other code

Official ZPE/YASS documentationIncluding other code

One of the greatest things about C or PHP is being able to include other code files. ZPE has supported libraries since a minor version of version 1.3 and yet as of version 1.5, it has no way to include a script, other than the run_script function.

To make development of larger applications more efficient, ZPE 1.5.1 and onward feature the includes keyword. This keyword signifies to the compiler to include a file's contents. The file should be UTF-8 text but the extension does not matter.

It's really easy to use the new feature by simply using:

YASS
includes "file_to_include.txt"
        

Inclusion is done at parse time (the step before compliation) and therefore if a program is compiled with a file included the file cannot be modified after.

If the file contains valid ZPE/YASS code, the code is included as part of the main application script and compiled as part of it.

Online code

Code from ZPE Online can be added using the ID of the file. For example, the file 'The Standard Algorithms' is availble publicly on ZPE Online and has the ID 'b7eb6c689c037217079766fdb77c3bac3e51cb4c'. To include it, ZPE will fetch the latest version from ZPE Online and include it's code:

YASS
includes online "b7eb6c689c037217079766fdb77c3bac3e51cb4c.txt"
print(gcd(54, 6))
        

The above will include the code from 'The Standard Algorithms' file from ZPE Online and then using the gcd function defined in there, calculate the GCD of two numbers.

Comments
Feedback 👍
Comments are sent via email to me.