Since YASS takes inspiration from many language, YASS is similar to many languages
in the sense that it has a simple print
function and a simple
input
function. These functions however, are not as straightforward as
they may look and their underlying implementation is different to some other languages.
stdio
Back in the days of C and before, the term stdio became popular for describing the function that was used for input and output. Its name means standard I/O (input/output) and its a reference to the standard I/O or stdio library that is used in the C programming language, for example.
ZPE is built upon Java and the stdio library is a part of the implementation. By default, unless ZPE is redirected in either input or output, the input and output to and from any ZPE program is done with stdio.
Output
Standard output in YASS is done in either of two ways: using the print
function or
the std_out
function. These work totally differently underneath
but result in the same output.
print("Hello world!") std_out("Hello world!")
Both of these functions can also take infinitely many values and will join them into one value before displaying them:
print("Hello", "world!")
A third function for displaying an output is the write
function that was added in
ZPE 1.7.11:
write("Hello world!", 100)
write
works differently to the other two functions because it can expect a
delay beforing writing each character to the display. In this case, there will be 100 milliseconds
between each character being written to the display.
Finally, if an error occurs it is better to display an error using the std_err
function that will automatically format and handle the error:
std_err("There was an error in line", "25")
Input
Input in YASS is handled normally by the simple get_input
or the
std_in
functions:
get_input("Please insert a value") std_in("Please insert a value")
The following example uses a variable to store the result of an input:
$v = get_input("Please insert a value")
As well as these functions, there is also a built-in get_yes_no
function
that will give a true
or false
value based on the result:
$v = get_yes_no("Please insert a value")
- Create a simple program that takes in an input asking for the user's name and displays it back to them.
-
Modify the program to display the name in a string, for example if the
user's name was Jamie it would display
Hello Jamie!
.