Lolcode - Input/Output


Advertisements

This chapter will explain you how to input a value through LOLCODE terminal and how to output it onto the terminal.

I/O from Terminal

You can use the keyword VISIBLE to print something in LOLCODE. VISIBLE is a function which can take an infinite number of characters as input, and prints them all at once by internally concatenating them, and converting them to strings or YARN.

The VISIBLE function ends or terminates by a delimiter, which is either a line end or a comma.

The output is automatically terminated by the compiler with a carriage return. If the final token is terminated with an exclamation symbol (!), then the carriage returned is over-ridden by this symbol.

VISIBLE <any_expression> [<any_expression> ...][!]

Please note that in LOLCODE, currently there is no defined standard for printing some data to a file.

To take some input from the user, the keyword used is GIMMEH. It is a function which can take any number of variables as input. It takes YARN as the input and stores the value in any given variable.

GIMMEH <any_variable>

Example

HAI 1.2
   I HAS A VAR ITZ A YARN BTW DECLARE A VARIABLE FOR LATER USE
   VISIBLE "TYPE SOMETHING AND ENTER"
   GIMMEH VAR BTW GET INPUT (STRING) INTO VARIABLE
   VISIBLE VAR
KTHXBYE

When this code is run, it will ask you to enter a number and then prints the number back in the next line automatically. When you run this code, it will print the following output −

sh-
4.3$ lci main.lo

TYPE SOMETHING AND ENTER
67

67
Advertisements