INPUT /  OUTPUT /  LANGUAGE






Getting Started

This chapter will get you up to speed with writing your first programs that make use of ioL for very basic input and output.


Producing output

In many programming languages, print (or something similar) is the name of the instruction used to produce output. The term 'print' is an old carry-over from the days when took up whole rooms and computer software was limited to outputting a stream of characters that got printed onto a long continuous length of paper. This essential capability has been baked into operating systems ever since the dawn of computing, and is known as standard output.

ioL feeds off your program's output to render your program's user interface and allow your program to work with data transmitted through the operating system. It uses the same standard output mechanism traditionally used to print text, but instead of being limited to plain text output, it allows you to add formatting instructions to your output by marking up your output with embedded instructions called 'tags', and—later in this book—output more sophisticated content and work with both the user and the OS in more sophisticated ways.

Here's what the typical 'print' command is called in a few different programming languages. These languages include other instructions to produce standard output in more versatile ways, but these will do for now...

C
printf
C++
std::cout
FORTRAN
print
Pascal
writeLn
Python
print

Your Proxima installation may come with interpreters or compilers for one or more of these languages (or other languages entirely; but those have their own equivalents to the 'print' instruction too).

Choose the programming language you feel most comfortable with.

Multi-line output

A typical 'print' instruction is often designed to output a single line of text.

But when producing more elaborate output, your program's output instructions will often span multiple lines. You can split your output up into multiple 'print' statements, but it's often useful (or more readable) to make one quoted string span multiple lines in your program code.

For example, in Python, you can use three quotation marks:

print('''
This output is spread
over multiple lines 
of Python code.
''')

...while in languages like C and C++, you can close the quotation marks at the end of each line and re-open them again on the next line:

printf(
    "This output is spread over\n"
    "multiple lines of C code.\n"
    "The C compiler will treat"
    " this entire thing as one"
    " long string.\n"
);

Dealing with input

Most programming languages provide an 'input' instruction to compliment the 'print' instruction. This capability allows a string of chracters to be received by the program, and is referred to by the OS as standard input.

In traditional computing environments, 'input' usually meant the user would type a string of characters into a terminal and press the Enter key. When a program required input from the user, that program would use an appropriate 'input' instruction which would do two things: (1) it would instruct the OS to block further execution of the program until the user finished typing a response into the terminal, and (2) it would return whatever the user typed as a value that could be used inside the program.

With ioL, programs receive input through the same mechanism except it's up to the program to define what input is required and how it should be sent back to the program. More on this later.

I won't explain how to use your programming language's particular input instruction(s) in this guide, except to mention that the names and usages of the standard input instructions available vary a lot depending on the programming languages. Here are some of the most typically used standard input instructions in a few different languages.

C
scanf
C++
std::cin
FORTRAN
read
Pascal
readLn
Python
input

Throughout this guide, I'll provide certain examples using Python code. Even if you aren't coding in Python yourself, you'll find the syntax easy enough to understand.

If you aren't using Python, just adapt the examples to suit your chosen programming language.

Also be mindful of quirks in how various programming languages require program output to be written.

e.g. In C, the printf function attaches special meaning to the % character so the percentage sign has to be output as %%.

Creating and running a program

In Proxima, each app is contained inside a software package, and you should create a new software package before you start writing code. Create a new blank software package from the system-request (SysRq) menu, select a language interpreter available on the system, choose a name the main program file in your software package (if applicable), then follow the instructions to place it on your chosen file storage device.

To write your program, open a listing of the contents of the software package on your storage media, then open the main program file in the software package through a text editor and write your code.

Once you've written some working code, you can then run your software package directly from the storage media.