YOU ARE VIEWING ARCHIVAL DOCUMENTATION FOR ioL VERSIONS 0.9x. Go to doc.iol.science for the latest version.
ioL

Programming manual (doc0.iol.science)



Printing plain text in ioL

ioL is more than a way to display fancy text on the screen. It's a powerful computer language in its own right.

But before we teach you how to fly, we need to teach you how to walk. Because ioL interprets your program's output in a specific way (rather than just taking taking what it's given like a TTY terminal does), you'll need to understand a few of ioL's syntax rules so your output is interpreted in the way you expect.

In this section, we'll tell you how to print boring old plain text, except we'll be printing it into an ioL console.

Practicing with standard input/ouput mode

You know by now that you can send output to ioL by printing it from a program.

Sometimes, you just want to play around with ioL by typing your content directly, and seeing the results in the ioL console immediately as you type them.

If you type iol - (single dash) into your terminal prompt, ioL will create an interactive environment where your TTY terminal will be linked up with the ioL console window directly. Anything you type into your TTY terminal will be processed by ioL (as if it were printed from a running program), and if you request input back from the user, the input that would go back to a running program will instead appear in your TTY terminal.

When you run iol in a terminal with the - option, you are the running program.

This is a fantastic way to practise!

Let's get started.

$ iol -
ioL: input/output Layer
Copyright © General Development Systems
_______________________________________________

A blank ioL console window appears on the screen.


Let's type something into our TTY...

Hello world!

When you hit the Enter key on your keyboard, the ioL console window will change, as though a program had printed what we just typed:

Hello world!

You're probably getting really bored of seeing "Hello world!" all the time. Let's try a different example below what we just typed...

'I am still learning'
     -- Michelangelo

How does our ioL console look now?

Hello world! 'I am still learning' -- Michelangelo

Not quite what we wanted. We wanted our output on more than one line, with a bit of spacing as well. Why doesn't ioL respect our spacing?

Quitting your console session

Before we get to that, let's end our input for now. Press Ctrl+d on a blank line to disconnect from our ioL console. Typing Ctrl+d into a TTY terminal usually signals 'end of file' (in this case it really means 'end of output').

ioL thinks that the program has ended, so the ioL console window closes automatically. If you remember back to our earlier example, this was the reason why we had to put that sleep(5); statement into our program earlier — otherwise the program would finish too quickly and the ioL console window would close too quickly for you to see anything at all.


Back to our question. Why didn't ioL display the multiple spaces and newlines in our output?

Well, ioL is first and foremost a computer language. Like all computer languages (including HTML), there are times when you need to space things out neatly in order to make the code easier to follow. ioL does not force you to be neat, but it does you the courtesy of letting you space out your output using spaces, tabs, and newlines, without affecting the meaning of the code.

Except in certain circumstances, ioL will collapse any sequence of whitespace characters, such as multiple spaces in a row, newlines, etc., into a single space .

We certainly don't want all of our programs to display all their output on a single line. So how do we enter new line characters and control white-space in ioL? As soon as you're ready, let's continue to the next section.

We need to talk about escape sequences.