# The Euphoria Programming Language 3.1.1

Contents

## 1. What is Euphoria?

Euphoria is a simple, 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.

## 1.1 Tutorial - Hello World!

```with trace
trace(1)

-- Tutorial - Print Hello World on the Screen

-- To run this tutorial,
--        Press Enter to execute the highlighted Euphoria statement.
--        Press F1 to flip to the main output screen.
--        Press F2 to flip back to this trace screen.

-- Step 1: Just to be neat - we'll clear the screen.
-- First, press F1 then F2 (Works best on DOS or DOSBox).
-- Then press Enter:
clear_screen()
-- Check again with F1/F2 - was the screen cleared?

-- Step 2: Let's position the cursor at line 10, column 30
position(10, 30)
-- Is the cursor now at 10,30? Press F1/F2

-- Step 3: Display the text:
puts(1, "Hello World")
-- Is the text there? Press F1/F2

-- Step 4 Output 2 blank lines and we're done
puts(1, "\n\n")
```

## 1.2 Example Program

The following is an example of a complete Euphoria program.
```-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sequence list, sorted_list

function merge_sort(sequence x)
-- put x into ascending order using a recursive merge sort
integer n, mid
sequence merged, a, b

n = length(x)
if n = 0 or n = 1 then
return x  -- trivial case
end if

mid = floor(n/2)
a = merge_sort(x[1..mid])       -- sort first half of x
b = merge_sort(x[mid+1..n])     -- sort second half of x

-- merge the two sorted halves into one
merged = {}
while length(a) > 0 and length(b) > 0 do
if compare(a[1], b[1]) < 0 then
merged = append(merged, a[1])
a = a[2..length(a)]
else
merged = append(merged, b[1])
b = b[2..length(b)]
end if
end while
return merged & a & b  -- merged data plus leftovers
end function

procedure print_sorted_list()
-- generate sorted_list from list
list = {9, 10, 3, 1, 4, 5, 8, 7, 6, 2}
sorted_list = merge_sort(list)
? sorted_list
end procedure

print_sorted_list()     -- this command starts the program

-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

The above example contains 4 separate commands that are processed in order. The first declares two variables: list and sorted_list to be sequences (flexible arrays). The second defines a function merge_sort(). The third defines a procedure print_sorted_list(). The final command calls procedure print_sorted_list().

The output from the program will be:
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.

merge_sort() will just as easily sort {1.5, -9, 1e6, 100} or {"oranges", "apples", "bananas"} .

This example is stored as euphoria\tutorial\example.ex. This is not the fastest way to sort in Euphoria. Go to the euphoria\demo directory and type "ex allsorts" to see timings on several different sorting algorithms for increasing numbers of objects. For a quick tutorial example of Euphoria programming see euphoria\demo\bench\filesort.ex.

Checksum
Euphoria Release Notes
How to Install Euphoria on Windows
How to Install Euphoria on Linux or FreeBSD
How to run Euphoria on 64-bit Linux
How to run Euphoria on 64-bit (& 32-bit) FreeBSD
Euphoria Reference Manual Part I - Core Language

Note: all .doc files are actually simple ASCII .txt files.

Lib2 is an extended standard library for the Euphoria Programming Language version 3.1, with lots of useful functions.

Lib2 includes also the edu IDE with context sensitive help (control-K), syntax coloring and more.

Checksum
Lib2 Release Notes

## 4. Utilities and Demo Programs

Checksum
• Rapid Deployment Software - The original Euphoria website (read-only).
• www.rapideuphoria311.com - (this site).
• www.rapideuphoria311.org - (this site).
• The x86 Interrupt List - aka "Ralf Brown's Interrupt List", "RBIL" (DOS API).
• Win32 API - Data Access and Storage: fileapi.h header (Windows API).
• The GNU C Library - libc, aka glibc (Linux / FreeBSD API).
• FreeDOS - a complete, free, DOS-compatible operating system.
• DOSBox - a DOS-emulator that's very easy to port to different platforms.
• WinWorld - from the past, to the present, for the future.
• VETUSWARE.COM - the biggest free abandonware downloads collection in the universe.
• HelpPC Reference Library - a DOS-based hypertext program by David Jurgens.
• DJGPP - a complete 32-bit C/C++ development system for Intel 80386 (and higher) PCs running DOS.
• Geany - a powerful, stable and lightweight programmer's text editor. Runs on Linux, Windows and MacOS.
• Linux Mint - a modern, elegant and comfortable operating system which is both powerful and easy to use.
• 7-Zip - a file archiver with a high compression ratio.
• QEMU - a generic and open source machine emulator and virtualizer.
• Try It Online - TIO is a family of online interpreters for an evergrowing list of practical and recreational programming languages.

## 6. FAQ

1. Why don't I use Open Euphoria version 4.x?
Can't avoid this one... Well, software in general is getting over bloated as time goes by, and in my case I don't need any of the new features. None. Nada.
2. No "string" data type in Euphoria 3.1.1?
From technical perspective a string is an array of numbers, moreover, any complex data type is literally a sequence of successive or arbitrarily nested numbers. Euphoria simply treats any complex data type as a sequence of numbers.
3. Euphoria 3.1.1 doesn't support Object Oriented Programming (OOP)!
The opposite is true: poor programmers are "stuck" with OOP for no apparent reason besides wrong decisions that were made decades ago.
4. Using bit manipulation in a very high level language?!
While Euphoria is a very high level language, it allows you to manipulate single bits in both high and low level manners.
5. Euphoria 3.1.1 lacks of essential libraries!
Sorry about it. Personally I've added Lib2 to extend the standard library of Euphoria 3, but I don't get paid for it. Adding libraries and wrappers to Euphoria 3 is voluntarily and fun.
6. Euphoria 3 does not have an ERROR handler???
For what? An error handler exists in some programming languages as a "safety net" or for an "instant solution" for hardware or software failures. In reality an error handler is a very poor approach for dealing with bugs, and of course - Euphoria 3 rightfully avoids this unnecessary feature.
7. Euphoria 3 does not support concurrent computing???
Any kind of database can be created with Euphoria, including random access database, CSV database, or anything else. The Euphoria Database System (EDS) is far more flexible and simple then SQL databases.
9. What about the data types in Euphoria 3?
Euphoria has only 4 builtin data types: integer, atom, sequence and object. You may also define your own data types very easily and with complete flexibility, to aid debugging.
10. Then why "nobody" is using Euphoria 3.1.1?
I use. I'm not a programmer and I don't have time for the nonsense of other programming languages... that's why.
11. What are the KEY POINTS of Euphoria 3?
At least some of them:
• Has an overall and well defined strategy by Robert Craig.
• Has a very professional and correct behavior, exactly what you would expect.
• All aspects of the language are polished and synchronized. Nothing is unrelated or indefinite.
• Extremely simple, readable, maintainable and logically-correct language.
• Powerful and rapid language without stupid elements.
• Very High Level language. No need to worry about low level issues.
• Minimalist language. Hence, Readable & Maintainable. Only what you really need for programming.
• No "Dead End". The language is extensible through libraries.
• Supports the main platforms: DOS, Windows, Linux, FreeBSD. Easy to write generic code that works on all platforms.
• A 32-bit language. On DOS as well.
• The data types issue is not exist in Euphoria 3. (The worst nightmare in other languages).
• The source code of Euphoria 3 is written in C and in Euphoria 3. Easy to compile for other platforms. (By a professional programmer).
• Can use and create shared C libraries.
• Interpreted language (with all the benefits that comes with it).
• Allows you to create standalone executable files, shrouded files or translated files.
• Suitable design for team's work.
• Very easy to create CGI (Common Gateway Interface) applications.
• Very safe language. Programming with confidence.
• Extremely fast interpreter.
• Open source language and already used and tested by many users.
• Pure and clean procedural language (like C or QBASIC). Not a bloated multi-paradigm language.
• Suitable for beginners and professional programmers.
• ...
12. Why atom? Why not double?
atom is a dynamic software data type - not a static hardware data type, therefore it is not double.
13. What happened to the Euphoria 3 users community?
They prefer to play with their "modern and cool" Smartphones (that silently radiates them to death).
14. Who should learn Euphoria 3 & Why am I doing this site?
I personally enjoy Euphoria 3. Others should learn Euphoria 3 as part of the process of detoxification of Smartphones, tablets and the big corporations brainwashing.
15. Only 3 scopes + 1 in Euphoria 3???
Yes. Bloated syntax implies bad programming skills. Euphoria 3 avoids this trap as well.
16. Pass By Reference vs. Pass By Value?
Euphoria 3 always using the Pass By Value method to pass arguments to subroutines, and it does it faster then other languages that using the terrifying Pass By Reference method. Euphoria 3, again, avoids the Pass By Reference trap. Note also that Euphoria's function can return any complex data type.
17. But Euphoria 3.1.1 is not a 64-bit language!!!
A 64-bit CPU is completely useless for normal programs and for normal people, and should have never find its way into the market - just like the nuclear smartphones, it serves only the big data miners, as well as programs that manipulate data in the size of an average city in China.
18. Can Euphoria 3.1.1 be converted to 64-bit language?
Yes. A professional C/C++ programmer can do it. According to Rob - it is fairly straightforward. But Rob isn't gonna do it, neither do I. See also the cboard conversation.
19. How can I run Euphoria 3.1.1 on a 64-bit operating system?
64-bit Windows has a built in layer for running 32-bit applications. Euphoria for DOS is running in 32-bit protected mode (while DOS runs in 16-bit real mode on a 64-bit CPU). See also How to run Euphoria on 64-bit Linux and How to run Euphoria on 64-bit (& 32-bit) FreeBSD.
20. Will Euphoria 3 run also on a very modern computer?
Modern computers will/are emitting RF radiation in extremely dangerous frequencies and density, through their so-called Wi-Fi and other so-called communication antennas. This makes the question a bit macabre. (I'll let you understand by yourself).
21. But the Euphoria 3 source code is obscure, full of tricky low level hacks, not easy to maintain, requires deep knowledge of the C compiler and libraries!
Any professional C or C++ programmer can, and should, deal with it for further developing the Euphoria language. Euphoria 3 is NOT a toy language, and shouldn't be treated as such by amateurs.
22. What can I do with Euphoria 3?
Your homework at school or university, administration scripts, writing practical programs your own way, or just enjoy programming as a hobby.
23. How can I contribute for developing Euphoria 3?
Use your knowledge and time for creating new Euphoria 3 libraries or C code wrappers. Or, if you are a professional C/C++ programmer, you can tweak the source code to be compiled on modern 64-bit systems (for 32-bit target OS) without the modern compilers errors... this will be a huge step forward. Note that there are few uses of Assembly code which are needing your special attention, according to the readme file... (adding "new features" in most cases is a complete minus).
24. Why did you (Shian) made so many changes in this website???
Whenever I realize that I waste my time - I change things drastically. My patience for mind games with people is almost none. There is also the factor of the "current events" which are abominable, such as the 5G & Corona multinational genocide.
25. How to create a bootable FreeDOS USB stick & Euphoria 3?
I've created a raw image (2GB size) of FreeDOS 1.2.
The image also includes Euphoria 3.1.1, Lib2 1.41, RBIL documentation, helppc, QE 2.3.9 IDE, EDU IDE (as part of Lib2), and basic utilities.

When you start FreeDOS it will run a menu written in Euphoria 3 (you can see the source code in C:\UTIL\MENU.EX).

Just download the compressed image, decompress it using 7-zip, burn it to a USB stick of 4GB or more, and restart your computer from the USB stick. (Legacy BIOS must be enabled in your BIOS, and you should be able to start your computer from USB-HDD).

In Linux you can burn the image using the attached documentation, or another Linux utility. On Windows you can (probably) use Rufus to burn the image to a USB stick.

-----------------------------------------------
How did I make this image on Linux?
-----------------------------------------------

Credit: Joe's Blog, https://joelinoff.com/blog/ (with few adjustments).

2. Create an empty local Disk as file, using 'dd':
` dd if=/dev/zero of=fdos12.img bs=1M count=2047`
3. Install "FD12CD.iso" to Disk, using 'qemu':
`qemu-system-x86_64 -cdrom FD12CD.iso fdos12.img -boot d`

Notes:
1. In FDISK I did NOT enable large drive support on start.
2. I created a single 2GB drive C: (2GB is maximum for standard DOS drive), made it bootable, then restart qemu with ctrl-alt-del... then continue with format and minimal installation.
4. Copy from another FreeDOS USB stick the Euphoria directory & other utilities and documents, using 'qemu' (/dev/sdb1 is my USB device):
`sudo qemu-system-x86_64 -hdb /dev/sdb fdos12.img`
5. Test again if the image is bootable, using 'qemu':
`qemu-system-x86_64 fdos12.img -boot c`
6. Burn the bootable image to a USB stick, using 'dd':
`sudo dd if=fdos12.img of=/dev/sdb bs=1M`
7. Test the new USB stick, using 'qemu':
First find the USB id, using 'lsusb':

`lsusb`

`= ( Bus 002 Device 005: ID 0781:5567 SanDisk Corp. Cruzer Blade )`

Now test it using ID 0781:5567:

`sudo qemu-system-x86_64 -usb -usbdevice host:0781:5567 -m 1024 -vga std`

(Using the above qemu command FreeDOS runs OK from the USB stick!)
8. OK. Ready. Now you can reboot your PC from the USB stick (legacy BIOS must be enabled in the BIOS)... and you can start using FreeDOS and Euphoria!
26. Example batch files for running DOS in Qemu:

I'm using this batch file to run "fdos12.img" on Linux:
```# File name: dos.sh
#
# I'm Using qemu-system-x86_64 --version:
# QEMU emulator version 4.2.0 (On Linux Debian 1:4.2-3ubuntu6.4)
# ==============================================================
#
# When you start qemu:
# --------------------
# Press control-alt-f to toggle full screen mode
# Press control-alt-g to (toggle) grab the keyboard & mouse into DOS
# Press control-alt-0 or control-alt-minus or control-alt-plus to zoom best-fit/out/in
#
# To share files with a FAT-16 or FAT-32 (DOS) formatted USB stick, append
# also the following command (change "/dev/sdb" if needed to your USB stick path):
# --------------------------------------------------------------------------------
#
#    -drive file="/dev/sdb",format=raw,if=ide,media=disk
#
# Note that you should run qemu as root to access the USB drive, i.e.:
# sudo qemu-system-x86_64 ...

