mc

Section: MacroCALC (1)
Index  

Name_

mc - Command
MacroCALC v10.33. Interactive spreadsheet calculator.
On Systems where mc is used by other programs, 321 can be used as an alias for mc. 321 means 321 is more than 123.  

Synopsis_

mc [-option...] [file]  

Description_

mc is an interactive, macro-programmable spreadsheet calculator. mc has no graphic features, but therefore it can run also on terminals. It uses a convenient, well-known user interface and has some special features especially interesting in the UNIX environment. It is the only spreadsheet that can handle units in calculations - so 1m + 1km = 1001m.  

Options_

-l
Sets alternative screen layout with input line at the bottom.
-b
Suppress displaying the borders with column and row numbering.
-s
Suppress displaying current cell in line 1 of the screen. This is especially interesting on slow terminals, since moving around is much faster.
-m
Suppress displaying the menu, marked range and the recalculation message for slow terminal lines.
-h
Suppress highlighting of the marked range for slow terminal lines.
-e
Combination of -bmsl options for a complete clean screen with only data displayed.
-k
Suppress using colors even when the terminal is capable of.
-cg
Marked range is full spreadsheet after load.
-cw
Sets preset column width to w. Default is 11.
-dp
Sets preset decimal places to p. Default is 2.
-fF
Sets preset format to F. Default is General. Possible formats are:

F
Fixed
S
Science
C
Currency
,
Comma
P
Percent
D
Date
T
Time
G
General
-yc
Sets currency symbol to c. Default is dollar ($).
-a
No autocalc mode.
-r
Read-only mode. Worksheets cannot be saved. This is useful, when output is done by "cell>command" statements. See shell-script mcrdb for an example.
-omacrofile
Auto-execute macro found in macrofile after loading the worksheet. This option also suppresses the interactive startup message. The macrofile "-" only suppresses the interactive startup message.
-nmacrocommands
Auto-execute macros in macrocommands after loading the worksheet. This option also suppresses the interactive startup message.
-x
Sets command autoexec mode. All cell-commands "cell<command" found in a new loaded worksheet and "cell>command" found in a saved worksheet will be executed automatically.
-u
Starts $ARX/mcunits as a background process for unit conversion calculation. The "units" function of mc can only work with this option! Startup is slower with this option, so only use it if unit conversion is needed.
-p
Pipes the standard input (a worksheet file) into the standard output ([nt]roff source format) without interactive action. This must be the last option when present! This is especially interesting because mc uses a fully transparent, editable ASCII file format, which is compatible with the /rdb database system. The worksheet file can easily be edited or manipulated with almost any UNIX command such as sed or awk. You can also use /rdb's 100-plus powerful database commands.
-q
Pipes the standard input (a worksheet file) into a "comma-separated-values" file without interactive action. This must be the last option when present!
-v
Prints version information. Options are also taken from the environment variable "MACROCALC".
 

General Overview_

A worksheet is a table built from columns and rows. Every point of intersection between a column and a row is called a cell. A cell can be filled with text, constant values or formulas.

mc supports:

- 702 columns named A..Z and AA..ZZ

- 99999 rows named 1..99999.

Every cell has a unique cell address with column and row name ranging from A1..ZZ99999.

Since a monitor can only display 24 rows and 80 characters at any given time, only a small part of the worksheet is displayed. One cell, the current cell, is highlighted and its contents is displayed in line 1 of the screen (unless option -s was given at startup). Movement around through the worksheet is possible with the cursor keys. Line 2 of the screen is the edit line where cell input is displayed. Line 3 is the status and message line where information is displayed. The rest of the screen shows the worksheet.  

File format_

mc uses a fully transparent and easy-to-understand file format to store worksheets. It is organized like a table and is compatible with /rdb table database format. The columns of the table are separated with <tab>, the rows with <newline>. At the top of each column is a column name and a dashed row to separate the names from the data. The columns are:

Cell
Cell address
Attrib
Cell attribute code
Format
Cell format code
Value
Cell value
Text
Cell string with justification sign

NOTE
Files produced by mc V1.x must be transformed by the utility mc2conv with the command:

mc2conv <mc1file >mc2file
This command transforms the old file into a form that can be read by mc V2.x and its successors. It is also a example of processing an mc file with awk.  

Recalculation_

To save memory, formulas are stored as text without any additional parsing information: therefore recalculation is slow. For large worksheets, autocalc mode should be turned off by using the menu command /Worksheet Autocalc or the option -a. Manual recalculation is started with [Recalc] after finishing with entries.  

