| INTERCALC(1p) | User Contributed Perl Documentation | INTERCALC(1p) |
intercalc - CLC-INTERCAL desk calculator
intercalc [options]
intercalc is a simple desk calculator, allowing the user to enter INTERCAL statements (to see what they do) and expressions (to see what value they produce); it uses an interpreter object from CLC-INTERCAL to provide immediate feedback.
The desk calculator accepts several options, some of which are documented here.
In this mode, the program executes each line from standard input according to the current mode and language, and prints results to standard output. A line starting with a backspark is interpreted as a command to the calculator. Use backspark-g to GIVE UP (you'll need to do it twice), or backspark-h to display the ehm, help page. Things which are available via menu entries on the Curses and X interfaces are also available via the backspark. For now, you can refer to the source code for a list.
Command-line editing and command history is provided by the readline library. Command completion works if the underlying compiler supports it (the compilers provided with the distributions do).
If this option is repeated, the given paths will be searched in the order given, followed by the standard paths.
Unlike previous versions of intercalc, this version checks that the options make sense in the context of the calculator; for example trying to load a compiler as an option will cause an error, but a compiler extension will be OK.
If filenames are explicitely specified, they must be fully qualified: the search path is not used to find them.
The calculator can operate in the following modes:
Statements are compiled as a one-statement program, and executed; any register value etc. will be preserved between statements, so entering a list of statements is equivalent to running a program in which all these statements are executed in sequence.
It is important to note that some statements will not execute in the normal manner. For example, a COME FROM will be parsed but have no effect, unless it is something like:
(1) PLEASE COME FROM (1)
which causes the calculator to hang. On the other hand, an ABSTAIN FROM or a REINSTATE will work as expected, as will CREATE and DESTROY. A GIVE UP does not cause the calculator to terminate. One final difference is that comments are not parsed, and therefore you get a "Syntax Error" from the calculator rather than a splat *000 from the INTERCAL interpreter.
For expressions, the calculator READs OUT the expression's result. Any side effects will be remembered, so if the expression contains overloads they will remain to haunt the calculator.
The calculator has a number of memories (default 100 - these can be changed by appending a number to the operating mode, for example oic10 will use a 10-memory calculator). These memories are identified by the letter m followed by a number; in the default 100-memory version, the first two digits after m are the memory, and any subsequent digit forms part of the next operand. At the start, all memories are initialised to 0.
Since there is only one operation, there is no need to specify it, so an "operation" is a sequence of three operands and a result. The result must be a memory, while each operand can be a number or a memory, with the limitation that consecutive numbers are acceptable only if the parser can determine where one ends and the next one starts. So for example "1-0" is two numeric operands, 1 and -0 (aka 0); "1.2.3" is also two operands, 1.2 and 3; "12" is a single operand, even if you intended it to be two operands, 1 and 2, and even if you put spaces: "1 2" is still interpreted as the single operand 12.
The operation performed is the difference between the first two operands, divided by the third. For example, the three operations:
7 m01 2 M01
1 m02 1 m02
m1 .5 m2 m03
will produce results m01=3.5 ((7-0)/2); m02=1 ((1-0)/1); m03=3 ((3.5-.5)/1). and will produce the following output if the calculator is running in batch mode:
m01 3.5 (7 - m01) / 2
m02 1 (1 - m02) / 1
m03 3 (m01 - .5) / m02
The INTERCAL on-line documentation, by running intercalc and finding the "help" menu or key (X and Curses) or backspark escape (Line and None).
| 2023-05-18 | perl v5.36.0 |