qemu-system-x86_64 -drive file="fdos12.img",format=raw,if=ide,media=disk -boot order=c -m 1024 -k en-us -rtc base=localtime -soundhw sb16,adlib,pcspk -vga std -no-quit -name "FreeDOS 1.2"
```
Short description:
`-drive` is a disk to add to DOS.
`-boot` tells qemu which disk to boot from (in order).
`-m` is memory to use (1024 = 1GB since Euphoria 3 is running in protected mode it's useful).
`-k` is keyboard (English-US is the standard keyboard)
`-rtc` is the clock
`-soundhw` is sound hardware to emulate (sb16,adlib,pcspk are common for many DOS programs).
`-vga` is type of screen (standard VGA)
`-no-quit` disable the option to close the qemu window by clicking the [x] on title bar
`-name` will appear at the title bar of qemu

Note: if using USB stick, then make sure that the USB stick is not mounted in Linux, and do NOT remove it until you exit Qemu.

I'm using this batch file to run "fdos12.img" on Windows-10:
```@ECHO OFF
REM .
REM File name: DOS.BAT
REM .
REM I'm Using qemu-system-x86_64 --version
REM QEMU emulator version 5.1.0 (v5.1.0-11824-g8699890d91-dirty)
REM On Windows-10 64-bit
REM ==============================================================
REM .
REM When you start qemu:
REM --------------------
REM Press control-alt-f to toggle full screen mode
REM Press control-alt-g to (toggle) grab the keyboard & mouse into DOS
REM Press control-alt-0 or control-alt-minus or control-alt-plus to zoom best-fit/out/in
REM .
REM To share files with a FAT-16 or FAT-32 (DOS) formatted USB stick, append
REM also the following command (change "/dev/sdb" if needed to your USB stick path):
REM --------------------------------------------------------------------------------
REM .
REM    -drive file="/dev/sdb",format=raw,if=ide,media=disk
REM .
REM You can also specify old PC speaker <name>: -machine pcspk-audiodev=<name>
REM .
REM Remeber to set path for Qemu (Once per session): SET PATH=C:\Program Files\qemu;%PATH%
REM - or just set the path permanently in Windows-10's settings (environment variables).
REM .

