From ea876fb78948b9b5e3cb90bdae2e6a727c608f68 Mon Sep 17 00:00:00 2001 From: DiamondNether90 Date: Sun, 21 Sep 2025 15:19:30 +1000 Subject: [PATCH] Add User Input and Output --- User-Input-and-Output.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 User-Input-and-Output.md diff --git a/User-Input-and-Output.md b/User-Input-and-Output.md new file mode 100644 index 0000000..204a48d --- /dev/null +++ b/User-Input-and-Output.md @@ -0,0 +1,32 @@ +In Ground, there are 3 commands that are used for I/O. These are `stdin`, `stdout`, and `stdlnout`. + +## **Stdin** +The `stdin` command allows user input within the terminal. It allows the user to input a value, and it will store the input in a variable. + +The syntax is: `stdin &variable`. + +## **Stdout** +The `stdout` command allows the program to output text to the terminal. + +The syntax is: `stdout $string` + +## **Stdlnout** +The `stdlnout` command allows the program to output text to the terminal. Unlike `stdout`, `stdlnout` will automatically append a newline character to the end of any string. +Please note that this command is not yet functional in [GroundPY](url=https://git.maxwellj.xyz/ground/GroundPY) - a workaround is to simply append a newline character to the end of the string. + +The syntax is: `stdout &variable` + +## **Example Program** +This program asks the user "Do you like cheese?" until the user inputs "yes" (must be lowercase). +``` +@begin +stdout "Do you like cheese? " +stdin &userin +equal $userin "yes" &condition +if $condition %end +stdlnout "That is sad" +jump %begin +@end +stdlnout "Awesome! I do too!" +``` +The program outputs `"Do you like cheese? "`, and waits for a reply. If the reply is `"yes"`, it will jump to the end, outputting `"Awesome! I do too!"`. Otherwise, it outputs `"That is sad"`, and returns to the beginning. \ No newline at end of file