What is the puts() function in Euphoria?
Overview
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.
Parameters
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 thecontentto standard output or any other output according to the indicated number. Commonly used is1or2. The parameter cannot be0or 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.
Return value
The puts() method will print the strings for string data. This implies that the puts method is better suited for printing strings for readability.
Example
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")
Explanation
Notice how the file numbers
1and2prints 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.
- Lines 11–13: These lines contain different attempts to print to screen using the
puts()method to see how it operates. There are comments in between as well.