qemu-system-x86_64 -drive file="fdos12.img",format=raw,if=ide,media=disk -boot order=c -m 1024 -k en-us -rtc base=localtime -device adlib -device sb16 -vga std -no-quit -name "FreeDOS 1.2"
```
Short description:
`-drive` is a disk to add to DOS.
`-boot` tells qemu which disk to boot from (in order).
`-m` is memory to use (1024 = 1GB since Euphoria 3 is running in protected mode it's useful).
`-k` is keyboard (English-US is the standard keyboard)
`-rtc` is the clock
`-device adlib -device sb16` is sound hardware to emulate (sb16,adlib,pcspk are common for many DOS programs).
`-vga` is type of screen (standard VGA)
`-no-quit` disable the option to close the qemu window by clicking the [x] on title bar
`-name` will appear at the title bar of qemu

Note: if using USB stick, then do NOT remove it until you exit Qemu.

## 7. Beyond Euphoria

For the last few decades we are witnessing the establishing of a Fourth Reich, by the very same monsters which established the Third Reich. (No, they did not die in WWII).

The first goal of the Fourth Reich, as written on the Georgia Guidestones is to "Maintain humanity under 500,000,000 in perpetual balance with nature".

In WWII they used Cyclone B (Hydrogen cyanide, HCN) to murder people, since Hydrogen cyanide is a poisonous gas that interferes with cellular respiration.

Yet Hydrogen cyanide is a "clumsy" way to "Maintain humanity under 500,000,000" therefore a new and promising way was developed and perfected instead of HCN, it is called: 5G.

5G is an electromagnetic radiation that interferes with cellular respiration. Yes. Again. But this time trillion times more efficiently then Cyclone B.

Agenda 21 is the promising name for the new plan, which is carried out by the United Nations (UN), the World Health Organization (WHO), the European Union (EU), the Vatican and the papacy, the Federal Communications Commission (FCC), all intelligence agencies worldwide, all governments worldwide, the Red Cross, all central banks worldwide, and so many other institutes, organizations and armies, which are part of the Fourth Reich.

I guess you've never heard about it. But you will, in the next few years.