Function keys_

In this manual the function keys are referenced by their names in square brackets.
F1 ?
[Help]
To access Help.
F2 !
[Edit]
Places the contents of the current cell in the edit line and enters the edit mode. When finished editing, press [Enter] 8 to accept the changes and return to the ready mode.
F3 .
[Mark]
Marks the current cell for further usage (see also Range, Copy, Move ).
F4 %
[All]
Marks the whole worksheet for further usage (ie. for Print).
F5 >
[Goto]
Prompts for a destination cell.
F6 $
[Macro]
Prompts for a macro file to execute.
F8 #
[Exit]
Save and exit. Updates current file without prompting and exits.
F9 =
[Recalc]
Recalculates all cells that contain a formula.
F10 /
[Menu] Enters command menu (also "<" can be used for convenience with international keyboards).
 

Moving around_

The following keys move through the worksheet. Moving is simply changing the current cell, which is displayed highlighted.

Function-Key Control-Key Description
[Up]         Ctrl+P      Move up one row
[Down]       Ctrl+N      Move down one row    
[Left]       Ctrl+B      Move left one column    
[Right]      Ctrl+F      Move right one column  
[Tab]        Ctrl+I      Move right one page 
[Shift-Tab]  Ctrl+G      Move left one page
[Home]       Ctrl+A      Move to cell A1
[End]        Ctrl+E      Move to last cell
[Pgdn]       Ctrl+V      Move down 20 rows
[Pgup]       Ctrl+U      Move up 20 rows  

NOTE
The Ctrl+Letter alternative keys are for terminals without special function keys. Most of them are the same as in the EMACS-Editor.  

Range_

A range is a rectangular sub-section of the worksheet which:

- is defined by two cells at two corners of the range

- encompasses all of the cells inside this sub-section.

Several commands act upon a range of cells. The [Mark] key specifies a corner of the range. There is always a marked range shown at the top of the worksheet. The marked range is also displayed highlighted (unless option -h was given at startup). Inside the marked range the current cell will be not highlighted. Before a command that acts on a range can be used, the correct range must be marked.

A range can be named with the /Range Name command. This name can be used in formulas. A valid range name consists of a starting character and at least one more alphanumeric character or the special characters backslash (\), underscore (_) and dollar ($). When a named range is used for a cell, the upper left cell of the range is used. Named ranges are adjusted when moved or after inserting or deleting columns or rows.  

Menu_

With the [Menu] key, mc enters the command menu. Within the menu there are powerful commands to alter the worksheet. To choose a menu item move to it with the cursor-keys until it is highlighted and press the [ENTER] key, or press the highlighted character of the item.
Worksheet
Insert
Column
Inserts columns at current position.
Row
Inserts rows at current position.
Delete
Column
Deletes current column.
Row
Deletes current row.
Column
Sets current column width.
Autocalc
Turns auto calculation mode on and off.
Formula
Turns formula display mode on and off.
Erase
Erases entire worksheet.
Titels
Horizontal
Freezes the rows above the current cell on the screen as a title.
Clear
Clears the title.
Page
Inserts a page break.
Range
Format
Formats Set display formats.
Attrib
Attributes Set display attributes.
Color
Colors Set display colors.
Erase
Erases a range.
Name
Create
Creates a named range.
Delete
Deletes a named range.
Prot
Protects a range.
Unprot
Unprotects a range.
Value
Values a range. All Formulas in the range are substituted by there actual value.
Copy
Copies marked range to current position.
Move
Moves marked range to current position.
File
Save
Saves current worksheet to file.
Part
Saves only marked range of current worksheet to file.
Retrieve
Retrieves file and replace current worksheet.
Merge
Merges file with current worksheet.
Print
Prints marked range of current worksheet.
Display
Redisplays in case of a corrupted screen.
Sys
Opens a subshell.
Quit
Leaves mc.
 

Macros_

A macro is a sequence of keystrokes or commands which can be performed automatically, just like a program within the spreadsheet. Unlike most spreadsheets, macros in mc are stored in files instead of inside the worksheet. A macro can be executed with the [Macro]-key. The macro will continue to execute until end-of-file. An auto-execute macro (see option -o ) starts executing immediately after the worksheet is loaded.

Every letter in the macro is simply feeded into mc as normal input. Exceptions are <tab> and <newline>; they do nothing. All macro keys must be enclosed in curly braces {}. An optional repeat count can be appended.
MACRO KEYS
When encountered in a macro file while executing, they make mc behave as if the corresponding key was pressed.

