	PortaCalc

	Brought to you courtesy of

	Glenn Everhart
	409 High St.
	Mt. Holly, NJ. 08060 USA
	609-261-3709

Version 5.4 and 5.4-VM, Summer 1983
	This version of PortaCalc is smaller, faster (by a large factor)
and more capable than the ones on Fall '82 SIG tapes. It is now fully
3 dimensional as well (by a reasonable definition of that.) Also, the
keypad finally works on VAX as well as PDP11. See KEYPAD.DOC for info on
the supplied default command files for implementing keypad functions.
This spreadsheet finally can do matrix math and has (in the usrfct.src
module which may be optionally included for VAX) some routines for
iteratively searching up to 8 dimensional spaces for solutions to
problems. It is the first spreadsheet able to do really significant
math in addition to the simple routines needed for finance calculations.

ABSTRACT:
	The PortaCalc spreadsheet is a FORTRAN written program able to
perform the usual "what if" types of calculations for anyone with a
compiler, 31KW of task space (more or less), and (in the present
version) an ANSI 3.64 terminal (e.g. VT100). The program is easily
recustomized for other terminals and designed for portability and
functionality. A data management system interface is built in, permitting
spreadsheets to access a potentially unlimited number of files and
records or parts of records in those files for user defined functions,
numbers, formulas, text, or whatnot. In fact it has many of the attributes
of a language.
	Three versions are provided, with complete source code for
all: a PDP11 version for I/D space machines that builds flat under
RSX11M+, an overlaid version for other mapped PDP11's under regular
RSX (11M or 11D/IAS), and a version for VAX that builds (flat of
course) under VMS. I assume the F77 compiler but the program is in
Fortran 66 (I use the /NOF77 switch). It is expected only minor changes
would be needed for the DEC Fortran IV compiler however.
	A separate graphics output task is documented in PCG.DOC
and provides histograms or scatterplots of any areas of the saved
spread sheets with a simple command syntax.

RESTRICTION:
	The overlaid version provides only a rather small spreadsheet,
though it is large enough to be useful in many applications. There are
some overlay tricks I haven't tried to increase the size, notably clustering.

SPECIAL HARDWARE:
	The software must be built for the appropriate terminal. Versions
of the UVT100 subroutine for VT100, VT52, Datamedia Elite, and several 
other types of terminals including VT100 with Advanced Video and Colorscan 10
are supplied, with command files for most combinations. The VT52 version
will show what the minimum requirements are for control. Most any terminal
can be easily interfaced to the package by editing one of the UVT100 routines
to correspond to the terminal's control sequences, provided direct cursor
addressing is supported.

BUILD:
	There are 4 major build files.
	COMPIL.COM	Build for Vax/vms...only compiles. Concatinate
			the objects and link.
	COMPILVM.COM	Builds a VAX/VMS version of the sheet that does
			not use a random access workfile on disk (and may
			run a bit faster than the standard one for that
			reason) but with all other capabilities.
	MAKE.CMD	Non-overlay I/D space build for RSX11M+ V2
			(uses F77 Compiler in non-F77 mode)
	SOMAKE.CMD	Compact overlay structure, OK for any 11,
			RSX11M/M+.
Note: THERE ARE COMPILER WARNINGS (ABOUT FUNCTION "INDEX") WHICH SHOULD
	BE IGNORED DURING THE BUILDS.
		I ASSUME FORTRAN 77 IS INSTALLED AS ...F4P.

	PRIOR TO BUILD:
	You must be sure the final VKLUGPRM.FTN is as you will need it.
The PDP11 command files generally copy one of the template versions to
this file, but the parameter file may be edited as may any template.
The VAX versions of command files generally assume you know what you
have is right. READ the appropriate template.
	Supplied templates include:

	VVKLUGPRM.FTN	VAX "standard" version for VT100 with or without AVO
	BVKLUGPRM.FTN	VAX "big" version for VT100
	VVKLUGPR5.FTN	VAX "standard" version for VT52 systems
	BVKLUGPRM.FTN	VAX "big" version for VT52 terminal use
	MVKLUGPRM.FTN	PDP11 version for RSX11M+ V2 I/D space, VT100
	MVKLUGPR5.FTN	PDP11 version for RSX11M+ V2 I/D space, VT52
	SVKLUGPRM.FTN	PDP11 version for RSX11M/M+ overlain, VT100
	SVKLUGPR5.FTN	PDP11 version for RSX11M/M+ overlain, VT52

