-- File: DJExtUtils3.mesa
-- utility routines used by the disjoint circuit extractor
-- Written by Martin Newell/Dan Fitzpatrick July 1981
-- Last edited: July 30, 1981 5:09 PM
DIRECTORY
Directory USING [Error, DeleteFile],
DJExtUtilsDefs: FROM "DJExtUtilsDefs",
IODefs: FROM "IODefs" USING [WriteString, WriteLine, WriteChar],
Real: FROM "Real" USING [Fix, WriteReal],
StreamDefs: FROM "StreamDefs" USING [StreamHandle, NewByteStream, Write, Append],
String: FROM "String" USING [AppendLongDecimal];
DJExtUtils3: PROGRAM
IMPORTS Directory, IODefs, Real, StreamDefs, String
EXPORTS DJExtUtilsDefs =
BEGIN
OPEN IODefs, Real, StreamDefs, String;
Create: PUBLIC PROCEDURE [fileName:STRING] RETURNS[StreamHandle] =
BEGIN
out:StreamHandle;
DeleteFile[fileName];
out ← NewByteStream[fileName,Write+Append];
out.reset[out];
RETURN[out];
END;
Close: PUBLIC PROCEDURE [file: StreamHandle] =
BEGIN
file.destroy[file];
END;
DeleteFile: PUBLIC PROCEDURE [s:STRING] =
BEGIN
ENABLE Directory.Error => CONTINUE;
Directory.DeleteFile[s];
END;
Trace: PUBLIC PROCEDURE [str:STRING, n1:LONG UNSPECIFIED, n2:LONG UNSPECIFIED ← 0] =
BEGIN
WriteString[str];
WriteString[": "];
WriteLongDecimal[n1];
IF n2 # 0 THEN {
WriteString[" "];
WriteLongDecimal[n2];
};
WriteLine[""];
END;
Error: PUBLIC PROCEDURE [x,y: REAL, str:STRING] =
BEGIN
WriteCIFUnits[x];
WriteString[" "];
WriteCIFUnits[y];
WriteString[" "];
WriteLine[str];
END;
WriteLongDecimal: PUBLIC PROCEDURE [n:LONG UNSPECIFIED] =
BEGIN
str: STRING ← [50];
AppendLongDecimal[str,n];
WriteString[str];
END;
WriteCIFUnits: PUBLIC PROCEDURE [r:REAL] =
BEGIN
WriteLongDecimal[Fix[r]];
END;
WriteFloat: PUBLIC PROCEDURE [r:REAL] =
BEGIN
WriteReal[WriteChar,r];
END;
END.