mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.10.2t30
This commit is contained in:
99
help/command
Normal file
99
help/command
Normal file
@@ -0,0 +1,99 @@
|
||||
Command sequence
|
||||
|
||||
This is a sequence of any the following command formats, where
|
||||
each command is terminated by a semicolon or newline. Long command
|
||||
lines can be extended by using a back-slash followed by a newline
|
||||
character. When this is done, the prompt shows a double angle
|
||||
bracket to indicate that the line is still in progress. Certain
|
||||
cases will automatically prompt for more input in a similar manner,
|
||||
even without the back-slash. The most common case for this is when
|
||||
a function is being defined, but is not yet completed.
|
||||
|
||||
Each command sequence terminates only on an end of file. In
|
||||
addition, commands can consist of expression sequences, which are
|
||||
described in the next section.
|
||||
|
||||
|
||||
NOTE: Calc commands are in lower case. UPPER case is used below
|
||||
for emphasis only, and should be considered in lower case.
|
||||
|
||||
|
||||
DEFINE function(params) { body }
|
||||
DEFINE function(params) = expression
|
||||
This first form defines a full function which can consist
|
||||
of declarations followed by many statements which implement
|
||||
the function.
|
||||
|
||||
The second form defines a simple function which calculates
|
||||
the specified expression value from the specified parameters.
|
||||
The expression cannot be a statement. However, the comma
|
||||
and question mark operators can be useful. Examples of
|
||||
simple functions are:
|
||||
|
||||
define sumcubes(a, b) = a^3 + b^3;
|
||||
define pimod(a) = a % pi();
|
||||
|
||||
HELP
|
||||
This displays a general help message.
|
||||
|
||||
READ filename
|
||||
This reads definitions from the specified filename.
|
||||
The name can be quoted if desired. The calculator
|
||||
uses the CALCPATH environment variable to search
|
||||
through the specified directories for the filename,
|
||||
similarly to the use of the PATH environment variable.
|
||||
If CALCPATH is not defined, then a default path which is
|
||||
usually ":/usr/local/lib/calc" is used (that is, the current
|
||||
directory followed by a general calc library directory).
|
||||
The ".cal" extension is defaulted for input files, so
|
||||
that if "filename" is not found, then "filename.cal" is
|
||||
then searched for. The contents of the filename are
|
||||
command sequences which can consist of expressions to
|
||||
evaluate or functions to define, just like at the top
|
||||
level command level.
|
||||
|
||||
If the -m mode disallows opening of files for reading,
|
||||
this command will be disabled.
|
||||
|
||||
READ -once filename
|
||||
This command acts like the regular READ expect that it
|
||||
will ignore filename if is has been previously read.
|
||||
|
||||
This command is particularly useful in a library that
|
||||
needs to read a 2nd library. By using the READ -once
|
||||
command, one will not reread that 2nd library, nor will
|
||||
once risk entering into a infinite READ loop (where
|
||||
that 2nd library directly or indirectly does a READ of
|
||||
the first library).
|
||||
|
||||
If the -m mode disallows opening of files for reading,
|
||||
this command will be disabled.
|
||||
|
||||
WRITE filename
|
||||
This writes the values of all global variables to the
|
||||
specified filename, in such a way that the file can be
|
||||
later read in order to recreate the variable values.
|
||||
For speed reasons, values are written as hex fractions.
|
||||
This command currently only saves simple types, so that
|
||||
matrices, lists, and objects are not saved. Function
|
||||
definitions are also not saved.
|
||||
|
||||
If the -m mode disallows opening of files for writing,
|
||||
this command will be disabled.
|
||||
|
||||
QUIT
|
||||
This leaves the calculator, when given as a top-level
|
||||
command.
|
||||
|
||||
CD
|
||||
Change the current directory to the home directory, if $HOME
|
||||
is set in the environment.
|
||||
|
||||
CD dir
|
||||
Change the current directory to dir.
|
||||
|
||||
|
||||
Also see the help topic:
|
||||
|
||||
statement flow control and declaration statements
|
||||
usage for -m modes
|
Reference in New Issue
Block a user