-- file: MFInteractionImpl.mesa -- Pascal-to-Mesa translator output, translated at October 31, 1985 4:28:00 pm PST DIRECTORY PascalBasic, PascalWizardFiles, MFTypes, MFExternals, MFMath, MFSymbols, MFInput, MFFileNames, MFInteraction, MFDebug, MFInit; MFInteractionImpl: PROGRAM IMPORTS PascalBasic, PascalWizardFiles, MFTypes, MFExternals, MFMath, MFSymbols, MFInput, MFFileNames, MFDebug, MFInit EXPORTS MFInteraction = PUBLIC BEGIN OPEN PascalBasic, PascalWizardFiles, MFTypes, MFExternals, MFMath, MFSymbols, MFInput, MFFileNames, MFInteraction, MFDebug, MFInit; --:13----20: Xord: LONG POINTER TO ARRAY PascalChar OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalChar OF AsciiCode]; Xchr: LONG POINTER TO ARRAY AsciiCode OF PascalChar ← PascalStaticZone.NEW[ARRAY AsciiCode OF PascalChar]; --:20----25: NameOfFile: LONG POINTER TO PACKED ARRAY PascalInteger[1..127] OF PascalChar ← PascalStaticZone.NEW[PACKED ARRAY PascalInteger[1..127] OF PascalChar]; NameLength: PascalInteger[0..FileNameSize]; --:25----29: Buffer: LONG POINTER TO ARRAY PascalInteger[0..7500] OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalInteger[0..7500] OF AsciiCode]; First: PascalInteger[0..BufSize]; Last: PascalInteger[0..BufSize]; MaxBufStack: PascalInteger[0..BufSize]; --:29----31:-- TermIn: AlphaFile; TermOut: AlphaFile; --:31----38: StrPool: LONG POINTER TO PACKED ARRAY PoolPointer OF AsciiCode ← PascalStaticZone.NEW[PACKED ARRAY PoolPointer OF AsciiCode]; StrStart: LONG POINTER TO ARRAY StrNumber OF PoolPointer ← PascalStaticZone.NEW[ARRAY StrNumber OF PoolPointer]; PoolPtr: PoolPointer; StrPtr: StrNumber; InitPoolPtr: PoolPointer; InitStrPtr: StrNumber; MaxPoolPtr: PoolPointer; MaxStrPtr: StrNumber; --:38----42: StrRef: LONG POINTER TO ARRAY StrNumber OF PascalInteger[0..127] ← PascalStaticZone.NEW[ARRAY StrNumber OF PascalInteger[0..127]]; --:42----50:-- PoolFile: AlphaFile; --:50 --54:-- LogFile: AlphaFile; Selector: PascalInteger[0..5]; Dig: LONG POINTER TO ARRAY PascalInteger[0..22] OF PascalInteger[0..15] ← PascalStaticZone.NEW[ARRAY PascalInteger[0..22] OF PascalInteger[0..15]]; Tally: PascalInteger; TermOffset: PascalInteger[0..MaxPrintLine]; FileOffset: PascalInteger[0..MaxPrintLine]; TrickBuf: LONG POINTER TO ARRAY PascalInteger[0..64] OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalInteger[0..64] OF AsciiCode]; TrickCount: PascalInteger; FirstCount: PascalInteger; --:54----68:-- Interaction: PascalInteger[0..3]; --:68----71: DeletionsAllowed: PascalBoolean; History: PascalInteger[0..3]; ErrorCount: PascalInteger[-1..100]; --:71----74: HelpLine: LONG POINTER TO ARRAY PascalInteger[0..5] OF StrNumber ← PascalStaticZone.NEW[ARRAY PascalInteger[0..5] OF StrNumber]; HelpPtr: PascalInteger[0..6]; UseErrHelp: PascalBoolean; ErrHelp: StrNumber; --:74----91:-- Interrupt: PascalInteger; OkToInterrupt: PascalBoolean; PrintLn: PROCEDURE = BEGIN SELECT Selector FROM 3 =>BEGIN PascalWriteLn[file: @TermOut]; PascalWriteLn[file: @LogFile];TermOffset←0;FileOffset←0; END; 2 =>BEGIN PascalWriteLn[file: @LogFile];FileOffset←0; END;1 =>BEGIN PascalWriteLn[file: @TermOut]; TermOffset←0; END;0,4,5 => NULL; ENDCASE; END;--:57----58: PrintChar: PROCEDURE[S: AsciiCode] = BEGIN SELECT Selector FROM 3 =>BEGIN PascalWriteChar[file: @TermOut, item: Xchr↑[S]]; PascalWriteChar[file: @LogFile, item: Xchr↑[S]];TermOffset←TermOffset+1; FileOffset←FileOffset+1; IF TermOffset=MaxPrintLine THEN BEGIN PascalWriteLn[file: @TermOut]; TermOffset←0; END; IF FileOffset=MaxPrintLine THEN BEGIN PascalWriteLn[file: @LogFile]; FileOffset←0; END; END;2 =>BEGIN PascalWriteChar[file: @LogFile, item: Xchr↑[S]]; FileOffset←FileOffset+1;IF FileOffset=MaxPrintLine THEN PrintLn[]; END;1 =>BEGIN PascalWriteChar[file: @TermOut, item: Xchr↑[S]];TermOffset←TermOffset+1; IF TermOffset=MaxPrintLine THEN PrintLn[]; END;0 => NULL; 4 =>IF Tally<TrickCount THEN TrickBuf↑[ PascalMODPower2Mask[Tally ,63]]←S; 5 =>BEGIN IF INT[PoolPtr]<PoolSize THEN BEGIN StrPool↑[PoolPtr]←S; PoolPtr←PoolPtr+1; END; END; ENDCASE;Tally←Tally+1; END;--:58----59: Print: PROCEDURE[S: PascalInteger] = BEGIN J:PoolPointer; IF(S<0)OR (S>=StrPtr) THEN S←131;J←StrStart↑[S]; WHILE INT[J]<StrStart↑[S+1]DO BEGIN PrintChar[StrPool↑[J]];J←J+1; END ENDLOOP ; END; --:59----60:-- SlowPrint: PROCEDURE[S: PascalInteger] = BEGIN J:PoolPointer; IF(S<0)OR (S>=StrPtr) THEN S←131;J←StrStart↑[S]; WHILE INT[J]<StrStart↑[S+1]DO BEGIN Print[StrPool↑[J]];J←J+1; END ENDLOOP ; END;--:60 --62:-- PrintNl: PROCEDURE[S: StrNumber] = BEGIN IF(( INT[TermOffset]>0)AND (PascalODD[Selector]))OR (( INT[FileOffset]>0)AND ( INT[Selector]>=2)) THEN PrintLn[];Print[S]; END;--:62----63: PrintTheDigs: PROCEDURE[K: EightBits] = BEGIN WHILE INT[K]>0 DO BEGIN K←K-1; PrintChar[48+Dig↑[K]]; END ENDLOOP ; END;--:63----64:-- PrintInt: PROCEDURE[N: PascalInteger] = BEGIN K:PascalInteger[0..23];M:PascalInteger; K←0;IF N<0 THEN BEGIN PrintChar[45]; IF N>-100000000 THEN N←-N ELSE BEGIN M←-1-N;N← M /10; M←( M MOD 10)+1;K←1;IF M<10 THEN Dig↑[0]←M ELSE BEGIN Dig↑[0]←0;N←N+1; END; END; END;DO Dig↑[K]← N MOD 10;N← N /10;K←K+1; IF N=0 THEN EXIT; ENDLOOP; PrintTheDigs[K]; END;--:64----103:-- PrintScaled: PROCEDURE[S: Scaled] = BEGIN Delta:Scaled; IF S<0 THEN BEGIN PrintChar[45];S←-S; END; PrintInt[ PascalDIVPower2[S ,16]];S←10*( PascalMODPower2Mask[S ,65535])+5; IF S#5 THEN BEGIN Delta←10;PrintChar[46]; DO IF Delta>65536 THEN S←S+32768-( PascalDIVPower2[Delta ,1]); PrintChar[48+( PascalDIVPower2[S ,16])];S←10*( PascalMODPower2Mask[S ,65535]);Delta←Delta*10; IF S<=Delta THEN EXIT; ENDLOOP; END; END;--:103----104:-- PrintTwo: PROCEDURE[X,Y: Scaled] = BEGIN PrintChar[40];PrintScaled[X];PrintChar[44];PrintScaled[Y]; PrintChar[41]; END;--:104----187:-- PrintType: PROCEDURE[T: SmallNumber] = BEGIN SELECT T FROM 1 =>Print[196];2 =>Print[197];3 =>Print[198];4 =>Print[199]; 5 =>Print[200];6 =>Print[201];7 =>Print[202];8 =>Print[203];9 =>Print[204]; 10 =>Print[205];11 =>Print[206];12 =>Print[207];13 =>Print[208];14 =>Print[209]; 16 =>Print[210];17 =>Print[211];18 =>Print[212];15 =>Print[213];19 =>Print[214]; 20 =>Print[215];21 =>Print[216];22 =>Print[217];23 =>Print[218]; ENDCASE =>Print[219]; END;--:187----195:-- BeginDiagnostic: PROCEDURE = BEGIN OldSetting←Selector; IF(Internal↑[13]<=0)AND (Selector=3) THEN BEGIN Selector←Selector-1; IF History=0 THEN History←1; END; END; EndDiagnostic: PROCEDURE[BlankLine: PascalBoolean] = BEGIN PrintNl[157]; IF BlankLine THEN PrintLn[];Selector←OldSetting; END;--:195----197: PrintDiagnostic: PROCEDURE[S,T: StrNumber,Nuline: PascalBoolean] = BEGIN BeginDiagnostic[];IF Nuline THEN PrintNl[S] ELSE Print[S]; Print[137];PrintInt[Line];Print[T];PrintChar[58]; END;--:197----772: --43:-- FlushString: PROCEDURE[S: StrNumber] = BEGIN IF INT[S]<StrPtr-1 THEN StrRef↑[S]←0 ELSE DO StrPtr←StrPtr-1; IF StrRef↑[StrPtr-1]#0 THEN EXIT; ENDLOOP;PoolPtr←StrStart↑[StrPtr]; END;--:43----:73 --76:-- JumpOut: PROCEDURE = BEGIN ERROR Error9998; END;--:76----77:-- Error: PROCEDURE = BEGIN C:AsciiCode;S1, S2, S3:PascalInteger;J:PoolPointer; IF INT[History]<2 THEN History←2;PrintChar[46];ShowContext[]; {IF Interaction=3 THEN BEGIN SetNormalPriority[];--78: WHILE TRUE DO BEGIN DO {--Label22:--ClearForErrorPrompt[];BEGIN Print[135]; TermInput[]; END;IF Last=First THEN GOTO Label10;C←Buffer↑[First]; IF INT[C]>=97 THEN C←C-32;--79: SELECT C FROM 48,49,50,51,52,53,54,55,56,57 =>IF DeletionsAllowed THEN--83: BEGIN S1←CurCmd;S2←CurMod;S3←CurSym;OkToInterrupt←FALSE; IF( INT[Last]>First+1)AND ( INT[Buffer↑[First+1]]>=48)AND ( INT[Buffer↑[First+1]]<=57) THEN C← C*10+Buffer↑[First+1]-48*11 ELSE C←C-48;WHILE INT[C]>0 DO BEGIN GetNext[]; --742: IF CurCmd=39 THEN BEGIN IF INT[StrRef↑[CurMod]]<127 THEN IF INT[StrRef↑[CurMod ]]>1 THEN StrRef↑[CurMod]←StrRef↑[CurMod]-1 ELSE FlushString[CurMod] ; END--:742--;C←C-1; END ENDLOOP ;CurCmd←S1;CurMod←S2;CurSym←S3; OkToInterrupt←TRUE;BEGIN HelpPtr←2;HelpLine↑[1]←150; HelpLine↑[0]←151; END;ShowContext[]; GOTO Label22; END--:83--;68 =>BEGIN DebugHelp[]; GOTO Label22; END;69 =>IF INT[FilePtr]>0 THEN BEGIN PrintNl[136]; Print[InputStack↑[FilePtr].NameField];Print[137];PrintInt[Line]; Interaction←2;JumpOut[]; END;72 =>--84: BEGIN IF UseErrHelp THEN BEGIN--85:--J←StrStart↑[ErrHelp]; WHILE INT[J]<StrStart↑[ErrHelp+1]DO BEGIN IF StrPool↑[J]#37 THEN Print[ StrPool↑[J]] ELSE IF J+1=StrStart↑[ErrHelp+1] THEN PrintLn [] ELSE IF StrPool↑[J+1]#37 THEN PrintLn [] ELSE BEGIN J←J+1;PrintChar[37]; END; J←J+1; END--:85-- ENDLOOP ;UseErrHelp←FALSE; END ELSE BEGIN IF HelpPtr=0 THEN BEGIN HelpPtr←2;HelpLine↑[1]←152; HelpLine↑[0]←153; END;DO HelpPtr←HelpPtr-1; Print[HelpLine↑[HelpPtr]];PrintLn[]; IF HelpPtr=0 THEN EXIT; ENDLOOP; END; BEGIN HelpPtr←4;HelpLine↑[3]←154;HelpLine↑[2]←153;HelpLine↑[1]←155; HelpLine↑[0]←156; END; GOTO Label22; END--:84--;73 =>--82:--BEGIN BeginFileReading[]; IF INT[Last]>First+1 THEN BEGIN CurInput.LocField←First+1; Buffer↑[First]←32; END ELSE BEGIN BEGIN Print[149];TermInput[]; END; CurInput.LocField←First; END;First←Last+1; CurInput.LimitField←Last; GOTO Label10; END--:82--;81,82,83 =>--81: BEGIN ErrorCount←0;Interaction←0+C-81;Print[144]; SELECT C FROM 81 =>BEGIN Print[145];Selector←Selector-1; END;82 =>Print[146]; 83 =>Print[147]; ENDCASE;Print[148];PrintLn[];PascalTextBREAK[file: @TermOut]; GOTO Label10; END--:81--; 88 =>BEGIN Interaction←2;JumpOut[]; END; ENDCASE => NULL;--80:--BEGIN Print[138]; PrintNl[139];PrintNl[140];IF INT[FilePtr]>0 THEN Print[141]; IF DeletionsAllowed THEN PrintNl[142];PrintNl[143]; END--:80----:79--; EXIT; EXITS Label22 => NULL} ENDLOOP; END--:78-- ENDLOOP ; END;ErrorCount←ErrorCount+1; IF ErrorCount=100 THEN BEGIN PrintNl[134];History←3;JumpOut[]; END; --86:--IF INT[Interaction]>0 THEN Selector←Selector-1; IF UseErrHelp THEN BEGIN PrintNl[157];--85:--J←StrStart↑[ErrHelp]; WHILE INT[J]<StrStart↑[ErrHelp+1]DO BEGIN IF StrPool↑[J]#37 THEN Print[ StrPool↑[J]] ELSE IF J+1=StrStart↑[ErrHelp+1] THEN PrintLn [] ELSE IF StrPool↑[J+1]#37 THEN PrintLn [] ELSE BEGIN J←J+1;PrintChar[37]; END; J←J+1; END--:85-- ENDLOOP ; END ELSE WHILE INT[HelpPtr]>0 DO BEGIN HelpPtr←HelpPtr-1; PrintNl[HelpLine↑[HelpPtr]]; END ENDLOOP ;PrintLn[]; IF INT[Interaction]>0 THEN Selector←Selector+1;PrintLn--:86--[]; EXITS Label10 => NULL};SetBackgroundPriority[]; END;--:77----88: FatalError: PROCEDURE[S: StrNumber] = BEGIN NormalizeSelector[]; BEGIN IF Interaction=3 THEN NULL;PrintNl[133];Print[158]; END; BEGIN HelpPtr←1;HelpLine↑[0]←S; END; BEGIN IF Interaction=3 THEN Interaction←2;Error[]; IF INT[Interaction]>0 THEN DebugHelp[];History←3;JumpOut[]; END; END;--:88----89: Overflow: PROCEDURE[S: StrNumber,N: PascalInteger] = BEGIN NormalizeSelector[]; BEGIN IF Interaction=3 THEN NULL;PrintNl[133];Print[159]; END;Print[S]; PrintChar[61];PrintInt[N];PrintChar[93];BEGIN HelpPtr←2; HelpLine↑[1]←160;HelpLine↑[0]←161; END; BEGIN IF Interaction=3 THEN Interaction←2;Error[]; IF INT[Interaction]>0 THEN DebugHelp[];History←3;JumpOut[]; END; END;--:89----90: Confusion: PROCEDURE[S: StrNumber] = BEGIN NormalizeSelector[]; IF INT[History]<2 THEN BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[133]; Print[162]; END;Print[S];PrintChar[41];BEGIN HelpPtr←1; HelpLine↑[0]←163; END; END ELSE BEGIN BEGIN IF Interaction=3 THEN NULL; PrintNl[133];Print[164]; END;BEGIN HelpPtr←2;HelpLine↑[1]←165; HelpLine↑[0]←166; END; END;BEGIN IF Interaction=3 THEN Interaction←2; Error[];IF INT[Interaction]>0 THEN DebugHelp[];History←3;JumpOut[]; END; END;--:90 --:36----44:-- MakeString: PROCEDURE RETURNS[MakeStringResult: StrNumber] = BEGIN IF StrPtr=MaxStrPtr THEN BEGIN IF StrPtr=MaxStrings THEN Overflow[130,MaxStrings-InitStrPtr];MaxStrPtr←MaxStrPtr+1; END; StrRef↑[StrPtr]←1;StrPtr←StrPtr+1;StrStart↑[StrPtr]←PoolPtr; MakeStringResult←StrPtr-1; END;--:44----45:-- StrEqBuf: PROCEDURE[S: StrNumber, K: PascalInteger] RETURNS[StrEqBufResult: PascalBoolean] = BEGIN J:PoolPointer;Result:PascalBoolean; J←StrStart↑[S]; {WHILE INT[J]<StrStart↑[S+1]DO BEGIN IF StrPool↑[J]#Buffer↑[K] THEN BEGIN Result←FALSE; GOTO Label45; END;J←J+1;K←K+1; END ENDLOOP ;Result←TRUE; EXITS Label45 => NULL};StrEqBufResult←Result; END;--:45----46: StrVsStr: PROCEDURE[S,T: StrNumber] RETURNS[StrVsStrResult: PascalInteger] = BEGIN J, K:PoolPointer;Ls, Lt:PascalInteger;L:PascalInteger; Ls←(StrStart↑[S+1]-StrStart↑[S]); Lt←(StrStart↑[T+1]-StrStart↑[T]);IF Ls<=Lt THEN L←Ls ELSE L←Lt; J←StrStart↑[S];K←StrStart↑[T]; {WHILE L>0 DO BEGIN IF StrPool↑[J]#StrPool↑[K] THEN BEGIN StrVsStrResult← StrPool↑[J]-StrPool↑[K]; GOTO Label10; END;J←J+1;K←K+1;L←L-1; END ENDLOOP ; StrVsStrResult←Ls-Lt;EXITS Label10 => NULL}; END;--:46----47:-- PrintDd: PROCEDURE[N: PascalInteger] = BEGIN N← ABS[N]MOD 100; PrintChar[48+( N /10)];PrintChar[48+( N MOD 10)]; END;--:65----66: TermInput: PROCEDURE = BEGIN K:PascalInteger[0..BufSize]; PascalTextBREAK[file: @TermOut]; IF NOT InputLn[@TermIn,TRUE] THEN FatalError[132];TermOffset←0; Selector←Selector-1; IF Last#First THEN FOR i:INT IN [ INT[First ].. INT[Last-1 ]] DO K ← i; Print[Buffer↑[K]] ENDLOOP;PrintLn[]; Buffer↑[Last]←37;Selector←Selector+1; END;--:66----87: NormalizeSelector: PROCEDURE = BEGIN IF INT[JobName]>0 THEN Selector←3 ELSE Selector←1; IF JobName=0 THEN OpenLogFile[]; IF Interaction=0 THEN Selector←Selector-1; END;--:87----93: PauseForInstructions: PROCEDURE = BEGIN IF OkToInterrupt THEN BEGIN Interaction←3; IF(Selector=2)OR (Selector=0) THEN Selector←Selector+1; BEGIN IF Interaction=3 THEN NULL;PrintNl[133];Print[167]; END; BEGIN HelpPtr←3;HelpLine↑[2]←168;HelpLine↑[1]←169;HelpLine↑[0]←170; END;DeletionsAllowed←FALSE;Error[];DeletionsAllowed←TRUE;Interrupt←0; END; END;--:93----94:-- MissingErr: PROCEDURE[S: StrNumber] = BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[133];Print[171]; END;Print[S]; Print[172]; END;--:94----99:-- OpenLogFile: PROCEDURE = BEGIN OldSetting:PascalInteger[0..5];K:PascalInteger[0..BufSize]; L:PascalInteger[0..BufSize];M:PascalInteger;Months: LONG POINTER TO PACKED ARRAY PascalInteger[1..36] OF PascalChar ← PascalZone.NEW[PACKED ARRAY PascalInteger[1..36] OF PascalChar]; OldSetting←Selector;IF JobName=0 THEN JobName←616; PackJobName[617];WHILE NOT AOpenOut[@LogFile]DO--788: BEGIN IF INT[Interaction]<2 THEN BEGIN BEGIN IF Interaction=3 THEN NULL; PrintNl[133];Print[610]; END;PrintFileName[CurName,CurArea,CurExt]; Print[611];JobName←0;History←3;JumpOut[]; END; PromptFileName[619,617]; END--:788-- ENDLOOP ; LogName←AMakeNameString[@LogFile];Selector←2;--789: BEGIN PascalWriteLongString[file: @LogFile, item: "This is METAFONT 0.9999, for Cedar 6.0"]; Print[BaseIdent];Print[620];PrintInt[RoundUnscaled[Internal↑[16]]]; PrintChar[32];Months↑←['J, 'A, 'N, 'F, 'E, 'B, 'M, 'A, 'R, 'A, 'P, 'R, 'M, 'A, 'Y, 'J, 'U, 'N, 'J, 'U, 'L, 'A, 'U, 'G, 'S, 'E, 'P, 'O, 'C, 'T, 'N, 'O, 'V, 'D, 'E, 'C]; M←RoundUnscaled[Internal↑[15]]; FOR i:INT IN [ INT[3*M-2 ].. INT[3*M ]] DO K ← i; PascalWriteChar[file: @LogFile, item: Months↑[K]] ENDLOOP;PrintChar[32]; PrintInt[RoundUnscaled[Internal↑[14]]];PrintChar[32]; M←RoundUnscaled[Internal↑[17]];PrintDd[ M /60];PrintChar[58]; PrintDd[ M MOD 60]; END--:789--;InputStack↑[InputPtr]←CurInput; PrintNl[618];L← INT[InputStack↑[0].LimitField]-1; FOR i:INT IN [ INT[1 ].. INT[L ]] DO K ← i; Print[Buffer↑[K]] ENDLOOP;PrintLn[];Selector←OldSetting+2;PascalZone.FREE[@Months]; END; END.