Added README
This commit is contained in:
commit
ee79885d76
85
README.md
Normal file
85
README.md
Normal file
@ -0,0 +1,85 @@
|
||||
# OpenEuphoria Cheat Sheet
|
||||
|
||||
|
||||
### 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
|
||||
1 - false
|
||||
|
||||
--------------
|
||||
|
||||
|
||||
```
|
||||
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:
|
||||
|
||||
```
|
||||
include std/io.e
|
||||
|
||||
|
||||
sequence mystring
|
||||
mystring == "hello"
|
||||
|
||||
if equal(mystring, "hello") then
|
||||
puts(1,"The condition is true!")
|
||||
else
|
||||
puts(1,"The condition is false!")
|
||||
end if
|
||||
```
|
||||
----------------
|
||||
### TODO
|
Loading…
x
Reference in New Issue
Block a user