commit ee79885d761b2fb0a80db29bcb3ca95b17ee0ab7 Author: mollusk Date: Tue Jul 19 18:54:19 2016 -0700 Added README diff --git a/README.md b/README.md new file mode 100644 index 0000000..42b1fde --- /dev/null +++ b/README.md @@ -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 \ No newline at end of file