87 lines
1.7 KiB
Markdown
87 lines
1.7 KiB
Markdown
# OpenEuphoria Cheat Sheet v0.0.1
|
|
|
|
|
|
## 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 |