# Programming in LOLGraphics 3.4/Interface, hello world program, subprograms, & labels
## Editor Interface

When opening LOLGraphics, you will be greeted to the LOLGraphics Editor. Let’s go over what each button does:
The save button saves the current code to example.lulz in the same folder that the jar file of LOLGraphics is located in. The load button reads example.lulz and displays its contents on the editor. This is assuming you wrote in the file field the word “example”. Otherwise, it will read and write to whatever file name you wrote there with a .lulz extension.
The run button takes what is written in the editor, removes all blank lines and comments (a line that begins with BTW, or a line that begins with OBTW all the way till the line TLDR) and trims all the lines (removes whitespace characters from the start and end of it). Then it will send what’s left to the interpreter to run it line by line.

## Interpreter interface

Here’s how the interface of the interpreter works:
The screen of the interpreter consists of 3 main parts: a console for text output, a field for input, and a graphics area. Don’t worry if you don’t understand how to use them just yet as all of it will covered later on in the book.
You can check out the example codes available in the editor. Just take into account that not all of them use the latest version of LOLGraphics. This book will only cover version 3.4 which is the latest.

## Code Structure

When you open the editor, you will see the default code which looks like this:
Let’s go over what each line does. The first line might seem useless for the untrained eye but it actually has multiple purposes. The first is to specify the version of LOLGraphics you are using. Believe it or not but if you download LOLGraphics Editor x.y, you are actually downloading all the versions up to this version. That means that a code written for LOLGraphics 0.1 will work fine on all versions of the editor, and will load using LOLGraphics Interpreter 0.1. The two numbers represent the delays between two commands. In this example 0 milliseconds since the interpreter I launched till the first command starts, and 100 milliseconds (0.1 second) in between every 2 commands. If you write just one number it will be the delay between every 2 commands and the initial delay will be 0. If you don’t write any numbers it will run as if you wrote 0 and 100.
This is also why throughout this book, the efficiency of the code will be measured purely by the number of lines executed by the interpreter.
Also it’s possible to change the delay in the middle of the code using the command PLZ SET DELAY <number>.
The line IM IN UR CODE EXECUTIN UR KOMANDZ does NOTHING🎉🎉🎉 but is necessary for the code to run. Otherwise you will get a message saying that you forgot to specify where the code starts. Remember, this is a meme programming language.
Finally the line IM OUTTA UR CODE ends the code. There’s no limitation on where you can put, or how many times you can put it. It’s just a command that ends the code and can be placed anywhere. You can theoretically omit the line and it will run until it has executed the last line. However, if you want to have subprograms it’s a must to have this line otherwise the interpreter will run on all the subprograms.

## Error handling

LOLGraphics forces you to be polite and most (not all) commands begin with PLZ. If you type a command that doesn’t exist it will check if it begins with PLZ. If yes it will tell that it doesn’t know what to do and ask to give a command that actually exists. Otherwise it will yell at you that you forgot the magic word. Don’t worry about the wording to much and definitely don’t add PLZ to commands that don’t have it otherwise it won’t work.
When you get yelled at, the interpreter will not tell you what line to fix so it’s recommended that when writing your code, you write it in small parts and test each one before you continue to the next.

## Printing strings

There are two ways to print strings in LOLGraphics:
The first one prints Hello World to the console, and the second one prints hello world and then goes to the next line. If you want to print variable x (variables will be taught in a later chapter), as x: 5, adding a space at the end of the type command won’t help since the LOLGraphics Editor deleted spaces at the beginning and end of the line. To compensate there is a command PLZ ADD A SPACE that types that character to the screen.

## Hello World

This is how a hello world program in LOLGraphics looks like:

## Clearing the console & changing text color

You can clear the console using PLZ CLEAR TEH CONSOLE.
You can also change the text color using the command PLZ CHANGE TEXT COLOR <color>. There are 3 ways to specify the color:
* Type its name for the following colors: black, blue, cyan, dark gray, gray, green, light gray, magenta, orange, pink, red, white, and yellow.
* Type its RGB values.
* Type the word random for a random color.

## Subprograms

A subprogram begins with IM IN UR SUBPROGRAM DAT IZ KALLED <name>. In order to end the subprogram, you type IM OUTTA UR SUBPROGRAM which like the command to end the code, can be placed anywhere in the subprogram. After the subprogram ends it will continue running starting from the line after where the subprogram was called. In later chapters, you will learn how to use subprograms in loops and conditions. You can also call a subprogram inside a subprogram and create recursion!🎊 Heres a code that prints I can has a ceezburger? indefinitely using recursion.
In this code there’s no point writing IM OUTTA UR SUBPROGRAM since it will never get there anyways. That’s another thing about LOLGraphics, you can add commands between the “main area” and the first subprogram or in between 2 subprograms but that probably isn’t very smart since the interpreter will never run them. Also they can be used as comments since they won’t be run anyways but it’s probably smarter to write regular comments with BTW or OBTW/TLDR since they will be wasted before the code is sent to the interpreter.

## Labels

When you start a subprogram, the program remembers which line it was that called the subprogram so that it can go back and continue running from that line. Usually that’s useful, but you might not always want that. Take for example the recursive code above. There’s not any reason for the code to remember where this subprogram was called. That’s why labels exist. To define a label, you write DIS IZ MY LABEL! IT IZ KALLED <name> (and yes, the exclamation mark is mandatory) and to jump to a label, write PLZ GOTO LABEL label. Now let’s rewrite the infinite recursion above only with labels.
This code does exactly the same. The only differences are that it’s shorter and more efficient.