150 lines
2.6 KiB
Markdown
150 lines
2.6 KiB
Markdown
# OpenEuphoria Cheat Sheet v0.0.1
|
|
|
|
## Data Types
|
|
|
|
*atom* : Holds any number.
|
|
*sequence* : Holds a dynamically resizeable list of objects
|
|
*integer* : Holds 30-bit signed integers; faster than atom
|
|
*object* : Holds any of the above.
|
|
|
|
## Standard Library
|
|
**Directory**: */usr/local/euphoria-x.x.x-Linux-<arch>/include/std*
|
|
|
|
net (*directory*)
|
|
|--common.e
|
|
|--dns.e
|
|
|--http.e
|
|
|--url.e
|
|
|
|
**base64.e**
|
|
filesys.e
|
|
locale.e
|
|
**os.e** - *system calls related to the Operating System*
|
|
sequence.e
|
|
unittest.e
|
|
cmdline.e
|
|
flags.e
|
|
localeconv.e
|
|
pipeio.e
|
|
serialize.e
|
|
utils.e
|
|
console.e
|
|
get.e
|
|
machine.e
|
|
pretty.e
|
|
socket.e
|
|
wildcard.e
|
|
convert.e
|
|
graphcst.e
|
|
map.e
|
|
primes.e
|
|
sort.e
|
|
datetime.e
|
|
graphics.e
|
|
math.e
|
|
rand.e
|
|
stack.e
|
|
dll.e
|
|
hash.e
|
|
mathcons.e
|
|
regex.e
|
|
stats.e
|
|
eds.e
|
|
image.e
|
|
memconst.e
|
|
safe.e
|
|
task.e
|
|
error.e
|
|
io.e
|
|
memory.e
|
|
scinot.e
|
|
text.e
|
|
eumem.e
|
|
lcid.e
|
|
search.e
|
|
types.e
|
|
|
|
## User input:
|
|
|
|
Getting user input is easy, just make sure to include ```get.e``` and create a prompt like so:
|
|
|
|
|
|
```
|
|
myprompt = prompt_string("Type a message here: )
|
|
```
|
|
|
|
The user's input is stored in ```mystring``` with which you can use in various situations.
|
|
|
|
Below is an example of taking input from the user and comparing it against various strings using -
|
|
the ```equal()``` function
|
|
|
|
|
|
```
|
|
|
|
include std/io.e
|
|
include get.e
|
|
sequence input
|
|
input = prompt_string("Type here: ")
|
|
|
|
if equal(input, "test") then
|
|
printf(STDOUT, "Test Successful\n")
|
|
elsif equal(input, "test1") then
|
|
printf(STDOUT, "Test1 Successful\n")
|
|
else
|
|
printf(STDOUT,"Unrecognized input\n")
|
|
end if
|
|
```
|
|
|
|
## Compare Sequences
|
|
|
|
You can use a couple of built-in functions to test strings or other sequences.
|
|
They are:
|
|
|
|
```
|
|
compare("string1", "string2")
|
|
equal("string1, "string2")
|
|
```
|
|
|
|
Below is an example of using the compare function.
|
|
Notice with this function you need to check it against a number.
|
|
|
|
0 - true
|
|
|
|
--------------
|
|
|
|
### compare(a_string, another_string) = status
|
|
|
|
```
|
|
include std/io.e
|
|
|
|
sequence mystring
|
|
|
|
mystring = "hello"
|
|
|
|
if compare(mystring, "hello") = 0 then
|
|
puts(1,"The condition is true!")
|
|
else
|
|
puts(1,"The condition is false!")
|
|
end if
|
|
```
|
|
---------------
|
|
|
|
On the other hand, the equal() function does not need a 0 or 1 to work:
|
|
|
|
### equal(a_string, another_string)
|
|
|
|
```
|
|
include std/io.e
|
|
|
|
|
|
sequence mystring
|
|
mystring = "hello"
|
|
|
|
if equal(mystring, "hello") then
|
|
puts(1,"The condition is true!\n")
|
|
else
|
|
puts(1,"The condition is false!\n")
|
|
end if
|
|
```
|
|
----------------
|
|
### TODO |