PortaCalc Brought to you courtesy of Glenn Everhart 409 High St. Mt. Holly, NJ. 08060 USA 609-261-3709 Version 7.0 and 7.0-VM, Fall 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: (see also the PRIOR TO BUILD section) There are 5 major build files. Also a number of minor ones; look them over before proceeding. COMPIL.COM Build for Vax/vms...only compiles. Concatinate the objects and link. The next 2 files build 128 by 256 sheets by default. 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. COMPILVMX.COM Builds a version of PortaCalc for VMS that does not use a workfile, runs even faster than COMPILVM's does, and has extra features. The *U XQTCM function allows a command file inside any cell to execute commands to the sheet (except K, X, and H), and there is a function (see the manual) to extract parts (up to 8 characters at a time) of formulas in a sortable numeric form. Also, the formulas entered may have (this version only) the following constructs which will be edited into the formula as entered (so a command file can enter them): _@V1,V2 Means get the values stored in V1 and V2 and use them as column and row locations pointing at some cell in the sheet. Replace the construct with the name of that cell. _#V1 Means take the real number in cell V1 and unpack it as if it had been a packed value from a formula with 8 characters packed; then convert it back into ASCII and place in the formula in place of this construct. 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 HVKLUGPRM.FTN VAX really huge (128 by 256) version, VT100 HVKLUGPR5.FTN VAX really huge (128 by 256) version, VT52 or colorscan 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 now used for showing negative numbers and work in a sensible screen design now. Negative numbers appear in red; positive ones in yellow. UVTTV925.FTN Televideo 925 experimental version. This version has not been well tested but is intended for Televideo 925 terminals. UVTPC.FTN IBM PC color mode and probably Intecolor terminals using ANSI escape sequences. This routine generates the necessary escape sequences to use the MSDOS ANSI.SYS driver from a suitable communications program to allow an IBM PC to run PortaCalc from a Vax or PDP11, using a color display. The Intecolor escape sequences seem to be the same (they differ from the Colorscan ones), so this may allow use from an Intecolor terminal. Note wide screen display is impossible on the IBM PC and its lookalikes. 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. The normal PDP11 builds will make a version which attaches the terminal so no funny modes need be set. The RSX and VMS flavors of PortaCalc can use escape sequences and now recognize VT100 arrow keys (VT52 too) and also that PF2 means "help". Remember under VMS to copy the desired file to VKLUGPRM.FTN before compiling, unless the build file does (MOST DO!) Ignore compiler/linker errors in RSX or VMS. They are harmless warnings. It develops that a few compilers treat the INDEX errors as errors, not warnings. Inserting a statement like EXTERNAL *INDEX into offending programs will get them to compile however. F77 V4.0 is one that seems to mess this up. Note that in VMS you may want to run PortaCalc from a command file to set the terminal /NOESCAPE after PortaCalc exits. Otherwise EDT gets VERY unhappy (not to mention screwed up). Some experimenting is desirable since the simple methods I've tried preclude the spawning of subtasks from working where PortaCalc is run from a command file. It can be done, though, since it works from VPW. 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. The PortaCalc-PC version has all this, but beware of exceeding MAXFIL. You should be able to build PortaCalc with regular old F4P but you may need minor changes to some OPEN statements. Use the LBL Tools INCL and MACRO processors to handle the parameter statements and expand them inline. You'll need to edit the include files into the form MACRO needs, but it can be made to work (I've done it). Note too the CMDMUN and TTYINI routines to set up the console. The supplied versions implement case translation and enable the arrow keys. 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: (Note: This hasn't been updated for awhile.) 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 SOMAKE.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. Note that the DEFAULT format is for a REAL (not integer) number and must be appropriate. The sheet can be converted to integer format, but will start as real (floating point) numbers, the most generally useful sort. Double precision is used, so about 17 digits of precision are available. 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 is already implemented and works well. Glenn Everhart