puts()
is an inbuilt function that displays the content. It is part of the Euphoria core functions. That is the standard library file that holds the puts
function, and it does not need to be included in your code to use it. It is in the same group as the print()
and printf()
methods in Euphoria, which are used to print the output.
It accepts only two parameters: first, the file number, and second, the content to display.
file_number
: This integer value tells the parser to print the content
to standard output or any other output according to the indicated number. Commonly used is 1
or 2
. The parameter cannot be 0
or missing; it is required.
content
: This is what you want to print to display. It can be a string sequence, an atom, or whatever you wish to print, even a new line.
The puts()
method will print the strings for string data. This implies that the puts
method is better suited for printing strings for readability.
In the code below, we’ll print outputs using the puts()
method.
--we delve straight into using the puts()puts(1,"I am displaying this using puts")--printing newlineputs(1, "\n")--now this text will print on another lineputs(1, "A display after a new line has been printed")--try other file numbersputs(2, "\n This is file number 2")
Notice how the file numbers
1
and2
prints have different standard outputs.
Multiple puts()
functions will print everything on the same line. So that is why on line 5
in the above code snippet, we used the \n
special to separate them.
puts()
method to see how it operates. There are comments in between as well.