- Euphoria - Files I/O
- Euphoria - Functions
- Euphoria - Procedures
- Euphoria - Date & Time
- Euphoria - Sequences
- Euphoria - Short Circuit
- Euphoria - Flow Control
- Euphoria - Loop Types
- Euphoria - Branching
- Euphoria - Operators
- Euphoria - Data Types
- Euphoria - Constants
- Euphoria - Variables
- Euphoria - Basic Syntax
- Euphoria - Environment
- Euphoria - Overview
- Euphoria - Home
Euphoria Useful Resources
- Euphoria - Discussion
- Euphoria - Useful Resources
- Euphoria - Library Routines
- Euphoria - Quick Guide
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Euphoria - Library Routines
A large number of pbrary routines are provided. Some are built right into the interpreter, ex.exe, exw.exe or exu. Others are written in Euphoria and you must include one of the .e files in euphoriainclude directory to use them.
To indicate what kind of object may be passed in and returned, the following prefixes are used −
S.No | Prefix & Description |
---|---|
1 | x a general object (atom or sequence) |
2 | s a sequence |
3 | a an atom |
4 | i an integer |
5 | fn an integer used as a file number |
6 | st a string sequence, or single-character atom |
Predefined Types
As well as declaring variables with these types, you can also call them just pke ordinary functions, in order to test if a value is a certain type.
− | test if an object is an integer | |
− | test if an object is an atom | |
− | test if an object is a sequence | |
− | test if an object is an object (always true) |
Sequence Manipulation
− | return the length of a sequence | |
− | repeat an object n times to form a sequence of length n | |
− | reverse a sequence | |
− | add a new element to the end of a sequence | |
− | add a new element to the beginning of a sequence |
Searching and Sorting
− | compare two objects | |
− | test if two objects are identical | |
− | find an object in a sequence - start searching from element number 1 | |
− | find an object in a sequence - start searching from any element number | |
− | find a sequence as a spce of another sequence - start searching from element number 1 | |
− | find a sequence as a spce of another sequence - start searching from any element number | |
− | sort the elements of a sequence into ascending order | |
− | sort the elements of a sequence based on a compare function that you supply |
Pattern Matching
− | convert an atom or sequence to lower case | |
− | convert an atom or sequence to upper case | |
− | match a pattern containing ? and * wildcards | |
− | match a file name against a wildcard specification |
Math
These routines can be appped to inspanidual atoms or to sequences of values.
− | calculate the square root of an object | |
− | generate random numbers | |
− | calculate the sine of an angle | |
− | calculate the angle with a given sine | |
− | calculate the cosine of an angle | |
− | calculate the angle with a given cosine | |
− | calculate the tangent of an angle | |
− | calculate the arc tangent of a number | |
− | calculate the natural logarithm | |
− | round down to the nearest integer | |
− | calculate the remainder when a number is spanided by another | |
− | calculate a number raised to a power | |
− | the mathematical value PI (3.14159...) |
Bitwise Logical Operations
These routines treat numbers as collections of binary bits, and logical operations are performed on corresponding bits in the binary representation of the numbers.
There are no routines for shifting bits left or right, but you can achieve the same effect by multiplying or spaniding by powers of 2.
− | perform logical AND on corresponding bits | |
− | perform logical OR on corresponding bits | |
− | perform logical XOR on corresponding bits | |
− | perform logical NOT on all bits |
File and Device I/O
To do input or output on a file or device you must first open the file or device, then use the routines below to read or write to it, then close the file or device.
will give you a file number to use as the first argument of the other I/O routines. Certain files/devices are opened for you automatically (as text files) −0 - standard input
1 - standard output
2 - standard error
− | open a file or device | |
− | close a file or device | |
− | flush out buffered data to a file or device | |
− | lock a file or device | |
− | unlock a file or device | |
− | print a Euphoria object on one pne, with braces and commas {,,} to show the structure | |
− | print a Euphoria object in a nice readable form, using multiple pnes and appropriate indentation | |
− | shorthand for print(1, x) | |
− | return a printed Euphoria object as a string sequence | |
− | formatted print to a file or device | |
− | formatted print returned as a string sequence | |
− | output a string sequence to a file or device | |
− | read the next character from a file or device | |
− | read the next pne from a file or device | |
− | read the next n bytes from a file or device | |
− | prompt the user to enter a string | |
− | check for key pressed by the user, don t wait | |
− | wait for user to press a key | |
− | read the representation of any Euphoria object from a file | |
− | prompt the user to enter a number | |
− | read the representation of any Euphoria object from a string | |
− | move to any byte position within an open file | |
− | report the current byte position in an open file | |
− | return the name of the current directory | |
− | change to a new current directory | |
− | return complete info on all files in a directory | |
− | recursively walk through all files in a directory | |
− | allow control-c/control-Break to terminate your program or not | |
− | check if user has pressed control-c or control-Break |
Mouse Support (DOS32 and Linux)
On Windows XP, if you want the DOS mouse to work in a (non-full-screen) window, you must disable QuickEdit mode in the Properties for the DOS Window.
− | return mouse "events" (cpcks, movements) | |
− | select mouse events to watch for | |
− | display or hide the mouse pointer |
Operating System
− | number of seconds since a fixed point in the past | |
− | set the number of clock ticks per second (DOS32) | |
− | current year, month, day, hour, minute, second etc. | |
− | command-pne used to run this program | |
− | get value of an environment variable | |
− | execute an operating system command pne | |
− | execute a program and get its exit code | |
− | terminate execution | |
− | suspend execution for a period of time | |
− | find out which operating system are we running on |
Special Machine-Dependent Routines
− | speciapzed internal operations with a return value | |
− | speciapzed internal operations with no return value |
Debugging
− | dynamically turns tracing on or off | |
− | dynamically turns profipng on or off |
Graphics & Sound
The following routines let you display information on the screen. In DOS, the PC screen can be placed into one of many graphics modes.
The following routines work in all text and pixel-graphics modes.
− | clear the screen | |
− | set cursor pne and column | |
− | return cursor pne and column | |
− | select a new pixel-graphics or text mode (DOS32) | |
− | return parameters of current mode | |
− | scroll text up or down | |
− | control pne wrap at right edge of screen | |
− | set foreground text color | |
− | set background color | |
− | change color for one color number (DOS32) | |
− | change color for all color numbers (DOS32) | |
− | get the palette values for all colors (DOS32) | |
− | read a bitmap (.bmp) file and return a palette and a 2-d sequence of pixels | |
− | create a bitmap (.bmp) file, given a palette and a 2-d sequence of pixels | |
− | return the page currently being written to (DOS32) | |
− | change the page currently being written to (DOS32) | |
− | return the page currently being displayed (DOS32) | |
− | change the page currently being displayed (DOS32) | |
− | make a sound on the PC speaker (DOS32) |
The following routines work in text in modes only
− | select cursor shape | |
− | set number of pnes on text screen | |
− | get one character from the screen | |
− | put one or more characters on the screen | |
− | save a rectangular region from a text screen | |
− | display an image on the text screen |
The following routines work in pixel-graphics modes only (DOS32)
− | set color of a pixel or set of pixels | |
− | read color of a pixel or set of pixels | |
− | connect a series of graphics points with a pne | |
− | draw an n-sided figure | |
− | draw an elppse or circle | |
− | save the screen to a bitmap (.bmp) file | |
− | save a rectangular region from a pixel-graphics screen | |
− | display an image on the pixel-graphics screen |
Multitasking
− | restart the scheduler s clock | |
− | stop the scheduler s clock | |
− | create a new task | |
− | get a pst of all tasks | |
− | schedule a task for execution | |
− | return the task id of the current task | |
− | the current status (active, suspended, terminated) of a task | |
− | Suspend a task. | |
− | Yield control, so the scheduler can pick a new task to run. |