পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Wednesday, February 1, 2017

Euphoria - Procedures

A procedure is a group of reusable code which can be called from anywhere in your program. This eliminates the need of writing same code again and again. This helps programmers to write modular code.
Like any other advance programming language, Euphoria also supports all the features necessary to write modular code using procedures.

You must have seen procedures like printf() and length() in previous chapters. We are using these procedure again and again but they have been written in core Euphoria only once.
Euphoria allows you to write your own procedures as well. This section explains how to write your own procedure in Euphoria.

Procedure Definition

Before you use a procedure, you need to define it. The most common way to define a procedure in Euphoria is by using the procedure keyword, followed by a unique procedure name, a list of parameters (that might be empty), and a statement block which ends with end procedure statement. The basic syntax is as shown below −
procedure procedurename(parameter-list)

   statements
   ..........

end procedure

Example

A simple procedure called sayHello that takes no parameters is defined here −
procedure  sayHello()
   puts(1, "Hello there")
end procedure

Calling a Procedure

To invoke a procedure somewhere later in the script, you simply need to write the name of that procedure as follows −
#!/home/euphoria-4.0b2/bin/eui

procedure  sayHello()
   puts(1, "Hello there")
end procedure 

-- Call above defined procedure.
sayHello()
This produces the following result −
Hello there

Procedure Parameters

Till now you have seen procedure without a parameter. But there is a facility to pass different parameters while calling a procedure. These passed parameters can be captured inside the procedure and any manipulation can be done over those parameters.
A procedure can take multiple parameters separated by comma.

Example

Let us do a bit modification in our sayHello procedure. This time it takes two parameters −
#!/home/euphoria-4.0b2/bin/eui

procedure sayHello(sequence name,atom  age)
   printf(1, "%s is %d years old.", {name, age})
end procedure

-- Call above defined procedure.
sayHello("zara", 8)
This produces the following result −
zara is 8 years old.

No comments:

Post a Comment