;Edit number 323 by SST.D-BIGELOW on 29-Oct-85 ; ** Begin minor version 2 for new features: expunging directory after ; directory full error, and not allowing users to mess up a recovery. ; ;Edit number 322 by SST.D-BIGELOW on 2-Aug-85 ; ** Begin minor version 1 to coincide with new manual production. ; ;Edit number 321 by SST.D-BIGELOW on 11-Jun-85 ; Correctly handle an illegal switch on the rescanned command line. ; Fix the trailing delete problem once and for all by rewriting the ; routine to count bytes being output rather than output until a ; special character. ; ;Edit number 320 by SST.D-BIGELOW on 25-Oct-84 ; Yet another try at removing the trailing null/delete from an ; output file. ; ;Edit number 317 by SST.D-BIGELOW on 24-Sep-84 ; Fix logic that caused bug in TYPCHK routine -- COMND% was reacting ; oddly to a CALL DPROMP, for no known reason... ; ;Edit number 316 by SST.D-BIGELOW on 5-Sep-84 ; Remove trailing null from closed files caused by outputting the ; delete. ; ;Edit number 315 by SST.D-BIGELOW on 28-Mar-84 ; Add a /VT102 switch to turn on special insert and delete code in ; VT100 handling. ; ;WPSIM.MAC.4, 29-Jan-84 20:15:14, Edit by SST.P-GALVIN ; 314 Implement /Search switch to execute a search before displaying ; the first screen. See VDT for details. ; ;WPSIM.MAC.2, 10-Oct-83 12:10:03, Edit by SST.D-BIGELOW ; 313 More work on error handling in INI files; make full message appear ; for errors during /TYPE: scan. ; ;WPSIM.MAC.8, 27-Sep-83 11:18:12, Edit by SST.D-BIGELOW ; 312 Remove null at the end of a file caused by overwriting the delete ; that terminates the file string. (Edit removed) ; ;WPSIM.MAC.7, 23-Sep-83 08:27:54, Edit by SST.D-BIGELOW ; 311 Correct default setting of /AUTOSAVE and /EXPAND. They weren't ; working correctly. ; ;WPSIM.MAC.4, 13-Sep-83 09:02:54, Edit by SST.D-BIGELOW ; 310 Change output file switch parsing routine to call rfield instead of ; readfl. Errors in number parsing got us into input routine again. ; ;WPSIM.MAC.3, 12-Sep-83 10:41:21, Edit by SST.D-BIGELOW ; 307 Fix problem (again!) with recognition failing on non-WPS files. ; ;WPSIM.MAC.26, 16-Aug-83 09:58:42, Edit by SST.D-BIGELOW ; 306 Change parsing algorithms so that WPSIM rescanned command line looks ; like a regular command line, allowing switches. Make command line ; switches hold precedence over all /TYPE: switch values. ; ;WPSIM.MAC.17, 15-Aug-83 12:38:08, Edit by SST.D-BIGELOW ; 305 Change version to 3.0, and change prompt to reflect style of edit ; number 304. More work on edit 304. ; ;WPSIM.MAC.3, 12-Jul-83 11:48:40, Edit by SST.D-BIGELOW ; 304 Make WPSIM allow output specifications in place of input ones, and ; notify the user about it, and always use the suggested default when ; possible. ; ;WPSIM.MAC.2, 30-Jun-83 12:51:41, Edit by SST.D-BIGELOW ; 303 Make the output routine avoid writting out the trailing delete. ; ;WPSIM.MAC.18, 20-Jun-83 12:29:04, Edit by SST.P-GALVIN ; 302 Include a couple new variables to match those in VDT. These ; are used by the new pagination routines. Also, include switches ; for the control of this feature. ; ;WPSIM.MAC.17, 20-Jun-83 12:26:47, Edit by SST.P-GALVIN ; 301 Make the output file prompt write the full default file spec, ; fix a bug in the defaulting code. ; ;WPSIM.MAC.11, 17-Jun-83 10:42:09, Edit by SST.P-GALVIN ; 300 Set /Autosave:200 and /Expand as default switch values ; ;WPSIM.MAC.3, 16-Jun-83 14:40:31, Edit by SST.P-GALVIN ; 277 Make the output file have the input file's parts as its default, ; so a will default the output to be exactly the same as the ; input ; ;WPSIM.MAC.2, 17-Feb-83 13:39:31, Edit by SST.D-BIGELOW ; 276 Add /SHRINK:n switch to allow setting of margin adjustment value. ; ;WPSIM.MAC.2, 31-Dec-82 08:04:00, Edit by SST.D-BIGELOW ; 275 Add the /NUMBER:n switch to say start the page numbering at page n. ; ;WPSIM.MAC.2, 9-Dec-82 16:46:16, Edit by SST.P-GALVIN ; 274 Make the output switch /Controls which converts "$"'s to ; Escape's and "^"'s to control characters. ; ;WPSIM.MAC.2, 24-Nov-82 10:30:48, Edit by SST.D-BIGELOW ; 273 Make /NO FILETABS the default action, to prevent problems with output ; files. ; ;WPSIM.MAC.2, 15-Oct-82 10:24:47, Edit by SST.D-BIGELOW ; 272 Bump the minor version to account for the removal of the ^S/^Q ; commands, and the changes to search and replace. ; ;WPSIM.MAC.2, 28-Sep-82 15:14:48, Edit by SST.D-BIGELOW ; 271 Make program entry vector which includes VDT edit number in the ; version. ; ;WPSIM.MAC.2, 8-Sep-82 16:04:14, Edit by SST.D-BIGELOW ; 270 Change TVER to PRINT for version number typout. ; ;WPSIM.MAC.2, 3-Sep-82 12:39:01, Edit by SST.D-BIGELOW ; 267 Make the standard scrolling size be 8 rather than 5. ; ;WPSIM.MAC.4, 1-Sep-82 15:19:12, Edit by SST.D-BIGELOW ; 266 Make the default type of an output file be used in place of the type ; of the input file, for the /TYPE processing. This also allows the ; create command to work. ; ;WPSIM.MAC.2, 1-Sep-82 13:22:54, Edit by SST.D-BIGELOW ; 265 Don't increment HGHLIN before calling EMPTY -- VDT has been made ; smarter. ; ;WPSIM.MAC.2, 31-Aug-82 12:42:17, Edit by SST.D-BIGELOW ; 263 Add switch /SCROLL:n to set amount to scroll when moving the cursor ; up or down with arrows. ; ;WPSIM.MAC.3, 20-Aug-82 09:25:46, Edit by SST.D-BIGELOW ; 262 Make WPSIM execute the SETSN jsys to set the system name. Because ; WPSIM isn't in subsys, statistics weren't being accumulated. ; ;WPSIM.MAC.3, 14-Aug-82 14:10:32, Edit by SST.P-GALVIN ; 261 Change the version type out routine to use the TVER LUUO. ; ;WPSIM.MAC.4, 13-Aug-82 16:15:03, Edit by SST.D-BIGELOW ; 260 Implement version number typout on program startup. ; ;WPSIM.MAC.3, 9-Aug-82 10:53:20, Edit by SST.D-BIGELOW ; Implement FILTAB switch, to request tabification on output. ; ;WPSIM.MAC.2, 6-Aug-82 14:11:53, Edit by SST.D-BIGELOW ; Increase SAVBUF size to 3200 words -- calculation was inaccurate and ; VDT was overflowing the buffer. ; ;WPSIM.MAC.2, 12-Jul-82 07:51:45, Edit by SST.D-BIGELOW ; Change GETJFN call to search for an INI file on dsk: before login:. ; ;WPSIM.MAC.2, 8-Jul-82 10:29:46, Edit by SST.P-GALVIN ; Patch the TYPCHK routine to allow reparsing of the ; INI file in case of label-search errors. PBG ; ;WPSIM.MAC.2, 8-Jul-82 08:55:22, Edit by SST.D-BIGELOW ; Add a new switch for model 2 Viewpoint terminals. They tack on ; a CR after a function, which must be disregarded. ; ;WPSIM.MAC.3, 5-Jul-82 12:33:16, Edit by SST.D-BIGELOW ; Clear LINE and COL before dispatching to GETTXT routine. Paired ; with corresponding change to VDT which avoids doing same. ; ;WPSIM.MAC.3, 5-Jul-82 11:03:57, Edit by SST.P-GALVIN ; Changed the TYPCHK routine to allow more than one label ; on a line of switches. ; ;WPSIM.MAC.3, 1-Jul-82 18:00:10, Edit by SST.D-BIGELOW ; Change CMD program storage parameters to allow up to 500 words in ; a command line and 30 words in an atom. ; ;WPSIM.MAC.2, 1-Jul-82 12:20:33, Edit by SST.D-BIGELOW ; Make /EXPERT mode cancel first line of WPSIM input prompt, and ; avoid the "expanding margin" message too. ; ;WPSIM.MAC.2, 29-Jun-82 14:35:01, Edit by SST.D-BIGELOW ; Fix problem that occurred in VDT when /SETTAB:0 was specified. ; ;WPSIM.MAC.2, 24-Jun-82 10:37:59, Edit by SST.B-RAMSEY ; Fix problems with /TABS command in INI file being overwritten. ; ;WPSIM.MAC.2, 23-Jun-82 10:56:33, Edit by SST.D-BIGELOW ; Beginning of formal edit history. Install new switch /SETTABS ; to allow setting variable spaced tab stops. ; Subttl Table of contents for WPSIM ; -- Section -- -- Page -- ; ; 1. Edit history.................................................. 1 ; 2. Table of contents............................................. 2 ; 3. Program Initialization........................................ 3 ; 4. Symbols....................................................... 4 ; 5. CMD program storage........................................... 5 ; 6. Storage....................................................... 6 ; 7. CMD program definition blocks................................. 7 ; 8. Program start................................................. 10 ; 9. Tab handling.................................................. 19 ; 10. Main processing, input file specification done................ 20 ; 11. Process the output............................................ 24 ; 12. Setstg - Set up data storage.................................. 28 ; 13. Saver - Fork which keeps backup editing copies................ 29 ; ; (End of table of contents) Subttl Program Initialization Search Symbol ; Universal file sets up macro definitions Sall ; Supress macro expansion ;Version information Vmajor==3 ; Major version Vminor==2 ; Minor version Vedit==323 ; Edit number Vcust==4 ; Who last edited file ;Define title, setup version and macro psuedo-ops ;========================================================================== .TTN. WPSIM,Word Processor Simulator ;========================================================================== ;Program feature test switches .IF Omit,Macro,< Omit Memory ; No memory manipulation Omit Sorter ; No sorting Omit Comman ; No special comnd jsys calls Omit Strng. ; No special string handling > Include F..UUO ; Local uuo features ; If included, requires UUOCON.REL ;* === Documentation === ;* ;* ;* Written by Douglas Bigelow on 14-Sep-81 ;* ;* Files required: SYMBOL.UNV, MACSYM.UNV, MONSYM.UNV, MACREL.REL ;* ;* Description: WPSIM is a program which simulates a word processor. ;* For details on operation, see the file WPSIM.DOC. ;* ;Set up program entry vector Wpsvec: jrst wpsim ;start jrst wpsim ;re-enter byte(3)vcust(9)vmajor(6)vminor(18)vedit+vdtedt## Subttl Symbols Datpag==40 ;beginning of data pages Datadr==datpag*1000 ;data address Defmxl==<700-datpag>*40 ;lines available for data Maxind==^d60 ;maximum indentation Stdind==0 ;standard Maxscr==^d24 ;scroll 24 lines Minscr==1 ;not less than one Stdscr==10 ;standard Minmin==^d10 ;minimum value for minimum line break Maxmin==^d76 ;maximum Stdmin==^d62 ;standard Minmax==^d12 ;minimum value for maximum line break Maxmax==^d78 ;maximum Stdmax==^d65 ;standard Minbak==0 ;minimum value for backup maximum Maxbak==^d60 ;maximum Stdbak==^d15 ;standard Minpgs==^d25 ;minimum page size Maxpgs==^d120 ;maximum page size Stdpgs==^d52 ;standard Minlet==0 ;minimum size of letterhead Maxlet==^d60 ;maximum size Stdlet==^d0 ;standard Minshr==1 ;minimum shrink value Maxshr==^d30 ;maximum shrink value Stdshr==^d10 ;standard Minsch==^d100 ;minumum number of characters between saves Stdsch==^d200 ;standard number of characters Tabdef==^d8 ;default tab spacing Subttl CMD program storage ;Load the proper symbol file and subroutines Search CMD .Requi SYS:CMD.REL ;Symbols for buffer lengths Cmdbln==:500 ;length of command line buffer Atmbln==:100 ;length of atom buffer Cjfnln==:20 ;length of gtjfn block Cmdpln==:200 ;amount of stack we can save ;Comnd jsys storage for CMD program Cmdbuf::block cmdbln ;command buffer Cmdacs::block 20 ;saved acs from beginning of command line Atmbuf::block atmbln ;atom buffer Sbk:: block 20 ;comnd jsys state block Cjfnbk::block cjfnln ;gtjfn block for comnd jsys Repara::block 1 ;reparse address Cmdfrm::block 1 ;marks bottom of stack Cmdpdl::block cmdpln ;room to save pdl Subttl Storage ;Internal storage, used by VDT Intern Line,Col,Maxlin,Toplin,Hghlin,Buf,Maxcol,Mincol,Backup,Tabwid,Savep Intern Schar,Spare,Indent,Tjfn,Length,Width,Ijfn,Ojfn,Tiw,Ccoc,Tabs,Intblk Intern Pagsiz,Savbuf,Savnum,Lethed,Flink,Pat,Chrnum,Chrcnt,Numsch Intern Pghead,Pagnum,Repstr,Replen,Lstspc,Hyphen,Sfirst Intern Intacs,Intstk,Expert,Xpncol,Funct,Value,Prog,Cipher,Mod2,Filtab Intern Fstlin,Inplin,Outlin,Scrval,Ctrlcv,Strpag,Shrink Intern Autopg,Hardpg,Currpg,Bfrcnt,Chrptr,Jbuf,Vt102 Integer Line,Col,Toplin,Hghlin,Buf Integer Schar,Tjfn,Length,Width,Maxlin,Ijfn,Ojfn,Savep Integer Chrnum,Chrcnt,Savjfn,Savhan Integer Pagnum,Replen,Lstspc,Outflg,Sfirst Integer Value,Typlab,Typrem,Typred,Savtab Integer Fstlin,Inplin,Outlin Integer Hardpg,Currpg,Bfrcnt,Chrptr Integer Outbyt ;Special storage not cleared on startup Savnum: block 1 ;Q-register line counter Savbuf: block 3200 ;Q-register storage for 100(10 lines Pdl: block stksiz ;stack pointer ;Beginning of storage cleared on startup ZBEG==. Dojfn: block 1 Tiw: block 2 Ccoc: block 2 Tabs: block 3 Intblk: block 3 Intacs: block 20 Pghead: block 20 Autos: block 30 Intstk: block 50 Jbuf: block 2000 ;Justification buffer Funct: block 660 Pat: block 121 ;Do not alter order of pat to flink Repstr: block 21 Flink: block 121 Spare: block 600 Savstk: block stksiz ;Beginning of switch storage Strtsw: ;Start of switch locations Numsch: block 1 Backup: block 1 Cipher: block 1 Ctrlcv: block 1 Xpncol: block 1 Expert: block 1 Filtab: block 1 Indent: block 1 Lethed: block 1 Maxcol: block 1 Mincol: block 1 Mod2: block 1 Hyphen: block 1 Strpag: block 1 Pagsiz: block 1 Autopg: block 1 Prog: block 1 Recovr: block 1 Scrval: block 1 Shrink: block 1 Tabwid: block 1 VT102: block 1 ;Storage for duplicate values Extra: offset==:extra-strtsw ;offset between block offset+1 ;storage ;Now put the storage here so the inpure data is contiguous/contained within ;page zero. Xlist ;but don't show the expansion Var List ;restore normal mode after VAR ZEND==.-1 Subttl CMD program definition blocks Fspec: flddb. (.cmfil,cm%sdh,,) Cspec: flddb. (.cmcfm,cm%sdh,,,,sspec) ;CR or switch C3spec: flddb. (.cmcfm,,,,,s2spec) ;CR or output switch C4spec: flddb. (.cmcfm) ;CR only C5spec: flddb. (.cmcfm,cm%sdh,,,,cmspec) Cmspec: flddb. (.cmcma,,,,,sspec) ;comma Tspec: flddb. (.cmnum,cm%sdh,12,) ;tab settings Sspec: flddb. (.cmswi,,swttab) ;Switch S2spec: flddb. (.cmswi,,swttb2) ;output switch table Nspec: flddb. (.cmnum,cm%sdh,12,) ;Switch value Fnspec: flddb. (.cmkey,,funtab,) ;which function Qspec: flddb. (.cmqst,cm%sdh,,) ;function Kspec: flddb. (.cmkey,,restab) ;keyword table Nospec: flddb. (.cmkey,,notab,) ;no table Typspc: flddb. (.cmfld,cm%sdh,,) ;label to find Grbspc: flddb. (.cmtxt) ;eat till end of line Comspc: flddb. (.cmcma) ;read a coma Ynspec: flddb. (.cmkey,cm%sdh,yntab,) ;yes or no Jnkspc: fldbk. (.cmfld,,,,,[ brmsk. (fldb0.,fldb1.,fldb2.,fldb3.,<,>,)]) ;read text & comas ;Switch table F%sec==cm%fw!cm%inv ;secrecy flags F%nvx==1b8 ;no value test flag F%spx==1b9 ;special handling required F%spc==cm%fw!f%spx ;special handling F%nov==cm%fw!f%nvx ;no value Define t(swt,loc,flgs),< ifb , ifnb ,> ;COMND tables Swttab: xwd swtlen,swtlen ;length t Autosave:,numsch ;autosave character count t Backup:,backup ;backup maximum t Cipher:,cipher ;cipher code t Controls,ctrlcv,f%sec!f%nov ;convert control characters t Expand,xpncol,f%nov ;expansion of margins allowed t Expert,expert,f%nov ;expert mode t Filetab,filtab,f%nov ;file tabs for output t Function:,wp.fun,f%spc ;function spec t Indent:,indent ;indention t Letterhead:,lethed ;size of letterhead t Maximum:,maxcol ;maximum column t Minimum:,mincol,f%sec ;minimum column (supressed on list) t Model2,mod2,f%nov ;model 2 viewpoint in use t No,wp.nos,f%spc ;no keyword t Nohyphen,hyphen,f%nov ;no hyphen continuation t Number:,strpag,f%sec ;starting page number t Pagesize:,pagsiz ;page size t Paginate,Autopg,f%nov ;auto paging t Program,prog,f%nov ;writing program instead of text t Recover,recovr,f%nov ;recovering from autosave file t Scroll:,scrval ;scrolling amount t Search,sfirst,f%nov ;enter with search mode t Settabs:,wp.tab,f%spc ;tab settings t Shrink:,shrink ;margin shrink value t Tabs:,tabwid ;tab settings t Type:,wp.typ,f%spc ;type of file to be edited t VT102,vt102,f%nov ;VT102 code swtlen==.-swttab-1 ;Table of entries to follow keyword "no" Notab: xwd nolen,nolen t Controls,ctrlcv,f%sec ;no controls t Expand,xpncol ;no expand t Expert,expert ;no expert t Filetab,filtab ;no filetabs t Model2,mod2 ;no model2 t Paginate,autopg ;no paginate t Program,prog ;no program t Recover,recovr ;no recover t VT102,vt102 ;no VT102 nolen==.-notab-1 ;Table of output switches Swttb2: xwd swtln2,swtln2 t Cipher:,cipher ;cipher the output text t Controls,ctrlcv ;convert "^" to control's t Filetab,filtab ;convert spaces to tabs t Nocontrols,-3 ;don't convert controls t Nofiletab,-2 ;don't convert spaces to tabs t Number:,strpag ;starting page number swtln2==.-swttb2-1 ;Yes or no decision Yntab: xwd 2,2 ;two choices t No,0 ;don't do it t Yes,1 ;go for it! ;Special function block for output file Ofun: fld(.cmfil,cm%fnc) ;output file spec 0 ;data for function 0 ;help text 0 ;default text ;RSCAN entry keyword block Restab: xwd reslen,reslen t CREATE,-1 ;create command t EDIT,1 ;edit command t START,0 ;Start same as wpsim t WPSIM,0 ;WPSIM command reslen==.-restab-1 ;Table of function switches Funtab: xwd funlen,funlen t 1,1 ;function 1 t 2,2 t 3,3 t 4,4 t 5,5 t 6,6 t A,7 t B,10 t C,11 t D,12 t E,13 t F,14 t G,15 t H,16 t I,17 t J,20 funlen==.-funtab-1 Subttl Program start ;Initialize the terminal, initialize the storage, ask for a startup file name. Wpsim: setzm savnum ;clear Q-registers on startup ;Entry point from continue command Wps.x: reset% stack pdl ;storage call cmdini ;initialize cmd routine call setstg ;set up the storage move a,[sixbit .WPSIM.] ;set system and private names move b,a setsn% jfcl ;First look for a WPSIM.INI file movei p2,1 seto p1, ;make sure p1 is non-zero getjfn asc ;get a jfn from dsk:, then login: jumpe a,noini ;no file movem a,p1 ;save the jfn movem a,typrem ;save it for later too movx b,fld(7,of%bsz)!of%rd openf% ;open the file ssterr (,JUMP,noini) hrl a,p1 ;get the jfn hrri a,.nulio ;output from editing movem a,sbk+1 ;store as new jfn pair setz a, ;no prompt call dpromp jrst wps.b ;now go get any switches ;Here if there was no ini file, or after it was processed Clsini: setzm typred ;no type specified any more setzm typrem ;let type know we had an error call cmdini ;re-initialize cmd buffers skipg a,p1 ;get the jfn jrst noini ;invalid jfn closf% ;close the file jfcl Noini: setz p1, ;done with ini file move a,tabwid ;get tab setting movem a,savtab ;and save it setzm cjfnbk+.gjdev ;zero any old default file part pointers setzm cjfnbk+.gjdir setzm cjfnbk+.gjnam setzm cjfnbk+.gjext move a,[.priin,,.priou] ;regular jfns movem a,sbk+1 ;set them up setz a, ;no prompt call dpromp ;set up the line movei a,.rsini ;rescan function rscan% ;do it jrst noi.b ;can't movei a,.rscnt ;count chars left rscan% ;get them setz a, ;no characters jumpe a,noi.b ;nothing left to read movei a,kspec ;keyword table call rflde ;read it jrst noi.a ;doesn't match hrre t1,(b) ;get function code noise ;optional noise ;Check for WPSIM keyword seto p2, ;flag that we're rescanning jumpe t1,noi.c ;wpsim command is like regular line jumpl t1,creat ;create if -1 move a,[-1,,[asciz .WPS.]] movem a,cjfnbk+.gjext ;preferred extension movx a,gj%old ;old file movem a,cjfnbk ;set flag Wpswps: movei a,[flddb. .cmfil] ;regular file call rflde ;read it jrst [jumpe t1,noi.a ;;exit if second pass setz t1, ;;clear counter for second pass setzm cjfnbk ;;try any file now jrst wpswps] ;;and try second time move t2,b ;store jfn move a,b ;copy it movx b,of%rd ;read access openf% ;try to read it erjmp [movem t2,dojfn ;;default output jfn jrst endlin] ;;finish up the line txo a,co%nrj ;don't release jfn closf% ;close file jfcl ;ignore errors Wpsed1: movem t2,ijfn ;save the input jfn move b,t2 ;copy the jfn for jfns hrroi a,typlab ;point to the type storage area movx c,js%typ ;return the file type jfns% ;of the input file setzm typred ;default type is being used noise ;the optional noise ;Now see if there is an output file Creat: move a,[-1,,[asciz .WPS.]] movem a,cjfnbk+.gjext ;preferred extension movx a,gj%fou ;output movem a,cjfnbk ;set as jfn flag movei a,[flddb. .cmfil,,,,,c4spec] call rflde ;get output spec jrst noi.a ;can't hrrz a,c ;get table used cain a,c4spec ;confirm? jrst wp.cr1 ;yes, done movem b,ojfn ;save jfn Endlin: movei a,c4spec ;confirm call rflde ;get it jrst noi.a ;can't skipn b,ojfn ;output jfn exist? move b,dojfn ;get default output jfn hrroi a,typlab ;point to the type storage area movx c,js%typ ;return the file type jfns% ;of the input file setzm typred ;default type is being used jrst wp.cr1 ;done ;Here to swallow up the rest of the defective command line Noi.a: movei a,.rscnt ;count of characters remaining rscan% ;read them erjmp noi.b ;can't jumpe a,noi.b ;if none left, don't read them in movei a,.priin ;input device setz b, ;to nowhere movei c,300 ;max chars movei d,12 ;end on a line feed sin% ;read in the line ;Here to read a command line starting with a file Noi.b: setz p2, ;now in interactive mode call prmpt ;initialize the prompt hrroi a,[asciz .>>.] ;set up the prompt call dpromp Noi.c: setzm tabwid ;no tabs set yet setzm ojfn ;clear output jfn setzm dojfn ;and default output jfn setzm ijfn ;and clear input file jfn setzm cjfnbk+.gjext ;no preferred extension yet move a,[.priin,,.priou] ;I/O from/to terminal now movem a,sbk+1 ;let COMND know it movx a,gj%old ;old file movem a,cjfnbk ;set flag seto t1, ;set first time flag Wps.a: movei a,fspec ;filespec call rflde ;read it ifnsk. setzm cjfnbk ;any file type now move a,[-1,,[asciz .WPS.]] movem a,cjfnbk+.gjext ;preferred extension tdze t1,t1 ;are we on the first pass? jrst wps.a ;no, try again jumpn p2,noi.b ;on rescan line, now talk to user jrst errchk ;already talking to user, type error msg endif. move t2,b ;store jfn move a,b ;copy it movx b,of%rd ;read access openf% ;try to read it erjmp [movem t2,dojfn ;;default output jfn jrst wps.a1] ;;now get switches txo a,co%nrj ;don't release jfn closf% ;close file jfcl ;ignore errors movem t2,ijfn ;store input jfn ;Now set the proper file type switches Wps.a1: move b,t2 ;copy jfn hrroi a,typlab ;label type movx c,js%typ ;type only jfns% ;get info setzm typred ;default type being used ;Here to parse switches on iterations after first Wps.b: movei a,cspec ;switch or cr call readfl ;read the field, correctly hrrz a,c ;get table cain a,sspec ;switch? jrst wp.swi ;yes cain a,cspec ;? jrst wp.crf ;yes jumpe p1,cmderr ;command error if interactive jrst inierr ;no, it's an ini file error ;Process a switch Wp.swi: hrrz t1,(b) ;get the switch address movei a,nspec ;parse a number next hlrz t2,(b) ;get the flag word move t2,(t2) txne t2,77b6 ;are bits 0-6 clear? jrst wp.sw1 ;no, so no switches in place txne t2,f%spx ;special handling? jrst (t1) ;yes, dispatch to proper routine txnn t2,f%nvx ;yes, is novalue switch set? Wp.sw1: call readfl ;no, read the field Wp.sw2: movem b,(t1) ;store the value skipg p2 ;on interactive or rescan pass? movem b,offset(t1) ;yes, copy the value jrst wps.b ;get the next ;Here for keyword NO Wp.nos: movei a,nospec ;get pointer to no table call readfl ;read the no keyword hrrz t1,(b) ;get the address setzm (t1) ;clear the flag skipg p2 ;on interactive or rescan pass? setzm offset(t1) ;yes, also set copy word jrst wps.b ;do next command ;Here are the /type:label routines ;Here to parse a type of file: Wp.typ: movei a,typspc ;trying to read a file type call readfl ;read the type setzm typlab ;zero our storage move a,[point 7,atmbuf] ;point to the type move b,[point 7,typlab] ;and the storage for it movei c,47 ;move 47 characters setz d, ;or up to a null sin% ;from the atom buffer into our storage skipn typlab ;did we read a type? pbgerr setom typred ;remember that the user specified the type jrst wps.b ;do the next command ;Here to find the type in the INI file, if appropriate: Typchk: skipn t1,typlab ;do we have a type to search for? ret ;no, nothing to do then skipn typrem ;do we have a JFN on the INI file? ret ;no, must have been an error, just return pop p,a ;clean the stack hrl a,typrem ;redirect input to the INI file hrri a,.nulio ;output nowhere movem a,sbk+1 ;let COMND know it ;Loop to find the correct label in the INI file: Typc.a: movei a,typspc ;try to find the type in the INI file call rflde ;by reading the INI file line by line ifnsk. ;here for error move a,[.priin,,.priou] ;redirect I/O movem a,sbk+1 ;and let COMND know skipn typred ;was this specified in a type switch? ifskp. ;,yes, here if a type was specified setzm typred ;clear our type-read flag setzm typlab ;don't come back here type <% No such type found in your WPSIM.INI file> endif. ;proceed jrst wp.cr2 ;no, just continue endif. ;end of error clause move a,[point 7,atmbuf] ;point to the string just read move b,[point 7,typlab] ;and the test string stcmp% ;compare them skipe a ;are they the same? ifskp. ;yes setzm typlab ;don't come back here movei a,jnkspc ;clear the buffer of any extraneous labels call rfield ;so that only switches are left on the line jrst wps.b ;go read the switches endif. ;end of yes clause ;Here if the label just read didn't match the one we're looking for: movei a,comspc ;now see if there is another label on the line call rflde ;by looking for a coma skipa ;didn't find a coma: no other label here jrst typc.a ;found one, read the label movei a,grbspc ;no, read the rest of the current line call cfield ;because it is garbage jrst typc.a ;and look at the next line ;Here if a function to parse Wp.fun: movei a,fnspec ;function code next call readfl ;read the function number hrrz t1,(b) ;get function offset imuli t1,30 ;thirty words per function movei a,qspec ;quoted string call readfl ;read to the quotes hrroi a,atmbuf ;point to string hrroi b,funct(t1) ;point to destination movei c,^D119 ;max number of chars setz d, ;end on a null sin% ;transfer it dpb d,b ;end with a null jrst wps.b ;get next switch ;Here to parse input fields and allow for errors in ini file Readfl: call rflde ;read, allow error return caia ;error, skip ret ;return pop p,a ;otherwise pop off the return Errchk: jumpn p2,inierr ;if not interactive, type special message jumpe p1,cmderr ;if interactive, use standard msg ;Here to print out fancy error messages for INI file handling Inierr: skipl p2 ;negative means command, skip print asc<%P Illegal switch in WPSIM.INI file: > skipg p2 ;positive means ini file, skip print asc<%P Illegal switch in command line: > movei a,.priou ;output move b,sbk+.cmptr ;pointer to text buffer movei c,50 ;length to output setz d, ;or stop on a null sout% ;type it type <> ;end with cr jumpl p2,noi.a ;if command line, go there jrst clsini ;close the ini file. Subttl Tab handling ;Here to set variable spaced tabs. Format is /SETTABS:5,10,20,45... Wp.tab: movx a,1b0 ;get a word with bit 0 set movem a,tabs ;always a tab at position zero setzm tabs+1 ;clear all words setzm tabs+2 setom tabwid ;say that we've set the tabs already jrst sett.b ;get first tab value Sett.a: movei a,c5spec ;tab specification call readfl ;get the proper field hrrz a,c ;get table used cain a,c5spec ;confirm? jrst wp.crf ;yes cain a,sspec ;switch? jrst wp.swi ;yes ;Here to read in the tab setting value Sett.b: movei a,tspec ;get value call readfl ;read it sojl b,sett.a ;too low, try again caile b,^d79 ;test too high jrst sett.a ;too high adjbp b,[point 1,tabs] ;get pointer to proper bit seto a, ;set to ones idpb a,b ;set the stop jrst sett.a ;and do the next Subttl Main processing, input file specification done ;Check the limits specified for switches and default them if out of bounds. Wp.crf: jumpn p1,noini ;if P1 nonzero, we've just done the INI file Wp.cr1: movei p2,1 ;on type checking pass call typchk ;check if we need to process a type switch ;Copy the command line switches over the typchk values Wp.cr2: move t1,[iowd offset,strtsw+1] skipl a,offset(t1) ;got a command line value? movem a,(t1) ;yes, reset over original aobjn t1,.-2 ;do for all switches hrrz a,typrem ;get the INI file JFN closf% ;close it jfcl ;ignoring errors setom currpg ;no page breaks on current screen move a,[.priin,,.priou] ;redirect I/O to the TTY movem a,sbk+1 ;and let COMND know about it move a,savtab ;none, get ini file setting skipn tabwid ;get width movem a,tabwid ;reset the setting skipl tabwid ;tabs need setting? call deftab ;yes, do it skipl a,indent ;get indention caile a,maxind ;check against maximum movei a,stdind ;load the standard movem a,indent ;save it skipn a,maxcol ;maximum column movei a,stdmax ;get standard cail a,minmax ;too small? caile a,maxmax ;or too large? movei a,maxmax ;set the standard movem a,maxcol ;save it camn a,mincol ;same as mincol? jrst .+3 ;yes, don't change minimum subi a,4 ;offset to minimum movem a,mincol ;set minimum too caml a,backup ;larger than backup? move a,backup ;no, get backup maximum cail a,minbak ;too small? caile a,maxbak ;or too large? movei a,stdbak ;load the standard movem a,backup ;save it move a,pagsiz ;get page size cail a,minpgs ;too small? caile a,maxpgs ;or too large? movei a,stdpgs ;load the standard movem a,pagsiz ;and set it up movei a,defmxl ;get default maximum lines movem a,maxlin ;store it ;Continued on next page ;Continued from previous page move a,lethed ;get letterhead size cail a,minlet ;too small? caile a,maxlet ;or too large? movei a,stdlet ;yes, set the default movem a,lethed ;set it up move b,shrink ;get shrink size movm a,shrink ;get shrink size magnitude cail a,minshr ;too small? caile a,maxshr ;or too large? movei b,stdshr ;yes, set the default movem b,shrink ;set it up skipn a,scrval ;get number of lines to scroll movei a,stdscr ;none set, use standard caig a,minscr ;too small? movei a,minscr ;yes, set minimum caile a,maxscr ;or too large? movei a,maxscr ;yes, set max movem a,scrval ;set it skipn a,numsch ;number of characters between saves ifskp. ;non-zero, test it caig a,minsch ;too small? movei a,stdsch ;yes, reset the standard movem a,numsch ;set it up movem a,chrcnt ;set up the character count endif. skipn prog ;programming? ifskp. ;yes movei a,maxmax ;get max column movem a,maxcol ;store it movem a,mincol ;also minimum setzm backup ;clear backup setom hyphen ;no hyphenation endif. ;Check to make sure we're not editing a backup file skipn b,ijfn ;input file? jrst wp.cf0 ;nope hrroi a,autos ;string here movx c,js%nam!js%typ!js%paf ;name and type jfns% ;get info hrroi a,autos hrroi b,asc stcmp% ;compare them jumpn a,wp.cf0 ;not the same type < % You're not supposed to be editing this file, so I'll assume that you're trying to recover some lost work. Next time, please use /RECOVER instead.> movei a,^D7000 ;7 second wait disms% move a,ijfn ;get input rljfn% ;yes, release it erjmp .+1 ;forget it setzm ijfn ;no input file movx a,gj%sht!gj%fou ;new generation hrroi b,asc gtjfn% ;get a jfn dblerr (,EXIT) movem a,dojfn ;save it as default setom recovr ;turn on recovery ;Check to see if we are in recovery code Wp.cf0: skipn recovr ;recovery code? jrst wp.cf1 ;nope skipn a,ijfn ;input file? ifskp. ;yup, must be an output file instead hrroi a,autos ;where to put it movx c,js%dev!js%dir!js%nam!js%typ!js%paf jfns% setz a, ;no input file soon exch a,ijfn ;get the jfn rljfn% jfcl ;can't movx a,gj%sht!gj%fou ;new file hrroi b,autos ;name to use gtjfn% ;get it setz a, ;can't movem a,dojfn ;default output endif. getjfn 2,asc ;get a jfn on an output file jumpe a,[error(,EXIT)] move p1,a ;store the jfn movx b,of%rd ;read 36 bit bytes openf% ;open it ssterr (,EXIT) bpm36 b,datadr ;36 bit pointer to data section movni c,defmxl*20 ;get number of words allowed sin% ;read in the string erjmp .+1 ;always expect an error hrrz t1,b ;get memory address of byte pointer subi t1,datadr ;get offset idivi t1,20 ;get the line number aoj t1, ;bump it movem t1,hghlin ;store highest line move a,p1 ;get jfn back closf% ;close the file jfcl ;ignore errors ;Here we set up the saver fork for asyncronous file saving Wp.cf1: skipn numsch ;are we in autosave mode? jrst wp.cf3 ;no getjfn 4,asc ;find an output file jumpe a,[prgerr(,JUMP,wp.cf2)] movem a,savjfn ;save the jfn movei a,saver ;address of saver routine txo a,cr%map!cr%cap!cr%st ;start it up with same pages cfork% ;create a fork ssterr (,JUMP,wp.cf2) movem a,savhan ;save the handle jrst wp.cf3 ;skip over the zeroing ;Here if we had a problem initiating Wp.cf2: setzm numsch ;number of characters set to zero ;If we have an input file, load it into memory Wp.cf3: call initrm## ;initialize the terminal movei a,datadr ;store location of data movem a,buf ;in buffer address skipn a,ijfn ;get jfn jrst wp.cf4 ;wasn't one movx b,fld(7,of%bsz)!of%rd skipe cipher ;are we ciphering? movx b,of%rd ;yes, so open in 36-bit mode openf% ;open the file ssterr (,EXIT) skipe xpncol ;expanding columns? setom xpncol ;yes, set to minus one as flag call fill## ;there was one jrst [call restrm ;failure, restore mode jrst wp.o2] ;and exit from program setzm cipher ;clear the cipher word skipg xpncol ;did we expand columns? jrst wp.cf4 ;nope skipe expert ;expert mode? jrst wp.c3a ;yes, no message typncr <% Expanding right margin to > numout xpncol ;type number type ;end the line movei a,^d1500 ;wait time disms% ;allow message to be read Wp.c3a: move a,xpncol ;get new column movem a,maxcol ;set it jrst wp.cf5 ;jump further on ;Tell user about a default output file being created Wp.cf4: skipn b,dojfn ;default jfn available? jrst wp.cf5 ;nope typncr <% Creating new file > movei a,.priou ;output setz c, ;regular form jfns% ;type it out type ;end with cr movei a,^d1500 ;1.5 seconds disms% ;wait for it to be read ;Here when we're not concerned about margins ;Call the routine which does the work Wp.cf5: setzm line ;clear line and col setzm col call gettxt## ;get the text prgerr (,CONT) ;unlikely error ;Reset the terminal and translate the file call restrm## ;original state Subttl Process the output ;Load an output specification and send the data. Default the output ;file to the next generation of the input file, if there was one. Wp.out: setzm ofun+3 ;no default at present movx t1,cm%dpp ;default pointer supplied andcam t1,ofun ;start with it turned off movx a,gj%fou ;output file movem a,cjfnbk ;store flag move a,[-1,,[asciz .WPS.]] movem a,cjfnbk+.gjext ;preferred extension skipn b,dojfn ;check for default move b,ijfn ;if not use input jumpe b,wp.o0 ;nothing specified movem b,dojfn ;set default setzm ofun+3 ;no default specified here setz t1, ;create a null byte hrroi a,spare ;point to the spare buffer movem a,cjfnbk+.gjdev ;that's the start of the default list move b,dojfn ;get the input JFN movx c,js%dev ;the device it was on jfns% ;write it to the buffer, as default idpb t1,a ;write a null movem a,cjfnbk+.gjdir ;store the new pointer to the default directory movx c,js%dir ;the directory name jfns% ;write it to spare idpb t1,a ;write out a null movem a,cjfnbk+.gjnam ;store the pointer as one for file name movx c,js%nam ;the file's name jfns% ;write it to space too idpb t1,a ;write a null movem a,cjfnbk+.gjext ;store the pointer for the extension movx c,js%typ ;the file type jfns% ;return it to spare movx a,co%nrj ;keep the JFN hrr a,dojfn ;get input JFN skipe ijfn ;skip if there is none closf% ;close it jfcl ;ignore error there Wp.o0: skipe ojfn ;is there a jfn? jrst wp.o1b ;yes ;Get a jfn on the output file Wp.o1: skipn b,dojfn ;default output file jrst wp.o1z ;none print b,asc<%C(%J)> ;type file info Wp.o1z: prompt movei a,ofun ;output file function block call rfield ;get and confirm jfn movem b,ojfn ;save it ;Now process any switches Wp.o1a: movei a,c3spec ;CR or switch call rfield ;get field hrrz a,c ;get table used cain a,c3spec ;a cr? jrst wp.o1b ;yes hrrz b,(b) ;get the address caie b,-2 ;is is the nofiletab switch? ifskp. ;yes setzm filtab ;clear filetab flag jrst wp.o1a ;and continue endif. caie b,-3 ;is is the nocontrols switch? ifskp. ;yes setzm ctrlcv ;clear controls flag jrst wp.o1a ;and continue endif. caie b,strpag ;is it the number flag? ifskp. ;yes movei a,nspec ;get a number call rfield ;read the field movem b,strpag ;and store it jrst wp.o1a ;and continue endif. caie b,cipher ;is it the cipher flag? ifskp. ;yes movei a,nspec ;get a number call rfield ;read the field movem b,cipher ;and store it else. setom (b) ;set switch value endif. jrst wp.o1a ;and loop for all switches ;Here when the line is confirmed Wp.o1b: move a,ojfn ;get it movx b,fld(7,of%bsz)!of%wr ;write access skipe cipher ;ciphering? movx b,of%wr ;yes, use 36-bit mode openf% ;open the file erjmp wp.o3 ;can't skipe outflg ;have we converted before? jrst wp.o1c ;yes, never do it twice! movei a,datadr-1000 ;address for output string call unfill## ;translate the buffer to text movem d,outbyt ;save output byte pointer setom outflg ;set the outflg switch ;Jump here if we've called the UNFILL routine already Wp.o1c: move a,ojfn ;get jfn again bpm36 b,datadr-1000 ;the string address movn c,hghlin ;get number of lines soj c, ;bump the count to account for line 0 imuli c,20 ;convert to number of words skipe cipher ;but check for ciphering ifskp. ;we aren't ciphering hrros b ;clear the byte pointer hllz t1,outbyt ;get byte pointer from unfill hrrz c,outbyt ;get word pointed at subi c,datadr-1000 ;number of words converted imuli c,5 ;characters per word movns c ;negate hrlzi t2,-6 ;aobjn pointer came t1,ptrtab##(t2) ;check pointer aobjn t2,.-1 ;loop until found subi c,-1(t2) ;add characters in last word endif. sout% ;do it erjmp wp.o4 ;can't output Wp.o1d: move a,ojfn ;restore jfn txo a,co%nrj ;don't release jfn closf% ;close the file erjmp wp.o5 ;can't seto a, ;all JFN's rljfn% ;release them jfcl ;ignore errors ;Cancel the saver fork activities skipn numsch ;are we saving? jrst wp.o2 ;nope move a,savhan ;get fork handle kfork% ;kill it move a,savjfn ;get output file rljfn% ;release the jfn jfcl ;ignore errors Wp.o2: haltf% ;done jrst wps.x ;if continued ;Type out the reason behind an open or close failure Wp.o3: move a,ojfn ;get jfn print a,asc<%QUnable to open file %J -- %E%C> rljfn% ;release it erjmp .+1 ;can't, ignore jrst wp.o6 Wp.o4: move a,ojfn ;get jfn print a,asc<%QUnable to write to file %J -- %E%C> txo a,cz%abt ;abort close closf% ;close the file jfcl ;ignore errors jrst wp.o6 ;and try again Wp.o5: move a,ojfn ;get jfn print a,asc<%QUnable to close file %J -- %E%C> txo a,cz%abt ;abort close closf% ;close the file jfcl ;ignore errors jrst wp.o1 ;and try again Wp.o6: skipl outflg ;been here? jrst wp.o1 ;yup, don't repeat messages hrrzs outflg ;make -1 become positive movei a,.fhslf ;this fork geter% hrrz a,b ;get last error code caie a,iox34 ;disk full? ifskp. ;yes type <% The entire disk is full. There is nothing you can do but keep trying occasionally and wait for space to appear.> jrst wp.o1 ;done endif. caie a,iox11 ;quota exceeded? jrst wp.o1 ;nope, don't tamper gjinf% ;get connected dir movem b,t2 ;save it for later print b,asc<%C You are connected to %U.%C> prompt < Shall I expunge deleted files in that area? > movei a,ynspec ;yes or no call cfield ;get answer hrrz t1,(b) ;get value jumpe t1,wp.o1 ;no, so don't expunge seto a, ;connected directory gtdal% ;get space used movem b,t1 ;save it move b,t2 ;get connected dir setz a, ;no flags deldf% ;expunge erjmp .+1 ;ignore errors seto a, ;connected directory again gtdal% ;now get space used sub t1,b ;get difference print t1,asc< OK, %N pages freed.%C> jrst wp.o1 ;try again Subttl Setstg - Set up data storage ;Zero all locations here that get used later. Also zero any pages used for ;file. Setstg: hrli a,zbeg ;get beginning of storage hrri a,zbeg+1 ;set up blt pointer setzm zbeg ;clear a word blt a,zend ;clear the block ;Now set the extra table to zeros move t1,[iowd offset,extra+1] setom (t1) ;set storage table to -1 aobjn t1,.-1 ;until done setom indent ;make sure some special words get set setom backup setom lethed setom xpncol ;default expand on setom numsch ;default autosave on movei a,datpag ;get starting page of data area ;Make sure the data area has no left over data from previous run. Set.a: hrli a,.fhslf ;our fork rpacs% ;check page access txnn b,pa%pex ;page exists? ret ;no, done hrrz t1,a ;get the page in question lsh t1,11 ;turn into a word address movei t2,1(t1) ;get addr+1 hrl t2,t1 ;make a blt pointer setzm (t1) ;clear the first word blt t2,777(t1) ;and propagate it aoja a,set.a ;loop until we find the last page ;Deftab -- set up the default tabs according to the contents of TABWID. Deftab: skipn a,tabwid ;anything set? movei a,tabdef ;nope, use default setzm tabs ;clear all existing tabs setzm tabs+1 setzm tabs+2 setz t1, ;start at zero seto t3, ;deposit from here jrst stt.b ;start by setting position zero Stt.a: add t1,a ;get next stop location caile t1,^d79 ;too far? ret ;yes, done Stt.b: move t2,t1 ;copy count adjbp t2,[point 1,tabs] ;adjust pointer idpb t3,t2 ;store a tab stop jrst stt.a ;do the next Subttl Saver - Fork which keeps backup editing copies ;This fork saves the state of the file every NUMSCH characters or once a ;minute at most. Saver: reset% stack savstk ;set up a private stack Sav.a: skipg chrcnt ;ready for action yet? jrst sav.b ;yes movei a,^d60000 ;no, load a minute of time disms% ;and sleep jrst sav.a ;try again ;Here when we're ready to save Sav.b: move a,savjfn ;get the jfn movx b,of%wr ;write 36-bit bytes openf% ;open the file erjmp nosave ;can't movn c,hghlin ;get highest line soj c, ;bump the count imuli c,20 ;convert to words bpm36 b,datadr ;point to beginning of data page sout% ;send the data move a,savjfn ;get the jfn txo a,co%nrj ;never release it closf% ;close the file erjmp nosave ;if we can't move a,numsch ;get number of chars between saves movem a,chrcnt ;reset the character count jrst sav.a ;and loop ;Here when we've found a problem Nosave: bpl a,< %% Error in AUTOSAVE process -- unable to backup current work. %% Please type ^L to clear this message off the screen. %% (No response to this message is required.) > psout% ;type the message haltf% ;and die ;Prompting routine Prmpt: print asc ;start the version hrroi a,[asciz . -- Please enter name of file to be edited or created:.] skipn expert ;are we experts? psout% ;no, type prompt type ;end with a cr ret ;return ;end of program end <3,,wpsvec>