The Euphoria Programming Language version 3.1.1 (Euphoria)

by shian ⌂ @, Israel, Thursday, March 05, 2020, 10:17 (32 days ago)
edited by shian, Monday, March 16, 2020, 13:19


What is Euphoria?

Euphoria is a simple, fun, flexible, and easy-to-learn programming language. It lets you quickly and easily develop programs for Windows, DOS, Linux and FreeBSD. Euphoria was first released in 1993. Since then Rapid Deployment Software has been steadily improving it with the help of a growing number of enthusiastic users. Although Euphoria provides subscript checking, uninitialized variable checking and numerous other run-time checks, it is extremely fast. People use it to develop Windows GUI programs, high-speed DOS games, and Linux/FreeBSD X Windows programs. It is also very useful for CGI (Web-based) programming.

The Euphoria package is now completely free, and the download package even includes the full, open source code.

Let me add thanks to the author of the Euphoria programming language Robert Craig.

[ From: What Is Euphoria? ]

Euphoria 3.1.1 Download Page

"Everyone knows the truth about himself, except the fool who considers himself wise". (

[Relatively] Simple lessons in Euphoria

by shian ⌂ @, Israel, Thursday, February 06, 2020, 16:30 (60 days ago) @ shian
edited by shian, Thursday, March 05, 2020, 10:49

Here I want to add relatively simple lessons or example programs in Euphoria 3.1.1.

Read the Euphoria Reference Manual to learn more.

I assume that you've already downloaded Euphoria and that you've already installed it correctly (don't forget to add the euphoria's 'bin' directory to your PATH environment variable, and don't forget to add the 'euphoria' directory to EUDIR environment variable). Read the documentation if you have a problem to install Euphoria.

OK, so just use your intuition, copy/paste the code to a text file, run it and learn more about it.

The examples are for beginners in Euphoria and/or in programming.

You should run the examples in the hostile "black-box" (the terminal/console/shell. In Windows it's called 'cmd' or 'power shell'. In Linux it's usually called 'Bash'. In DOS it's usually called DOS.).

By the way: the best "black-box" is DOSBox, with support for graphics and much much more! - it's the best way to learn programming IMHO.

You better download also Lib2, and use the 'edu' editor for programming in Euphoria 3.1.1 (it's simple and has context-sensitive-help for keywords using control-K).


"Everyone knows the truth about himself, except the fool who considers himself wise". (

app-1: Inches to cm (centimeters) converter

by shian ⌂ @, Israel, Thursday, February 06, 2020, 16:44 (60 days ago) @ shian

A bit hard for really beginners - yet interesting!

-- app-1: Inches to cm (centimeters) converter

-- ( 1 in = 2.54 cm; 1 cm = 0.39370079 in )

-- I used the editor 'edu', from 'Lib2 version 1.41' to create this
-- application. In 'edu' press Control-K on any keyword to get help.

-- include the standard routine 'prompt_number()' from library get.e
include get.e

-- constants (read-only variables of any kind) are making the code
-- easier to read, understand and maintain - so let's use them for
-- the variable 'choice':
constant QUIT = 0,
     IN_TO_CM = 1,
     CM_TO_IN = 2

constant SCREEN = 1 -- Yes, the screen device number is always 1

-- variables: atom can hold any number; sequence can hold any sequence
--            of numbers or complex structure of numbers, or a "string"
--            (there is no actual string-type in Euphoria...):
sequence prompt
atom choice, number, result

-- clean the screen (the "black-box"/"terminal"/"console")

-- let's impress the user a bit with this title ('\n'=new line):
puts(SCREEN, "An Advanced in2cm Converter(c)\n")
puts(SCREEN, "------------------------------\n\n")

-- run the program inside an endless loop:
while 1 = 1 do

    -- choose what to convert (press 0 to quit)
    prompt = "Enter [0,1,2] - Quit, inch-to-cm, cm-to-inch: "
    choice = prompt_number(prompt, {0, 2})

    choice = floor(choice) -- round down the user's choice

    if choice = IN_TO_CM then
        number = prompt_number("\tEnter value in inch: ", {})
        result = number * 2.54
        printf(SCREEN, "\t%g inches are %g centimeters", {number, result})

    elsif choice = CM_TO_IN then
        number = prompt_number("\tEnter value in centimeters: ", {})
        result = number * 0.39370079
        printf(SCREEN, "\t%g centimeters are %g inches", {number, result})

    elsif choice = QUIT then
        puts(SCREEN, "----------------------------------------------\n")
        puts(SCREEN, "Thanks for using our advanced in2cm converter!\n")
        exit -- exit the program's while-loop (end the program)

    end if

    puts(SCREEN, "\n\n\n") -- print 3 empty new-lines

end while -- return to the start of this loop

-- here the program ends.


"Everyone knows the truth about himself, except the fool who considers himself wise". (

app-2: Guess a number between 1 and MAX_VALUE

by shian ⌂ @, Israel, Friday, February 07, 2020, 11:06 (59 days ago) @ shian

-- app-2: Guess a number between 1 and MAX_VALUE

-- include the standard routine 'prompt_number()' from library get.e
include get.e

-- constants are read-only variables (usually using capital letters)

-- you can set the maximum (integer) value from 1 to 1073741823
constant MAX_VALUE = 1000

-- create a random number (integer) between 1 to MAX_VALUE
constant SECRET_NUMBER = rand(MAX_VALUE)

constant TRUE = 1, -- in Euphoria FALSE is 0; TRUE is 1 (or non-zero)
       SCREEN = 1  -- the screen device-number is always 1

-- these are variables (not constants)
sequence prompt -- sequence is a sequence of numbers (see manual)
atom number     -- atom is any number
integer counter -- integer is a fast (but limited) atom

counter = 0     -- initialize the counter for user's guesses

-- clean the hostile black-box

-- run the program in an endless loop (TRUE is always true...),
-- until user find the secret number.
-- (control-C will stop the program. In Linux use control-D to stop.)
while TRUE do

    -- prompt the user to enter a number (sprintf() and printf() are used
    -- to format numbers and convert numbers to strings)

    prompt = sprintf("Guess a number between 1 to %d: ", MAX_VALUE)
    number = prompt_number(prompt, {1, MAX_VALUE})

    -- round down the user's number, e.g. 1.34 --> 1
    number = floor(number)

    -- test the user's guess
    if number > SECRET_NUMBER then
        puts(SCREEN, "\tToo high!\n\n") -- ( '\t' is tab character )

    elsif number < SECRET_NUMBER then
        puts(SCREEN, "\tToo low!\n\n")  -- ( '\n' is new-line character )

    else -- number = SECRET_NUMBER
        puts(SCREEN, "\n---------------------------------------\n")

            "Congratulations! the secret number is %d.\n\n", SECRET_NUMBER)

            "But you know... you've missed %d times... just for the record.\n",

            exit -- exit the while-loop (end of program)
    end if

    -- OK, user is wrong again... add 1 to counter
    counter = counter + 1   -- ( counter += 1 )
end while

-- end of program.

"Everyone knows the truth about himself, except the fool who considers himself wise". (

Euphoria & Data types - what's the big deal?

by shian ⌂ @, Israel, Friday, February 07, 2020, 19:53 (58 days ago) @ shian
edited by shian, Friday, February 07, 2020, 21:39

The computer's hardware has only one basic data type: integer.

integer can be made of 4-bits, 8-bits (bit is 0 or 1), 16-bits, 32-bits, 64-bits, 128-bits, etc.

Modern computers can take 64-bits integer or even longer integer and use one of its bits as a decimal point (simplified), therefore modern computers can deal with another data type: floating point.

OK, that's all you need to know: your computer has only two data types: integer and floating point (which is still an integer but is dealt differently by the CPU).


Any programming language is "faking" data types of many kinds: Boolean, String, Double, Single, Integer, Byte, Array, Dictionary, Complex Number, Date, Map, Tree, Currency, Vector, etc, etc, etc.

Well I said "faking", yea. All of these data types are not necessarily exist in your hardware, these are just software libraries that provide "new" data types. Well that's great :-P!! isn't it?

Isn't it great to have lots of data types for any purpose under the sun? Not really :-|.

A programming language that provides lots of data type - must provide lots of functions, methods, and all kinds of tricks which allow you to manipulate each individual data type. And I'm talking about LOTS of stuff. So that the programming language looks like a huge supermarket and you're supposed to remember where are your favorite things that you like to buy. That's not easy.

Now, instead of having to remember 30 different data types, and the functions that manipulate each one of them, like sort_integer(), sort_map(), sort_double(), etc - imagine that you could represent and manipulate all data types as just one data type... well this is what Euphoria does: it takes the only data types that your hardware knows, integer and floating point, and use them as integer and atom.

But how can Euphoria deal with a Vector, Array, Map, Single, Date, Boolean - and all that nonsense? In Euphoria we call that nonsense a flexible sequence. Which simply means that the sequence is flexible so you can use it in any way you want, period.


In Euphoria we don't need LOTS of functions to deal with each individual data type - we can have a single function, like sort(), that will sort anything (cats, dogs, letters, spaceships).

So Euphoria is unique, it has only two data types, atom and sequence, and another two data types just as helpers, integer and object: integer is a faster but limited atom; and object can be integer, atom or sequence - because, for example, our sort() function can sort anything and anything is simply called "object" (not to be confused with the "Object Oriented Programming" punishment).

OK - that's it. Go figure why programming languages are SOOOOOOO complicated!

That's why Euphoria is extremely simple and powerful; mainly because of the no-data-types concept. Still don't believe? download Euphoria and try it by yourself.

"Everyone knows the truth about himself, except the fool who considers himself wise". (

RSS Feed of thread
powered by my little forum