Chaga Programming Language: Chapter 7: Input and Output

READLINE function

  • The READLINE function is built-in to the Chaga programming language.
  • The READLINE function reads zero or more bytes from the keyboard.
  • Input will be read from the keyboard until the user presses the <return> key.
  • The <return> character is not counted and not included in the keyboard input.
  • If the only character entered is a <return>, the READLINE function will return an empty string and indicate zero bytes read.
  • The READLINE function returns a string datatype.
  • The length attribute of the string datatype indicates the number of bytes the READLINE function read.

Usage:

  • set string_identifier = call readline ();

Example: readline

declare string buffer;

set buffer = call readline ();
if (buffer.length > 0)
{
  call print ("Number of characters received is: ", buffer.length, "\n");
}

  • The PRINT procedure is built-in to the Chaga programming language.
  • The PRINT procedure displays the contents of variables and/or constant string quotes.
  • The PRINT procedure accepts one or more input parameters.

Usage:

  • call print ( ... );

Example: print

declare real temperature_in_fahrenheit, temperature_in_celcius;

set temperature_in_fahrenheit = 68;
set temperature_in_celcius = (temperature_in_fahrenheit - 32) * 5 / 9;
call print (temperature_in_fahrenheit, " degrees F = ", temperature_in_celcius, " degrees C\n");

Output from print example:

68 degrees F = 20 degrees C


Copyright © 2025, 2026 Robert James Bruce.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at https://www.gnu.org/licenses/fdl-1.3.html