BLControl.mesa
Last edited by Satterthwaite on January 6, 1983 2:21 pm 
Last Edited by: Maxwell, August 29, 1983 3:49 pm
DIRECTORY
Commander: TYPE USING [Handle, Register],
CommandUtil: TYPE USING [
Echo, Failed, GetNth, GetRootName, GetSwitches, ListLength, PairList, Parse, SetExtension, Switches],
IO: TYPE USING [char, CR, Put, PutChar, PutRope, rope, STREAM, time, UserAbort],
ListerOps: TYPE USING [ListBcd, ListFiles, ListRTBcd, ListStamps, ListVersion],
ListerUtil: TYPE USING [SetTypescript],
OSMiscOps: TYPE USING [BcdCreateTime],
Rope: TYPE USING [ROPE];
BLControl: PROGRAM
IMPORTS Commander, CommandUtil, IO, ListerOps, ListerUtil, OSMiscOps = {
switches
StandardDefaults: PACKED ARRAY CHAR ['a..'z] OF BOOL = [
FALSE, -- a
TRUE, -- b Bcd (only)
FALSE, -- c
FALSE, -- d Call debugger on error
FALSE, -- e
FALSE, -- f Files (only)
FALSE, -- g
FALSE, -- h
FALSE, -- i
FALSE, -- j
FALSE, -- k
FALSE, -- l Links
FALSE, -- m
FALSE, -- n
FALSE, -- o Ordered (with /r only)
FALSE, -- p
FALSE, -- q
FALSE, -- r RTBcd (only)
FALSE, -- s Stamps (only)
FALSE, -- t
FALSE, -- u
FALSE, -- v Version (only)
FALSE, -- w
FALSE, -- x
FALSE, -- y
FALSE];-- z
v > b > r > f > s; others are unused
Commander interfaces
DoCommand: SAFE PROC[cmd: Commander.Handle] = TRUSTED {
switches: Rope.ROPE;
results: CommandUtil.PairList;
commandArgs: CommandUtil.PairList;
localSwitches: CommandUtil.Switches;
inputName, outputName, rootName: Rope.ROPENIL;
defaultSwitches: CommandUtil.Switches ← StandardDefaults;
WriteHerald: PROC [stream: IO.STREAM, id: Rope.ROPE] = {
stream.Put[
IO.rope["Cedar 3.4 Symbol Lister of "],
IO.time[OSMiscOps.BcdCreateTime[]],
IO.char[IO.CR]];
IF id # NIL THEN stream.Put[IO.rope[id], IO.rope[" -- "]];
stream.Put[IO.time[], IO.char[IO.CR]]};
RepeatCommand: PROC [s: IO.STREAM] = {
IO.PutRope[s, "\nListing "]; IO.PutRope[s, inputName];
IO.PutRope[s, ", output to "]; IO.PutRope[s, outputName];
IO.PutChar[s, IO.CR]};
ListerUtil.SetTypescript[cmd.out];
WriteHerald[cmd.out, NIL];
main loop
DO {
Initialize: PROC = INLINE {RepeatCommand[cmd.out]};
Finalize: PROC = INLINE {};
[inputName, commandArgs, results, switches] ←
CommandUtil.Parse[cmd.commandLine
! CommandUtil.Failed => {GO TO badSyntax}];
IF inputName = NIL AND switches = NIL THEN EXIT; -- done listing
cmd.out.PutRope["\nCommand: "];
CommandUtil.Echo[
d: cmd.out, operator: inputName, argList: commandArgs,
resultList: results, switches: switches];
IF inputName = NIL THEN GO TO globalSwitches;
SELECT CommandUtil.ListLength[results] FROM
0 => outputName ← NIL;
1 => outputName ← CommandUtil.GetNth[list: results, n: 0];
ENDCASE => GO TO badSemantics;
rootName ← CommandUtil.GetRootName[inputName];
localSwitches ← CommandUtil.GetSwitches[switches, defaultSwitches];
IF localSwitches['v] THEN outputName ← NIL
ELSE {IF outputName = NIL THEN outputName ← rootName;
outputName ← CommandUtil.SetExtension[outputName, "bl"]};
BEGIN
ENABLE UNWIND => {Finalize[]};
Initialize[];
SELECT TRUE FROM
localSwitches['v] => ListerOps.ListVersion[rootName];
localSwitches['s] => ListerOps.ListStamps[rootName, outputName];
localSwitches['f] => ListerOps.ListFiles[rootName, outputName];
localSwitches['r] => ListerOps.ListRTBcd[rootName, outputName, localSwitches['o]];
localSwitches['b] => ListerOps.ListBcd[rootName, outputName, localSwitches['l]];
ENDCASE;
Finalize[];
END;
IF cmd.in.UserAbort[] THEN EXIT;
EXITS
globalSwitches => {
defaultSwitches ← CommandUtil.GetSwitches[switches, defaultSwitches];
switches ← NIL; results ← NIL};
badSemantics => {
results ← NIL;
cmd.out.PutRope["\n -- Illegal command"]}};
REPEAT
badSyntax => {cmd.out.PutRope["-- Illegal syntax"]};
ENDLOOP;
};
global Binder initialization
Commander.Register["bl", DoCommand,
"Prints the information in a .bcd file (not the code or symbols)."];
Commander.Register["BCDLister", DoCommand,
"Prints the information in a .bcd file (not the code or symbols)."];
}.