Note that several variants of UVT100 exist too. The ones presently
included are:

	UVT100.FTN (.FOR for VAX)	VT100 control, no Advanced
				Video Option (AVO) assumed. Many entries
				are not called by PortaCalc. The ones
				that are used are:
					CUP	Cursor Position
					ED	Erase Display
					SGR	Set Graphics Rendition
					EL	Erase Line
					ANSI	set ANSI mode (may be nooped)
	UVTAVO.FTN	VT100 control with AVO terminal support. Includes only
				entries needed. Also uses underline to
				underline alternate rows and will display
				display-sheet row numbers as well as physical
				ones.
				This version will also highlight negative
				values in intensified video.
				By editing to change how NUL is set in the
				CUP entry, this could be set to highlite
				entries over/under a fixed amount (put the
				amount in one of the letter accumulators).
	UVT52.FTN	VT52 control. Since VT52 terminals have no reverse
				video, draws a ">" character in first col. of
				cell pointed at to indicate cursor location.
	UVTDM.FTN	Datamedia Elite 1500 control. Similar to UVT52 but
				cursor controls for Datamedia.
	UVTCS.FTN	Datamedia Colorscan-10 control. This terminal uses
				VT100 sequences, but UVTCS will use some of
				the color setup sequences to create a
				multicolor spread sheet. Colors are not used
				for showing negative numbers but could be
				adapted to (compare UVTAVO).
	UVTTV925.FTN	Televideo 925 experimental version. This version
				has not been well tested but is intended
				for Televideo 925 terminals.
You may easily adapt the UVT100 subroutine from any of these to handle
whatever terminal you have using these routines as examples. Note the
parameter JVTINC in the VKLUGPRM.FTN which adjusts for the backspace
generated by UVT100 on SGR calls needs to be set correctly.
	Adapting UVT100 to your terminal and setting up VKLUGPRM.FTN
correctly are the necessary setup actions needed prior to compiling
and building PortaCalc. You may of course get UVT100 to determine
what terminal type is there itself, or use the VMS terminal independent
cursor positioning logic, if you wish. On a VAX you may also want to
inhibit scrolling. To get PortaCalc to control the PDP11 more efficiently
you may also want to SET /SERIAL=TI: under RSX (which will inhibit MCR
from grabbing input you want to send to PortaCalc).
	The RSX flavors of PortaCalc can use escape sequences and now
recognize VT100 arrow keys (VT52 too) and also that PF2 means "help".
On VMS, the ESCAPE parameter works differently so the arrow key support
is somewhat flaky. Edit to use a QIO$ to read the commands to fix this
if you wish, just before CMDMUN is called...
Remember under VMS to copy the desired file to VKLUGPRM.FTN before
compiling.
	Ignore compiler/linker errors in RSX or VMS. They are harmless
warnings.
	On overlay builds, some functions (notably the F file readin
function) are commented out of OXQTCMD.FTN. You may uncomment them to
get the functions if things fit. They may. Journaling is commented out
except for VAX versions due to number of open files needed. Uncomment
for PDP11 if you wish.
	You should be able to build PortaCalc with regular old F4P
but you may need minor changes to some OPEN statements.
	Note too the CMDMUN and TTYINI routines to set up the console.
The supplied RSX versions implement case translation and enable the arrow
keys. The VAX CMDMUN usually should be used but its' TTYINI is probably
wrong and the dummy should be used. The idea is to effectively
SET TERM /ESCAPE (and SET TERM /NOWRAP) on VMS to get the full escape
sequences in. At least set the nowrap attribute. VMS does funny things
to the escape sequences; I haven't deciphered them yet.

	You will find 4 user function routine areas too:
	USRFCT.FTN	Version supporting return of system date
	USRFCT.FOR	Supports also matrix equation solution
	USRFCT.ASC	Supports matrix determinant, matrix value
			copy also
	USRFCT.SRC	Supports matrix multiply/add/subtract also,
			and general functional vary for VAX.
