--SetBootSwitches.mesa
-- by Sweet, 18-Mar-82 16:10:28
DIRECTORY
Exec,
File,
Format,
MFile,
OthelloOps,
SpecialMFile,
System;
SetBootSwitches: PROGRAM
IMPORTS Exec, Format, MFile, OthelloOps, SpecialMFile =
BEGIN
DoIt: Exec.ExecProc =
BEGIN
Say: Format.StringProc = Exec.OutputProc[h];
suc: OthelloOps.SetGetSwitchesSuccess;
file, switches: LONG STRING ← NIL;
firstPage: File.PageNumber = SpecialMFile.LeaderPages[];
sw: System.Switches;
fh: MFile.Handle ← NIL;
cap: File.Capability;
Cleanup: PROC = {
IF fh # NIL THEN MFile.Release[fh];
file ← Exec.FreeTokenString[file];
switches ← Exec.FreeTokenString[switches]};
BEGIN -- to make variables visible in exits clause
[token: file, switches: switches] ← Exec.GetToken[h];
Say["Set default switches in boot file: "L];
Say[file];
Say[" to "L];
Say[switches];
Format.CR[Say];
fh ← MFile.ReadWrite[file, [], binary ! MFile.Error =>
{Say["-- trouble opening file"L]; GO TO failed}];
cap ← SpecialMFile.GetCapaWithAccess[fh];
sw ← OthelloOps.DecodeSwitches[switches ! OthelloOps.BadSwitches =>
{Say[" -- bad switches"L]; GO TO failed}];
suc ← OthelloOps.SetSwitches[cap, firstPage, sw];
IF suc # success THEN {Say[" -- didn't succeed"L]; GO TO failed};
Cleanup[];
EXITS
failed => {Cleanup[]; RETURN[error]};
END;
END;
Exec.AddCommand["SetBootSwitches.~", DoIt];
END.