The Very Basics

Getting Started with a Simple Program

Programmers create computer programs. Since we learn best by example, I'm going to create a very simple Euphoria program. Remember, a program is input that the computer uses to determine what it should output. Type the following line into a text file and save it as add.ex. (If you're using RDS' ed, just type ed add.ex from a command line.)

? 23489 + 1293374

The question mark is a shorthand way of saying, "print to the screen." I'll give you more details later. For now, just follow along.

At this point, the computer doesn't actually "understand" our program. The computer only understands numbers arranged in long sequences of ones and zeros. So, we'll need something (another program) to translate the program code in our text file so the computer understands it. We need a program to interpret our input and give it to the PC in a form it understands. That's where Euphoria comes in. Euphoria is a program interpreter, because it takes a program written in Euphoria syntax (that is, using Euphoria rules and grammar) and translates it into computer speak (ones and zeros).

When you "run" or "execute" the program, the Euphoria interpreter will convert it into machine-readable code and give that to the PC. Your PC will then take that input and provide you with output. So, let's run the program by typing the following:

eui add.ex

If everything is set up properly, you should see the following output on your screen:

1316863

By having our input (the program itself) inside a text file, I can send it to the interpreter any time I want! It also saves me from having to retype the input each and every time I want to know the sum of 23489 and 1293374.

For the rest of this book, anything that is input to the computer will be shown in Courier font on a light blue background (like above). Anything that is output from the computer will be shown in a Verdana font on a light blue background (like above).