{LEFT}   - cursor left    {BIGLEFT}  - one page left
{RIGHT}  - cursor right   {BIGRIGHT} - one page right
{UP}     - cursor up      {PGUP}     - one page up
{DOWN}   - cursor down    {PGDN}     - one page down
{HOME}   - cursor to A1
{EDIT}   - F2             {GOTO}     - F5
{CALC}   - F9             ~          - Sub for [ENTER]
{ESC}    - Escape         {END}      - End Key
{INS}    - Insert key     {DEL}      - Del key
{MENU}   - Call main menu {MARK}     - Mark cell

ENVIRONMENT
Variables from the process-environment can be included in the macro by preceding them with "$".
COMMENTS
Lines starting with "#" are completely ignored and are therefore comments.

Try the following simple macro which enters the string "hello, world" into the current cell and moves the cursor down one cell and right two cells. Type the following in file "test.mcr" with an editor of your choice:

# this is a comment
hello, world~
{DOWN}{RIGHT 2}
and call the macro with [Macro] and the filename "test.mcr".
LIMITATIONS
There are no higher macro statements implemented yet.  

Formatting_

The formatting of a range of cells is set with the /Range Format command.

Type       Example
---------- -------------
Fixed      123.12
Science    1.234e+06
Currency   $533.89
,          2,400.90
Percent    87.4%
Date       May 31 1991
/rdb-Date  970531
Time       12:45:08
General    123.1299
Hidden     

After Fixed or Science formats, mc prompts for the number of decimal places to be displayed. The default format for all new cells is General, which is a generic format. The default format and decimal places can be changed with the -f and -d options at startup. When a new cell is entered and the cell above (one row higher) has a non-default format, the new cell is auto-formatted with that format. This helps setting up tables of data. Cells with no contents cannot be formatted. The cell value does not change when formatted. Bold and Italic are not formats, but are attributes (see below).  

Numbers_

Values can be entered in a cell simply by moving to the cell and typing in the number. With the [Enter] key, mc will put the text into the current cell and display its contents.
COMPLEX
Complex values are entered with "i" between the real and the imaginary part. For example "0i1" is the representation for "i" = SQRT(-1).  

Text_

