-- file: TFtoPLMiscImpl.mesa
-- Pascal-to-Mesa translator output, translated at September 23, 1986 1:04:35 pm PDT


DIRECTORY
  PascalBasic,
  PascalWizardFiles,
  TFtoPLPrivate,
  TFtoPLExternals,
  TFtoPLMain;

TFtoPLMiscImpl: PROGRAM IMPORTS PascalBasic, PascalWizardFiles, TFtoPLExternals, TFtoPLMain EXPORTS TFtoPLPrivate = PUBLIC
BEGIN OPEN PascalBasic, PascalWizardFiles, TFtoPLPrivate, TFtoPLExternals, TFtoPLMain;
--:89
 Initialize: PROCEDURE = 
BEGIN {PascalWriteLongString[file: @Output, item: "This is TFtoPL 2.4 for Cedar 6.0"]; PascalWriteLn[file: @Output]};
--7:--ByteFileReset[@TfmFile,Alfa['t, 'f, 'm, ' , ' , ' , ' , ' , ' , ' ]];--:7----17:
FileRewrite[@PlFile,Alfa['p, 'l, ' , ' , ' , ' , ' , ' , ' , ' ]];--:17----28:
Ascii04↑←[' , '!, '", '#, '$, '%, '&, '', '(, '), '*, '+, ',, '-, '., '/, '0, '1, '2, '3, '4, '5, '6, '7, '8, '9, ':, ';, '<, '=, '>, '?];
Ascii10↑←['@, 'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N, 'O, 'P, 'Q, 'R, 'S, 'T, 'U, 'V, 'W, 'X, 'Y, 'Z, '[, '\\, '], '↑, '←];
Ascii14↑←['`, 'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p, 'q, 'r, 's, 't, 'u, 'v, 'w, 'x, 'y, 'z, '{, '|, '}, '~, ' ];MblString↑←['M, 'B, 'L];
RiString↑←['R, 'I, ' ];RceString↑←['R, 'C, 'E];--:28----33:--Level←0;--:33----46:
CharsOnLine←0;Perfect←TRUE;--:46----64:--LabelPtr←0;
LabelTable↑[0].Rr←0;--:64-- END;--:2----30:-- OutDigs: PROCEDURE[J: PascalInteger]
 = 
BEGIN DO J←J-1;PascalWriteInteger[file: @PlFile, item: Dig↑[J], fieldMinLength: 1]; IF J=0 THEN EXIT; ENDLOOP; END;
 PrintDigs: PROCEDURE[J: PascalInteger] = 
BEGIN DO J←J-1;PascalWriteInteger[file: @Output, item: Dig↑[J], fieldMinLength: 1];
 IF J=0 THEN EXIT; ENDLOOP; END;--:30----31:-- PrintOctal: PROCEDURE[C: Byte] = 
BEGIN J:PascalInteger[0..2];
 PascalWriteLongString[file: @Output, item: "'"];FOR i:INT    IN [ INT[0 ].. INT[2 ]] DO  J ← i;  Dig↑[J]← PascalMODPower2Mask[C ,7];C← PascalDIVPower2[C ,3]; ENDLOOP;
PrintDigs[3]; END;--:31----34:-- OutLn: PROCEDURE = 
BEGIN L:PascalInteger[0..5];
 PascalWriteLn[file: @PlFile];FOR i:INT    IN [ INT[1 ].. INT[Level ]] DO  L ← i; PascalWriteLongString[file: @PlFile, item: "   "] ENDLOOP; END;
 Left: PROCEDURE = 
BEGIN Level←Level+1;PascalWriteLongString[file: @PlFile, item: "("]; END;
 Right: PROCEDURE = 
BEGIN Level←Level-1;PascalWriteLongString[file: @PlFile, item: ")"];OutLn[]; END;--:34
--35:-- OutBcpl: PROCEDURE[K: Index] = 
BEGIN L:PascalInteger[0..39]; PascalWriteLongString[file: @PlFile, item: " "];
L←Tfm↑[K];WHILE  INT[L]>0 DO BEGIN K←K+1;L←L-1;
SELECT  PascalDIVPower2[Tfm↑[K],5]FROM 1 =>PascalWriteChar[file: @PlFile, item: Ascii04↑[1+( PascalMODPower2Mask[Tfm↑[K],31])]];
2 =>PascalWriteChar[file: @PlFile, item: Ascii10↑[1+( PascalMODPower2Mask[Tfm↑[K],31])]];
3 =>PascalWriteChar[file: @PlFile, item: Ascii14↑[1+( PascalMODPower2Mask[Tfm↑[K],31])]]; ENDCASE; END ENDLOOP ; END;--:35----36:
 OutOctal: PROCEDURE[K,L: Index] = 
BEGIN A:PascalInteger[0..1023];B:PascalInteger[0..32];J:PascalInteger[0..11];
 PascalWriteLongString[file: @PlFile, item: " O "];A←0;B←0;J←0;WHILE  INT[L]>0 DO--37:--BEGIN L←L-1;
IF Tfm↑[K+L]#0  THEN BEGIN WHILE  INT[B]>2 DO BEGIN Dig↑[J]← PascalMODPower2Mask[A ,7];A← PascalDIVPower2[A ,3];
B←B-3;J←J+1; END ENDLOOP ;SELECT B FROM 0 =>A←Tfm↑[K+L];1 =>A←A+2*Tfm↑[K+L];
2 =>A←A+4*Tfm↑[K+L]; ENDCASE; END;B←B+8; END--:37-- ENDLOOP ;
WHILE( INT[A]>0)OR (J=0)DO BEGIN Dig↑[J]← PascalMODPower2Mask[A ,7];A← PascalDIVPower2[A ,3];J←J+1; END ENDLOOP ;
OutDigs[J]; END;--:36----38:-- OutChar: PROCEDURE[C: Byte]
 = 
BEGIN IF  INT[FontType]>0  THEN BEGIN Tfm↑[0]←C;
OutOctal[0,1]; END  ELSE IF( INT[C]>=48)AND ( INT[C]<=57) THEN {PascalWriteLongString[file: @PlFile, item: " C "]; PascalWriteInteger[file: @PlFile, item: C-48
, fieldMinLength: 1]} ELSE IF( INT[C]>=65)AND ( INT[C]<=90) THEN {PascalWriteLongString[file: @PlFile, item: " C "]; PascalWriteChar[file: @PlFile, item: Ascii10↑[C-63]]} ELSE
IF( INT[C]>=97)AND ( INT[C]<=122) THEN {PascalWriteLongString[file: @PlFile, item: " C "]; PascalWriteChar[file: @PlFile, item: Ascii14↑[C-95]]} ELSE BEGIN
Tfm↑[0]←C;OutOctal[0,1]; END; END;--:38----39:-- OutFace: PROCEDURE[K: Index]
 = 
BEGIN S:PascalInteger[0..1];B:PascalInteger[0..8];
 IF  INT[Tfm↑[K]]>=18  THEN OutOctal[K,1] ELSE BEGIN PascalWriteLongString[file: @PlFile, item: " F "];
S← PascalMODPower2Mask[Tfm↑[K],1];B← PascalDIVPower2[Tfm↑[K],1];PascalWriteChar[file: @PlFile, item: MblString↑[1+( B MOD 3)]];
PascalWriteChar[file: @PlFile, item: RiString↑[1+S]];PascalWriteChar[file: @PlFile, item: RceString↑[1+( B /3)]];
 END; END;--:39----40:-- OutFix: PROCEDURE[K: Index] = 
BEGIN A:PascalInteger[0..4095];F:PascalInteger;
J:PascalInteger[0..12];Delta:PascalInteger;  PascalWriteLongString[file: @PlFile, item: " R "];
A←(Tfm↑[K]*16)+( PascalDIVPower2[Tfm↑[K+1],4]);
F←(( PascalMODPower2Mask[Tfm↑[K+1],15])*256+Tfm↑[K+2])*256+Tfm↑[K+3];IF  INT[A]>2047  THEN--43:
BEGIN PascalWriteLongString[file: @PlFile, item: "-"];A←4096-A;IF F>0  THEN BEGIN F←1048576-F;
A←A-1; END; END--:43--;--41:--BEGIN J←0;DO Dig↑[J]← A MOD 10;A← A /10;
J←J+1; IF A=0 THEN EXIT; ENDLOOP;OutDigs[J]; END--:41--;--42:--BEGIN PascalWriteLongString[file: @PlFile, item: "."];
F←10*F+5;Delta←10;
DO IF Delta>1048576  THEN F←F+524288-( PascalDIVPower2[Delta ,1]);
 PascalWriteInteger[file: @PlFile, item: PascalDIVPower2[F ,20], fieldMinLength: 1];F←10*( PascalMODPower2Mask[F ,1048575]);Delta←Delta*10;
 IF F<=Delta THEN EXIT; ENDLOOP; END;--:42-- END;--:40----52:-- CheckBcpl: PROCEDURE[K,L: Index]
 = 
BEGIN J:Index;C:Byte; IF  INT[Tfm↑[K]]>=L  THEN BEGIN BEGIN Perfect←FALSE;
IF  INT[CharsOnLine]>0  THEN {PascalWriteLongString[file: @Output, item: " "]; PascalWriteLn[file: @Output]};CharsOnLine←0;
{PascalWriteLongString[file: @Output, item: "Bad TFM file: "]
; PascalWriteLongString[file: @Output, item: "String is too long; I've shortened it drastically."]; PascalWriteLn[file: @Output]}; END;Tfm↑[K]←1;
 END;FOR i:INT    IN [ INT[K+1 ].. INT[K+Tfm↑[K]]] DO  J ← i;  C←Tfm↑[J];
IF(C=40)OR (C=41) THEN BEGIN BEGIN Perfect←FALSE;
IF  INT[CharsOnLine]>0  THEN {PascalWriteLongString[file: @Output, item: " "]; PascalWriteLn[file: @Output]};CharsOnLine←0;
{PascalWriteLongString[file: @Output, item: "Bad TFM file: "]
; PascalWriteLongString[file: @Output, item: "Parenthesis in string has been changed to slash."]; PascalWriteLn[file: @Output]}; END;Tfm↑[J]←47;
 END  ELSE IF( INT[C]<32)OR ( INT[C]>126) THEN BEGIN BEGIN Perfect←FALSE;
IF  INT[CharsOnLine]>0  THEN {PascalWriteLongString[file: @Output, item: " "]; PascalWriteLn[file: @Output]};CharsOnLine←0;
{PascalWriteLongString[file: @Output, item: "Bad TFM file: "]; PascalWriteLongString[file: @Output, item: "Nonstandard ASCII code has been blotted out."]
; PascalWriteLn[file: @Output]}; END;Tfm↑[J]←63; END  ELSE IF( INT[C]>=97)AND ( INT[C]<=122) THEN Tfm↑[J]←C-32; ENDLOOP; END;

END.