--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.