Text can be entered in a cell simply by moving to the cell and typing in the text. With the [Enter] key, mc will put the text into the current cell and display its contents.
JUSTIFICATION
Text cells can be displayed left or right justified in a cell depending on the first character, the justification sign. If the first character is an apostrophe (') the text will be left justified. If it is a quotation mark (") right justified. If no justification sign is specified at the start of the text, mc will add a left justification sign as default.
REPEATING
The special justification sign backslash (\) will cause the following character be repeated in the whole cell.  

Formulas_

Formulas are entered like text. mc will determine whether the entered string is a legal formula or text. If a string starts like a formula, mc assumes a syntax error and put the cursor in the place where the error starts. If the cell is text and not a formula, simply press [Escape] or begin the text with one of the justification signs.

Cell names in formulas are typed in with the column followed by the row enclosed in square brackets separated by comma. Relative cell references start with a sign. An absolute cell reference can be written without brackets or comma. Toggle absolute cell references in formulas with relative references by pressing F4 (or $). Named Ranges can be used directly with the rangename.

ex. A1+[A,2]*[B,-1]^5/([+0,+2]+SUM(Myrange))

SPECIAL
Formulas can be used recursively! That means that in spite of copying a formula cell, the absolute cell reference preceded by ampersand (&) can be used. This saves memory and, when changing the formula, all formulas entered in this way will change automatically, because they refer to the same formula text string! Think of this as a way of defining user functions in a worksheet.

ex. A1: value:   1.00
    B1: formula: 2*[-1,+0] = 2.00
    A2: value:   2.00
    B2: formula: &B1       = 4.00

CONSTANTS
mc recognizes the following special constant values in formulas:

PI
Value of PI = 3.141592.
E
Value of E = 2.718281.
I
Value of I = 0i1 the imaginary unit.
SQRT2
Value of sqrt(2) = 1.414213.
COL
Current column number.
ROW
Current row number.

STRINGS
Strings in formulas are entered enclosed in quotation marks ("). If a cell is preceded by hash (#) it refers to the cell string instead of the value. Strings can be concatenated without any operator.  

Dates_

Dates can be entered as formulas like

@DATE(97,4,21)
As a shortcut for this function call, dates can be directly entered either the american way

04/21/97
04/21/1997
or the european way

21.04.97
21.04.1997
In both cases mc will determine the input as a constant date value, call the @DATE-function with the appropriate values and automatically format the cell with the date format, unless the cell was formatted before with a different format.  

Operators_

An operator is a function that is built into mc formula language. It usually relates one operand to another. The following is a table of the mc operators:

Op  Description
--  -----------------------------
^   Power
*   Multiplication
/   Division
+   Addition
-   Subtraction
==  Equivalence
!=  Inequality
<   Less than
<=  Less than or equal to
>   Greater than
>=  Greater than or equal to
&&  Logical AND
||  Logical OR

In addition to these C-like operators, also operators known from other commonly used spreadsheet programs (e.g.: #AND#, #OR#, ...) can be used.  

Precedence_

Precedence refers to the order in which mc executes operators. Cell formula languages assign a level of precedence to each operator. Operators are executed in the order of their precedence level, from highest to lowest.

The following table summarizes the precedence of mc operators. They are listed in descending order of precedence: those listed higher in the table are executed before those lower in the table. Operators listed on the same line have the same level of precedence, and the implementation determines the order in which they are executed. If you use two or more such operators in the same expression, you would be wise to use parentheses to indicate exactly the order in which you want the operators executed.

Operator      Precedence
------------  -------------
(  )          Left to right
-             Right to left
^             Right to left
*  /          Left to right
+  -          Left to right
<  <=  >  >=  Left to right
==  !=        Left to right
&&            Left to right
||            Left to right

mc always determines precedence in an expression by enclosing sub-expressions within parentheses: the expression enclosed within the innermost parentheses is always executed first.
SIMPLY
All of the rules of basic algebra apply to expressions in mc. Remember to use parentheses to indicate exactly the order in which you want the operators executed.  

Units_

mc has a unique feature called automatic unit conversion. If you use the -u option at startup, then $ARX/mcunits acts as a background process to convert units. You can assign a unit to each constant value in a formula by placing it in curly brackets after the constant.

ex. 2.3{g} -- makes this 2.3 grams.
This will put the string of the unit in the cell right next to the cell with the constant. mc keeps track of all units you use in formulas and will refuse to calculate senseless expressions. When adding a unit (in curly brackets) at the end of a formula, the calculated value is converted to that unit.

ex. A1: value:   12.00{m}
    A2: value:    1.00{sec}
    A3: value:   12.00{mile/hour}
    A4: formula: a1/a2       = 12.00 m/sec
    A5: formula: a3+a4       = 38.84 mile/hour
    A6: formula: a5+6{pound} = ERROR  Unit conformity
    A7: formula: a5{m/min}   = 1041.87 m/min
The syntax of the units is the same as in mcunits. To add units to the database see the documentation of mcunits.
LIMITATIONS
Units are not implemented for the ^ (power) operator and for all nonstatistical functions like SQRT!  

Piping_

mc has a very advanced interface to the operating system via piping. This offers unmatched flexibility based upon the Unix operating system's piping mechanism. Since the database /rdb is based upon the shell level this can be used perfectly for database interactions like queries or updates in tables.

A cell statement with the syntax:

cell<command
is called a cell-command. When such a cell is entered, it will execute the command and put the command's output into the range of cells starting with cell as the upper-left corner. The output is read line by line into the rows of the range. The columns, which have to be separated by <tab> in the output of the command, are placed into the columns of the range. At the end of the data a special cell value designated 'EOF' (end of file) is placed in the cell below the data. Therefore, /rdb commands work especially well with mc because this is exactly the format of /rdb tables. But also all other standard Unix commands like sed, awk, cut, ... can produce output of this format. It is also simple to produce input-files with any standard editor, or write own programs which can feed mc. Since formulas can be used recursively with the '&' operator; you can also build flexible commands of querying or updating a database.

ex. B2<cat expenses
Puts the table expenses into the cell range B2..F5.

ex. B2<row 'Onhand < &F15' <inventory
Select all rows in the inventory table in which Onhand is less than the value in the cell F15 into the cell range B2..G5.

A cell statement of the form:

cell<<command
will act the same way but does not overwrite the data in the output range. The data is inserted into the worksheet by inserting a new row into the worksheet for every line in the commands output. Existing cell contents in the first row are copied into every inserted row. This is useful, when a formula should act on every line of the output.

A cell statement of the form:

cell<!command
will act the same way but parses the incoming cells as formulas. This is especially useful with the mcread command. This command is part of the system and can extract the formulas of a given range or the whole worksheet from a mc-file from standard input. It inserts <tab> between the formulas of the selected columns. With this combination any range from a extern worksheet-file can be easily copied to a range in the current worksheet. For example the command:

f9<!mcread -rb3-d7 <somedata.mc
selects all constants/formulas from range B3.D7 in the worksheet-file somedata.mc and copies them to the range starting with cell F9 into the current worksheet. This procedure has the advantage that the source file and range are stored in the command-cell, and can always be re-imported by re-editing and re-executing the command (see below). The disadvantage is that the attributes and formats are not imported, but once they are set up, they are used by the next import and keep intact. Call mcread with the -h option to get a reference of the command.

A cell statement of the form:

cell>command
will execute the command and feed the cell range starting with cell into the input of the command. The cell range starts with cell in the left upper corner until it reaches an empty cell right of the starting cell, and until it reaches the 'EOF'-cell on the way down the worksheet.

The cell statement:

B2>cat >expenses
places the updated table from the worksheet back into the database. To determine where to stop, the special 'EOF'-cell must be found. It can be entered by placing the string "EOF" into the cell below the data, as long as it was not written by a former query.

To reexecute any cell-command simply reedit it with [Edit] [Return].
ERROR MESSAGES
All output to standard error of cell-commands is redirected to the mc error message line.  

mcrdb_

The shell-script mcrdb uses mc as a table editor for structured text-files or /rdb-tables. With the command:

mcrdb table
the file (or /rdb-table) "table" is locked and loaded into a worksheet. mc is called for editing the table in a much more convenient way than with ve, the /rdb table-editor. The user can see more than one row simultaneously, and all spreadsheet-power can be used to modify the data. Inserting, copying and deleting rows or fields is very easy. It is a good idea to examine the shell-script how it works as an example of using the advanced integration possibilities of mc and /rdb. Of course mcrdb can only work when /rdb is installed.  

Linking_

The worksheet currently in memory can be linked to worksheets on disk using the LINK function of mc.

    LINK("filename",cell)
ex. LINK("/u/tom/sample.mc",A23)
Since file linking is slow, linked cells are not recalculated. However, if you enter a cell

ex. LINK("/u/tom/sample.mc",A23)+A12
then the link is recalculated every time because it is a formula! To avoid this, place only the link in one cell and put a formula in an additional cell which refers to the link-cell. Another advantage of this way is, that the cell in the link is not adjusted in column or row deletes or inserts or moves of the cell in the link. To avoid this misbehavior, it is also possible to use named cells and build the link with the name instead of the absolute reference.  

Mathematical functions_

The following functions act upon the argument 'x' within the parentheses. 'x' can be a value or a formula which references other cells within the worksheet. The (C) indicates availability for complex values.
ABS(x)
Returns the absolute value of argument. (C)
ex. ABS(-10) = 10
ACOS(x)
Arc Cosine, returns radians. (C)
ex. ACOS(0.5) = 1.0471
ASIN(x)
Arc Sine, returns radians. (C)
ex. ASIN(0.866) = 1.0471
ATAN(x)
Arc Tangent, returns radians. (C)
ex. ATAN(1.732) = 1.047
COS(x)
Cosine of angle, x in radians. (C)
ex. COS(1.047) = 0.5
EXP(x)
Raises 'e' to the 'x'-th power. (C)
ex. EXP(5) = 148.4131591
INT(x)
Integer value of argument. The fractional part of the number is truncated and the integer remainder is returned.
ex. INT(10.6) = 10
LN(x)
Natural Logarithm to base 'e'. (C)
ex. LN(6) = 1.791...
LOG(x)
Logarithm to base '10'. (C)
ex. LOG(10) = 1
SIN(x)
Sine of angle, x in radians. (C)
ex. SIN(1.047) = 0.866
SQRT(x)
Square root of argument. (C)
ex. SQRT(2) = 1.4142135624
TAN(x)
Tangent of angle, x in radians. (C)
ex. TAN(1.047) = 1.732
 

Logical functions_

IF(Condition,arg1,arg2)
Value of arg1 if Condition is true. Value of arg2 if Condition is false.
ex. IF(10>2,3*2,4+5) = 6
 

Financial functions_

CTERM(INTerest,FutureValue,PresentValue)
The number of compounding periods required for an investment of PV (present value) to grow to FV (future value), if the investment is earning INT interest per compounding period.
DDB(Cost,Salvage,Life,Period)
Accelerated depreciation value for an asset, given the initial cost, the life expectancy, the end value and the depreciation period. The depreciation is calculated using the double declining balance method.
FV(Annuity,interest rate,period)
Returns the future value corresponding to an annuity occurring over the specified period. Reverse of the above.
ex. FV(700,0.0925,30) = 99979.77
PMT(Principal,interest,period)
Returns the amount of an annuity equal to the principal amortized over the period.
ex. PMT(75000,0.0925,30) = 7462.61
PV(Annuity,interest rate,period)
Returns the present value corresponding to an annuity occurring over the specified period. Reverse of the above.
ex. PV(700,0.0925,30) = 7035.08
RATE(FutureValue,PresentValue,N)
Interest rate required for an investment of PVAL to be worth FVAL, in N compounding periods.
SLN(Cost,Salvage,Life)
Straight line depreciation of an asset over ONE period of LIFE.
SYD(Cost,Salvage,Life,Period)
Depreciation of an asset using the Sum-of-Years depreciation method.
TERM(Payment,Interest,FutureValue)
Number of periods required to accumulate an investment of FVAL making regular payments of PMT and accruing interest at the rate of INT per period.
 

Statistical functions_

Statistical functions operate on a range of values. A range specifies a rectangular block of data in the worksheet. Only ONE range may be used as an argument.
ex. Range = A1..B10 defines the block of data from:

      a1...b1
       .   .
       .   .
       .   .
     a10...b10
Presented below are the statistical functions available within mc. To illustrate the use of each function an example is included. All examples will operate on the numbers contained in the portion of the worksheet duplicated below, A1..C3.

              A        B        C
        1       1.1      5.6      8.2
        2       2.3      7.5       10
        3       3.5      4.4        2
        4
AVG(Range)
Average value of the range.
ex. AVG(A1..C3) = 4.955555
COUNT(Range)
Count the number of elements in the range. Blank cells ignored.
ex. COUNT(A1..C3) = 9; COUNT(A1..A4) = 3
MAX(Range)
Maximum value in the range.
ex. MAX(A1..C3) = 10
MIN(Range)
Minimum value in the range.
ex. MIN(A1..C3) = 1.1
STD(Range)
Standard deviation of the range.
ex. STD(A1..C3) = 2.904827
SUM(Range)
Sum of values in the range.
ex. SUM(A1..C3) = 44.6
or A1..C3 = 44.6
VAR(Range)
Returns the population variance of the range.
ex. VAR(A1..C3) = 8.438024
 

Date/Time functions_

DATE(YY,MM,DD)
Serial number of days from Jan 1 1900 to Year = YY, Month = MM, Day = DD. YY from 0 to 37 will be transformed automatically to 2000 to 2037. To get a date before 1938 enter 19YY into the year value. (Note: Cell need to be in date format to display dates)
ex. DATE(87,5,20) = 31917
TODAY()
Returns the serial number of days to now.
TIME(HR,MIN,SEC)

Fraction of day corresponding to HR:MIN:SEC
DAY(X)
The Day in X.
ex. DAY(31917) = 20.
HOUR(X)
The Hours in the fractional part of X
MINUTE(X)
The Minutes in the fractional part of X
MONTH(X)
The Month in X.MONTH(31917) = 5 (May)
SECOND(X)
The Seconds in the fractional part of X
YEAR(X)
The Year in X.
ex. YEAR(31917) = 87
 

String functions_

LENGTH(string) or LENGTH(Cell)
Number of characters in string.
 

User functions_

User functions are functions developed in the C programming language. They must be compiled with the C compiler and linked with the kernel of mc. Everything that is needed to build a special version with user functions is included in mc. To build a new mc the following steps must be completed:
1.
Change into the directory $ARX/mc/src. This directory contains following files:

makefile
Makefile for the new mc
mc_kern.o
kernel of mc
libmcf.a
archive with mc functions
f.tab.h
header for function types
mcfunc.h
header for functions
mcftab.c
function table
mcuser.c
user functions source code
2.
Develop your functions in C in the module mcuser.c. Every function must be a double returning function with up to four double parameters or a single string parameter.
3.
Add description entries in the files mcftab.c and mcfunc.h for every developed function. Carefully read the comments in these files that explain how to describe your function correctly.
4.
Simply compile and link the new mc with make
5.
Test the new mc and the new functions with ./mc
6.
Copy the new mc into the bin directory with
cp $ARX/mc/src/mc $ARX/bin
 

Language support_

mc is language configurable. The error messages and the menus are held in separate editable files, which are read in at startup of mc. The files can be translated into any language and can be altered by the "bin" user with any editor.

The messages are held in the Message file $ARX/lib/mcmsg.rdb. This file is a /rdb-table (see File format ). To alter the file simply reedit only the messages without altering the rest of the file.

The menus are in the Menu file $ARX/lib/mcmnu.rdb. This is a simple list of the available menus. To alter the file simply reedit every menu keyword without altering the order of the keywords! The "hot-key" for every menu item is the first uppercase or non-alphabetic character in every keyword.
PLEASE
If you translate the files to any language, please send the translated files to me via Email or on a disk. They will then be distributed with mc.  

Printing_

mc uses [nt]roff to do the hard work of text formatting. The marked range is piped to the shell procedure $ARX/lib/mcprint with the command /Print This procedure passes its input to nroff as the default. $ARX/lib/mcprint can be modified to the user's needs, for example to add a standard header to every printed worksheet or to change nroff to troff and lpr to hpr.

[nt]roff commands can be used by putting them directly into the left side cells of the printing range. For example, the menu command /Worksheet Page simply adds a ".bp" break page command into the worksheet.  

Attributes_

The appearance of a cell on printed output can be set with the /Range Attrib command. Every cell can have a Bold or Italic attribute. mc puts nroff font controlling commands in the output, which is piped through [nt]roff.  

Lotus WKS-files_

A conversion program for the most popular DOS spreadsheet file format WKS (Lotus 1-2-3) is included in mc. mc2wks converts mc-files to and from binary WKS-files. With the command

mc2wks [-option] <mcfile >wksfile
every worksheet produced with mc can be converted to a WKS-file. mc2wks can handle also the mc-options -c -d -f -v and -x the same way mc does.

With the command

mc2wks -r <wksfile >mcfile
every worksheet produced with a DOS spreadsheet which has been transferred to UNIX (or is on a UNIX-DOS shared device) can be converted to a mc-file.
LIMITATIONS
mc2wks can only convert Lotus-WKS- and -WK1-files produced by Lotus Versions 1-2-3 V<=2.x. The newer WK3-files must be converted to WK1-format by the 1-2-3 utility-program TRANS.EXE before using mc2wks with them.

units
Since no DOS spreadsheet can handle units, all unit information is lost when converting from mc to WKS.
range names
Range names longer than 16 characters will be shortened to 16 chars when transferred to WKS. Since range names in mc are case sensitive and in DOS spreadsheets not, they are converted to uppercase when transferred to WKS.
user functions
User functions and functions special for mc (i.e. @LINK()) will probably generate error messages when loaded with the DOS spreadsheet, but conversion is done.
functions
Cells containing functions of DOS spreadsheets that are not implemented in mc can not be transferred to mc-file-format. The rest of the worksheet is transferred and an error message is displayed.
arguments
Multiple arguments of statistical functions are not implemented in mc. Therefore only the first argument is recognized when converting to mc-file-format.

Lotus 1-2-3 is a trademark of Lotus Development Corp.  

Dbase files_

db2rdb is a program, that comes with the registered version of mc. It fully supports the use of Dbase-files with mc and other UNIX-commands. See in the docs of db2rdb for further information.

Dbase is a trademark of dBase LLC.  

Examples_

There are example worksheets in the directory $ARX/exm. This directory contains the following files:

sort.mc

Sorting a database. Must be loaded with:

mc sort.mc
how_sort

Description for sorting a database within mc.
unit.mc

Unit conversion. Must be loaded with:

mc -u unit.mc
purchase

Shellscript-Example of /rdb integration with mc. /rdb must be installed in $RDB (usually is $RDB=/usr/rdb, set $RDB in /etc/profile). The /rdb example project /act must be installed in $RBD/act.
purchase.mc

Worksheet for purchase.
purchase.mcr

Macro for purchase.
 

Limitations_

The date and time functions do not work with dates prior to Dec 14, 1902. The date display format does not work with dates prior to Jan 1, 1970 and after Jan 18, 2038 due to UNIX's date limits.

Since there is a bug in cursor positioning of the COHERENT curses-library, the lower-right position of the screen is never displayed.

The function shortcut for SUM(Range) to write only Range (mc V<=3.01) was removed from mc V4 due to parser problems with range names.  

Terminal_

Since this product is based on the curses library, the program run on the console as well as on terminals.

The following table list the keys and their corresponding entries in /etc/termcap or /usr/lib/terminfo/?/*. COHERENT-3.x versions work with termcap, all others with terminfo.

The table also lists the used screen attributes. If you want color output you can change the entries to sequences for colors colors on your terminal.

The keys and screen attributes can only work if their correct entries are made in the terminals description, which is identified by the environment variable TERM.

Key      termcap terminfo Comment
-------- ------- -------- ------------------------------
UP       ku      kcuu1    Move one line/item up.
DOWN     kd      kcud1    Move one line/item down.
LEFT     kl      kcub1    Move one character/item left.
RIGHT    kr      kc       Move one character/item right.
PGUP     Kp      kpp      Move one screen up.
PGDOWN   KP      knp      Move one screen down.
BACKTAB  bt      cbt      Move one screen left.
HOME     kh      kc       Move to begin.
END      KE      kll      Move to end.
INSERT   Ku      kich1    Insert mode.
DELETE   Kd      kdch1    Delete item.
F1       k1      kf1      Function 1 = Help.
F2       k2      kf2      Function 2.
F3       k3      kf3      Function 3.
F4       k4      kf4      Function 4.
F5       k5      kf5      Function 5.
F6       k6      kf6      Function 6.
F7       k7      kf7      Function 7.
F8       k8      kf8      Function 8.
F9       k9      kf9      Function 9.
F10      k0      kf0      Function 10 = Exit.
Attribut termcap terminfo Comment
-------- ------- -------- ------------------------------
Blink    mb      blink    Blink mode on
Bold     md      bold     Bold mode on
Reverse  so      rev      Reverse mode on
Standout so      smso     Standout mode on
Underlin us      smul     Underline mode on
Normal   me      sgr0     Normal mode on
Standard se      rmse     Standout mode off
Standard se      rmso     Standout mode off
Standard ue      rmul     Underline mode off

CAUTION
Since most terminal keys start with the <ESC>-character (octal 033), the ESCAPE-Keys itself needs one second to be decoded!  

Files_

The installation of mc creates the following files:

$ARX/bin/mc
the spreadsheet program.
$ARX/bin/mcunits
the unit conversion program, which is used by the -u option of mc.
$ARX/bin/mcunits.rdb
the unit conversion programs units table (see mcunits for more information).
$ARX/bin/mcrdb
script for editing /rdb-tables with mc.
$ARX/bin/mc2conv
script for converting from mc V1.x to V2.x (compatible with all higher versions).
$ARX/bin/mc2wks
file conversion program from and to Lotus WKS-file-format.
$ARX/bin/mcread
mc file reader for copying ranges from external files into the current worksheet via the cell-command "<!".
$ARX/lib/mcsample.tar
example worksheets to demonstrate the power of mc.
$ARX/lib/mcrdb.mc
worksheet for script mcrdb.
$ARX/lib/mcmacro
program for reading macros.
$ARX/lib/mcprint
script for printing.
$ARX/lib/mcellval
script for linking.
$ARX/lib/mcmsg
program for reading message file.
$ARX/lib/mcmsg.rdb
Message file.
$ARX/lib/mcmenu.rdb
Menu file.
$ARX/mc/src/*
development library files, see User functions.
$ARX/bin/arxactiv
program to add the serial number and the license key to the binary.
 

See Also_

awk, db2rdb, dos, make, me, mcunits, nro, nroff, sed, termcap, terminfo, /rdb  

Author_

Axel Reinhold
Franz-Heinrich-Str. 20
95100 Selb
Germany
Fax:      +49-9287-8244
eMail:    axel@freakout.de
Internet: http://www.freakout.de
(c)  Axel K. Reinhold.


 

Index

Name_
Synopsis_
Description_
Options_
General Overview_
File format_
Recalculation_
Function keys_
Moving around_
Range_
Menu_
Macros_
Formatting_
Numbers_
Text_
Formulas_
Dates_
Operators_
Precedence_
Units_
Piping_
mcrdb_
Linking_
Mathematical functions_
Logical functions_
Financial functions_
Statistical functions_
Date/Time functions_
String functions_
User functions_
Language support_
Printing_
Attributes_
Lotus WKS-files_
Dbase files_
Examples_
Limitations_
Terminal_
Files_
See Also_
Author_