NIL, msg: Rope.
tech: Rope.ROPE;
open typescript, look for a command line, herald
log.PutRope["\nMebesDirectory 6.0 --- July 31, 1985 ..."];
RunID ← NIL;
IF args.argc<2
THEN
BEGIN
log.PutRope[cmd.procData.doc];
RETURN;
END;
FOR i:
NAT
IN [1..args.argc)
DO
SELECT
TRUE
FROM
args[i].Equal["-updateServer", FALSE] => updateServer ← TRUE;
args[i].Equal["-makeTape", FALSE] => makeTape ← TRUE;
RunID = NIL AND IsRun[args[i]] => RunID ← args[i];
IsDie[args[i]] => dice ← CONS[args[i], dice];
IsLayer[args[i]] => layers ← CONS[args[i], layers];
ENDCASE =>
{log.PutF["... illegal argument \"%g\"...aborted", IO.rope[args[i]]]; RETURN};
ENDLOOP;
IF RunID = NIL THEN {log.PutRope["... no run id (e.g. 49A) ... aborted"]; RETURN};
directoryPrefix ← Rope.Cat[favoriteDirectory, RunID, "/"];
IF dice =
NIL
THEN
BEGIN
otherInput: IO.STREAM = FS.StreamOpen[IO.PutFR["%gDice.cm", IO.rope[directoryPrefix]]];
DO
t: Rope.ROPE = otherInput.GetTokenRope[MPCTokenProc ! IO.EndOfStream => EXIT].token;
IF NOT IsDie[t] THEN Abort[IO.PutFR["\"%g\" is improper die code, should be single capital letter", IO.rope[t]]];
dice ← CONS[t, dice];
ENDLOOP;
otherInput.Close[];
END;
TRUSTED {dice ←
LOOPHOLE[List.Reverse[
LOOPHOLE[dice]]]};
IF layers =
NIL
THEN
BEGIN
otherInput: IO.STREAM ← FS.StreamOpen[IO.PutFR["%gTech.cm", IO.rope[directoryPrefix]]];
tech ← otherInput.GetTokenRope[MPCTokenProc].token;
otherInput.Close[];
otherInput ← FS.StreamOpen[IO.PutFR["%gTechnology/%g-TapeLayers.cm", IO.rope[favoriteDirectory], IO.rope[tech]]];
DO
t: Rope.ROPE = otherInput.GetTokenRope[MPCTokenProc ! IO.EndOfStream => EXIT].token;
IF
NOT IsLayer[t]
THEN
Abort[IO.PutFR["\"%g\" is improper Mebes layer code, should be of form DD-AA", IO.rope[t]]];
layers ← CONS[t, layers];
ENDLOOP;
otherInput.Close[];
END;
TRUSTED {layers ← LOOPHOLE[List.Reverse[LOOPHOLE[layers]]]};
Create the Mebes tape header file ...
mebesTapeHeaderFile ← IO.ROS[];
mebesTapeHeaderFile.PutRope["\000\002\000"]; -- 2 is Cedar version, was 1 before
TRUSTED
{nFiles: [0..99] ← List.Length[LOOPHOLE[dice]]*List.Length[LOOPHOLE[layers]];
mebesTapeHeaderFile.PutChar[LOOPHOLE[nFiles]]
};
FOR i:
LIST
OF Rope.
ROPE ← dice, i.rest
WHILE i#
NIL
DO
FOR j:
LIST
OF Rope.
ROPE ← layers, j.rest
WHILE j#
NIL
DO
mebesTapeHeaderFile.PutRope[TapeHeaderName[i.first, j.first]];
ENDLOOP;
ENDLOOP;
mebesTapeHeaderFile.PutF["%02d%02d%02d\011",
IO.int[LOOPHOLE[now.month, CARDINAL] + 1],
IO.int[now.day],
IO.int[now.year MOD 100]];
pad 2048-byte block with 0's
FOR Bytecount:
INT
IN [mebesTapeHeaderFile.GetIndex..2048)
DO
TRUSTED {mebesTapeHeaderFile.PutChar[LOOPHOLE[0, CHAR]]};
ENDLOOP;
CopyToServer[localName: IO.PutFR["MPC%g.mebes", IO.rope[RunID]], fromStream: IO.RIS[IO.RopeFromROS[mebesTapeHeaderFile]]];
Make a list of files to be transferred to the tape
filesToTape ← IO.ROS[];
filesToTape.PutRope[FileServerName["", ""]]; -- of the header file
FOR i:
LIST
OF Rope.
ROPE ← dice, i.rest
WHILE i#
NIL
DO
FOR j:
LIST
OF Rope.
ROPE ← layers, j.rest
WHILE j#
NIL
DO
filesToTape.PutF[" %g", IO.rope[FileServerName[i.first, j.first]]];
ENDLOOP;
ENDLOOP;
CopyToServer[localName: IO.PutFR["MPC%g.cedarTape", IO.rope[RunID]], fromStream: IO.RIS[IO.RopeFromROS[filesToTape]]];
Copy relevant local files to the server...
IF updateServer
THEN
BEGIN
CopyToServer[
localName: IO.PutFR["MPC%g.cedarTape", IO.rope[RunID]],
serverName: IO.PutFR["%g/MPC%g.cedarTape", IO.rope[directoryPrefix], IO.rope[RunID]]];
CopyToServer[
localName: IO.PutFR["MPC%g.mebes", IO.rope[RunID]],
serverName: FileServerName["", ""]];
FOR i:
LIST
OF Rope.
ROPE ← dice, i.rest
WHILE i#
NIL
DO
FOR j:
LIST
OF Rope.
ROPE ← layers, j.rest
WHILE j#
NIL
DO
CopyToServer[localName: LocalName[i.first, j.first], serverName: FileServerName[i.first, j.first]];
ENDLOOP;
ENDLOOP;
Copy files from the server to the tape...
IF makeTape
AND (r ← Atom.GetProp[$TapeTool, $state]) #
NIL
AND (tapeTool ←
NARROW[r]).open
THEN
BEGIN
SetRope:
PROC [ textViewer: ViewerClasses.Viewer, text: Rope.
ROPE ] =
BEGIN
textViewer.class.set[textViewer, text, TRUE];
Process.Pause[Process.MsecToTicks[500]];
END;
PushButton:
PROC [button: Buttons.Button] =
BEGIN
button.class.notify[button, LIST[ NEW[TIPUser.TIPScreenCoordsRec ← [mouseX: 1, mouseY: 1, color: button.column = color]], $Mark, $Hit ]];
END;
fileNames: IO.STREAM = IO.ROS[];
log.PutRope[".... generating tape"];
SetRope[tapeTool.blockingViewer, "2048"];
PushButton[tapeTool.RewindButton];
IOClasses.Copy[from:
FS.StreamOpen[
IO.PutFR["%gMPC%g.cedarTape",
IO.rope[directoryPrefix],
IO.rope[RunID]]],
to: fileNames, closeTo: FALSE];
SetRope[tapeTool.fileNameViewer, IO.RopeFromROS[fileNames]];
PushButton[tapeTool.WriteButton];
Process.Pause[Process.SecondsToTicks[1]];
WHILE tapeTool.active DO Process.Pause[Process.SecondsToTicks[1]] ENDLOOP;
log.PutRope[".... done (you can unload tape now)"];
END
ELSE log.PutRope[".... tape not generated... done"];
EXITS Punt => log.PutF[" ... aborted"];
END;