Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

euphoria
communitycreator
puts function

What is the puts() function in Euphoria?

NDUKWE CHIDERA K.

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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 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.

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 newline
puts(1, "\n")
--now this text will print on another line
puts(1, "A display after a new line has been printed")
--try other file numbers
puts(2, "\n This is file number 2")
Printing string and new line using puts() method

Explanation

Notice how the file numbers 1 and 2 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.

  • 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.

RELATED TAGS

euphoria
communitycreator
puts function

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring