To use this website fully, you first need to accept the use of cookies. By agreeing to the use of cookies you consent to the use of functional cookies. For more information read this page.

Input and Output methods

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 with one of two functions: print or the std_out function, which print actually aliases (thus std_out is actually a faster version of print).

YASS
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:

YASS
print("Hello", "world!")

A third function for displaying an output is the write function that was added in ZPE 1.7.11:

YASS
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:

YASS
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:

YASS
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:

YASS
$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:

YASS
$v = get_yes_no("Please insert a value")
  1. Create a simple program that takes in an input asking for the user's name and displays it back to them.
  2. Modify the program to display the name in a string, for example if the user's name was Jamie it would display Hello Jamie!.
Read more
  1. std_out
  2. std_in
Provide feedback on this page
Comments are sent via email to me.