CLC-INTERCAL Reference

... The INTERCAL calculator

Table of contents:

The INTERCAL calculator

Starting from CLC-INTERCAL 1.-94.-4, a new INTERCAL calculator is included with the distribution. Apart from the obvious use as a luxury desk calculator, the calculator allows to quickly test fragments of INTERCAL programs by just typing them in the calculator and seeing what happens. Note that some statements are by necessity not supported, for example COME FROMs have no real meaning as each statement is executed as a separate program. ABSTAIN FROM and friends, however, are supported: you can even say things line "DO ABSTAIN FROM (1)", them write out the state to a file, exit the calculator, start it up again, read the state back in, type "(1) DO .1 <- #2" and the statement will not be executed: the calculator remembers it's supposed to be ABSTAINed FROM.

intercalc requires CLC-INTERCAL 1.-94.-4 and newer. It won't work with older versions.

Starting with CLC-INTERCAL 1.-94.-2, intercalc is provided as a separate package, CLC-INTERCAL-ICALC. The various User Interfaces are also probided as separate packages, so you can install just the ones you use.

By default, if started without instructions to the contrary, intercalc attempts to use the "best" user interface which happens to work in the current environment; here "best" means that the list of interfaces is obtained from file .sickrc or system.sickrc and the first one which works is used. The default is X, Curses, Line, None meaning that a GTK2-based graphical interface is preferred if X is running and GTK2 is installed; otherwise, a curses-based text interface or a ReadLine-based interface if the calculator is running on a terminal and the necessary libraries are installed. If none of them work, a batch mode interface which writes commands in from standard input and produces results on standard output always works. In the remainder of this chapter, we speak of "interactive" interface to mean "anything except batch mode" and of "windowed" interface to mean X or Curses, as opposed to Line or None.

The arguments on the command line are either options (in the form --name=value or -xvalue), or filenames. If a filename is encountered, it must be a file previously created by intercalc using the Write Out option. Specifiying a file is equivalent to selecting Read In first thing after the calculator starts up.

Command-line options

There is a number of command-line options, which are grouped by type for easy reference.

User interface options

If the automatic user interface selection does not give the required result, the following options can be used to control what happens:

Long optionShortMeaning
--graphic-XGTK2-based graphical interface
--curses-cCurses-based text interface
--lineReadLine-based text interface
--batchBatch mode, no user interface
--interface=NAME-iNAMELoad the specified interface

Compiler options and operating mode

These are either the name of the compiler to use, and any extensions which you wish to load initially, or other options which control how the compiler behaves.

Long optionShortMeaning
--include=DIR-IDIRAdd directory to search path for compiler objects
--language=NAME-lNAMESelects the compiler (default: sick)
--option=NAME-oNAMESelects a compiler option, may be repeated (default: none)
--mode=NAME-mNAMESelects operating mode (default: full)
--bug=NUMBERChange the probability of the compiler bug
--ubug=NUMBERChange the probability of the unexplainable compiler bug

The calculator currently defines three operating modes: full (the default), expr and oic.

In full mode, the full power of the selected compiler and extensions is available. One types INTERCAL statements and watches them execute. Additionally, for convenience, one can type an expression and this will be evaluated and its result displayed. It is internally implemented by pretending you typed "DO READ OUT expression".

expr mode is a restricted form of full mode, where you can only execute assignments and evaluate expressions; other statements are disallowed. Assignments are specified without the initial DO and/or PLEASE. Expressions can of course contain overloading and other side-effects, which will be remembered and will come back to cause unexpected results later. This mode is suitable for a desk calculator.

oic mode is a silly "One Instruction" desk calculator which is there because we can. This mode is currently undocumented.

Misc options

The following options control the way intercalc operates:

Long optionShortMeaning
--nouserrcIgnore .sickrc files, use only first system.sickrc found
--rcfile=NAME-rNAMEUses specified file instead of searching for .sickrc and system.sickrc

Using the calculator

Once the calculator has started, it will display its window (in windowed mode), print its prompt (in Line mode), or simply wait for input (in batch mode). In any case, you enter statements or expressions and watch them execute.

Some menus are available in windowed mode to change the current compiler, base and operating mode. These should be self-explanatory in the X interface. In the Curses interface, press Alt-F to access the File menu, Alt-E to access the Edit menu, and so on with the other menus. Just use Alt and the initial letter of the menu name. Once a menu is open, the up and down arrow keys navigate the menu, while the left and right keys move to the next menu in the corresponding direction. To select a menu entry, press Enter; to close the menu without making a selection, press Esc.

In X mode you can provide input by clicking on a key or by pressing the corresponding key on the keyboard if there is one (some symbols may not be available on all keyboards); in Curses mode you can press the key or, if necesssary, use the cursor keys (up, down, left, right) to highlight one of the buttons on the screen, then press Enter to activate it.

In line and batch mode, access to menu functions can be achieved by starting a line with a backspark (`) and a letter. In Line mode you can see what letters make sense by pressing Tab after the backspark, which will give you a list. In any case, the following backsparks are available:

BacksparkMeaning
`aShow the "About intercalc" text
`bBASEChange base
`cSave settings to .sickrc (not yet implemented)
`gGive up (exit calculator) - you'll need to do it twice to confirm
`hShow command history
`hNUMShow command history, limiting to last NUM commands
`lLANGUAGELoad a different compiler (1972, ick or sick)
`mMODEChange operating mode (full, expr or oic)
`oOPTIONToggle compiler option
`rFILERead Out: saves calculator state to file
`rLike `rFILE but uses last filename given to `r or `w
`tShow program trace, if enabled with `otrace
`tNUMSame as `t, limiting to trace produced by last NUM commands
`wFILEWrite In: loads calculator state from file
`?Help: displays the help text

If you do not provide an argument to `b, `l, `m or `o, they will show a list. Currently selected base, language, mode or options (respectively) will be marked with a splat.