<> <> DIRECTORY Rope, Interscript, FileIO USING [Open, OpenFailed], Process, SafeStorage, IO; InterscriptImpl: CEDAR PROGRAM IMPORTS Interscript, IO, SafeStorage, FileIO, Rope, Process = BEGIN OPEN Interscript; ROPE: TYPE ~ Rope.ROPE; MainLoop: PROCEDURE = { <> <> <> <> <> error, fileName: ROPE; bindTbl: BTHandle; vin, vout: IO.STREAM; scriptZone: ZONE _ SafeStorage.NewZone[sr: quantized]; script: IO.STREAM; [in: vin, out: vout] _ IO.CreateViewerStreams[name: "Interscript"]; BEGIN ENABLE IO.Error => GO TO quit; DO vout.Put[IO.rope["Type the name of the file to be internalized (extension .is83 is assumed): "]]; fileName _ GetFileName[in: vin, dfltExt: "is83"]; script _ FileIO.Open[fileName: fileName ! FileIO.OpenFailed => {vout.Put[IO.rope["\nCouldn't open the file named "], IO.rope[fileName], IO.rope["\n"]]; LOOP}]; EXIT; ENDLOOP; DO vout.Put[IO.rope["Internalizing "], IO.rope[fileName], IO.rope[": "]]; error _ Internalize[stream: script, z: scriptZone]; IF error = NIL THEN {vout.Put[IO.rope["No errors\n"]]; EXIT} ELSE vout.Put[IO.rope[error], IO.rope["\n"]]; ENDLOOP; EXITS quit => RETURN; END; }; GetFileName: PROC [in: IO.STREAM, dfltExt: ROPE _ NIL] RETURNS [name: ROPE] = { <> point: INT; name _ in.GetRope[]; IF (point _ name.Index[s2: "."]) >= name.Length[] THEN name _ name.Cat[".", dfltExt]; }; TRUSTED {Process.Detach[FORK MainLoop[]]}; END. <> <> <<>>