Note the USRFCT programs are designed to be points for you to plug in
your favorite statistical subroutines. They'll need extra routines
which you'll find sources for here (things like MTXEQU, MDET, GMSUBS)
which may not be well included into command files. However, they may
be linked together and used to support functionality far beyond that
of conventional sheets.

WRITEUP:


	This is a spreadsheet written in Fortran (the only universal
assembler) for portability. Its functions are described in the separate
document file; it assumes VT100, but the UVT100 routines are the
only places the VT100 is actually handled in screen mode, and may be
altered for other machines.
	The spreadsheet sizes may be defined by editing the parameter
file Vklugprm.ftn (caveats and restrictions are listed there). There
are 2 sheets -- a big physical sheet and a small display sheet which
is what's really shown on screen. Sheets may be saved/merged/restored/
linked (via saved files)/printed or hardcopy made onto files. Numerous
other functions exist.
	The sheet's physical size can be tailored to any desired size
(subject to memory constraints) by editing VKLUGPRM.FTN and recompiling.

	WHEN BUILDING PORTACALC, YOU MAY ENCOUNTER FORTRAN WARNINGS
ABOUT THE INDEX FUNCTION BEING ASSUMED USER SUPPLIED. IGNORE THESE;
THERE IS AN INDEX FUNCTION SUPPLIED HERE, AND THE WARNINGS ARE OF
NO CONSEQUENCE, EITHER ON PDP11 OR VAX.

	There are 2 ODL files, either of which can build a reduced
version when the fortran files are compiled with OVKLUGPRM.FTN
renamed to VKLUGPRM.FTN, included. There is a bit of extra space
so the parameters in that file can be enlarged somewhat. They use a
very overlain FCS and F4P OTS. You may be able to do similar things
clustering an FCSRES and a F4PRES together too. However, the overlay
versions (made with the OMAKE.CMD file) do work, though more slowly
than the I/D space one. This at least gets you something on a machine
with only normal 11/34 type resources. I assume the F4P or F77 compiler
here for the OTS part. You will need to tailor to other Fortran
compilers on PDP11's yourself.

		NOTE:
	If you get this program working on a non-PDP11, non-
VAX, the author would appreciate a (machine readable) copy of
the modified version.

BUGS:
	The functions here are mostly tested, but some bugs may remain.
	Fortran formats are used and any format entered will be used.
If you put something in that Fortran can't understand, you lose.
Portacalc will try your format once before writing to disk, however, to
(hopefully) prevent you from generating an un-reusable work file.
Conversely, you can use things like O or Z formats for octal/hex
or whatever you like. Formats A and L by themselves mean "display the
formula itself"; anything else means "display the number". On entering
numbers, any formula containing the characters ".","[","+", "(", or "-" is
treated as a numeric; anything else is treated as a formula, unless the
string contains the double quote (") character, which forces it to be
treated as a literal rather than a number regardless of what else it has.
The DF command can fix up this if it's not what you want. Note too that the
multi-argument functions:
	SUM[args]	Sum
	MAX[args]	Maximum
	MIN[args]	Minimum
	AVG[args]	Average
	STD[args]	Standard Deviation
and the statement
	IF [v1.RL.v2]true-statement|false-statement
must appear at the start of a formula or formula substatement (substate-
ments are delimited by \ characters) and the value goes into the
current variable cell (which is universally named P## if you want something
location independent). It's a good idea to include an else statement in
IFs since something gets put in otherwise.
			Glenn Everhart

FURTHER NOTE:
	In response to some user queries, I have added some comments in
the XQTCMD.FTN and OXQTCMD.FTN code about journaling. They are a section
of code (look for it just before the string "'*'" (minus the " chars))
which will implement journaling. The syntax of the journaling command
would be
	+J filename
which will cause Portacalc to record all commands issued to it in a file
of the given name. The command +N will close the journal file and stop
recording..
	If you want to implement the functions, just take out the initial
C's in column 1 and use. It uses unit 10, and I didn't want to overload
task size on PDP11's. On VAX it should be fine.
			Glenn Everhart
	The journaling commands are implemented by default for VAX; not
for PDP11 for size reasons. Try them if you want however; they work well.
