Euphoria is an interpreted language that is easy, flexible, and simple to get started with. It is used in building desktop applications and applications for other platforms. In Euphoria, a lot of subroutines exist that are inbuilt to the language and are available at every installation.
As a programmer, we have the ability to write a subroutine for use anywhere in our code. We can achieve this by writing:
A procedure is a program structure in euphoria. It can contain sets of instructions to carry out computations that may need parameters.
Procedures are important because they enable developers to write reusable code blocks. These blocks can be used anywhere in the program. Procedures are similar to functions except that they do not return anything, unlike functions, which have return values.
procedure identifier(parameter)
// code to execute
end procedure
procedure
keyword.identifier
to the procedure.identifier
.end procedure
statement.Afterward, to use the procedure, we simply call it by writing down its identifier
followed by the parentheses with the parameters (if any), as shown below:
identifier(parameter)
Let’s write a simple procedure that welcomes users to our program.
procedure greetings(sequence name)printf(1,"Welcome %s to Edpresso",{name})end proceduregreetings("Friend")
greetings
and give it a parameter of sequence type name
.Friend
to the parameter name
.Whereas in a function, we can save the value of the executed code in a variable and return it to use in other expressions or functions, we can’t do this in a procedure, as the latter does not return a value.