tutHelloWorld

Euphoria Tutor

Hello World


A common example used by lots of people to demostrate a programming language, is a program that just displays "Hello, World!" or something similar on the screen.

The simplest "Hello World" program in Euphoria has only a single line of code ...

puts(1, "Hello, World!") 

That's it, just a single line of code.

Now let's break it down to look at its details.

The first word on the line, puts, is the name of a routine. A routine is a named set of code that has been designed to do a specific task. In this case, the routine called puts is designed to send the text string in its second argument to the file handle given in its first argument.

In our example program here, the second argument is the text string literal "Hello, World!", and the file handle is in the first argument is the integer 1. Euphoria has three predefined file handles that are always ready for a program to use.

File Handle Description
0 The standard input device, normally the keyboard.
1 The standard output device, normally the screen.
2 The standard error device, normally the screen.

So our program here is sending the text "Hello, World!" to the screen.

Try it yourself. Open your text editor and start a new, empty file. You can then either type in the one-line program code that is shown above, or copy-paste it from this page. Once that is done, save the new file to your computer's disk - you can call it whatever you like, but I'd suggest something like 'helloworld.ex'. Note that the '.ex' file type is one of the default ones recognized by Euphoria as a program text file.

Now, assuming you have installed Euphoria and can get a command window open, make sure the current directory is set to where ever you saved the hello world program, then at the command prompt, enter ...

eui helloworld.ex

and the program should run and display that text onto your window.

Note that eui is the name of the Euphoria interpreter, which checks your program for syntax mistakes, and if all looks fine it, then it runs your program.

Search



Quick Links

User menu

Not signed in.

Misc Menu