DIRECTORY Ascii, Commander, Basics, Rope, FS, IO, PressFormat; SetPressPrintingModeImpl: CEDAR PROGRAM IMPORTS Ascii, Commander, FS, IO, Rope ~ BEGIN ROPE: TYPE ~ Rope.ROPE; Bad: ERROR ~ CODE; bytesPerPressPage: INT ~ 512; bytesPerWord: INT ~ Basics.bytesPerWord; ReadDirectory: PROC [input: IO.STREAM] RETURNS [REF PressFormat.DDV] ~ TRUSTED { ddv: REF PressFormat.DDV _ NEW[PressFormat.DDV]; fileLength: INT _ input.GetLength; IF fileLength MOD bytesPerPressPage # 0 THEN ERROR Bad; IF fileLength < bytesPerPressPage THEN ERROR Bad; input.SetIndex[fileLength-bytesPerPressPage]; [] _ input.UnsafeGetBlock[block: [base: LOOPHOLE[ddv], startIndex: 0, count: bytesPerWord*SIZE[PressFormat.DDV]]]; IF ddv.Passwd # PressFormat.PressPasswd THEN ERROR Bad; IF ddv.nRecs*bytesPerPressPage # fileLength THEN ERROR Bad; RETURN [ddv]; }; GetToken: PROC [stream: IO.STREAM] RETURNS [token: ROPE _ NIL] = { token _ stream.GetTokenRope[Break ! IO.EndOfStream => CONTINUE].token; }; Break: PROC [char: CHAR] RETURNS [IO.CharClass] = { IF char = '_ THEN RETURN [break]; IF char = ' OR char = ' OR char = ', OR char = '; OR char = '\n THEN RETURN [sepr]; RETURN [other]; }; SetMode: PROC [fileName: ROPE, mode: CHAR] RETURNS [expl: ROPE] ~ { file: IO.STREAM _ FS.StreamOpen[fileName: fileName, accessOptions: $write, streamOptions: [tiogaRead: FALSE, commitAndReopenTransOnFlush: TRUE, truncatePagesOnClose: FALSE, finishTransOnClose: TRUE, closeFSOpenFileOnClose: TRUE]]; documentDirectory: REF PressFormat.DDV _ ReadDirectory[file ! Bad => GOTO Quit]; was: CARDINAL _ documentDirectory.spare3[0]; documentDirectory.spare3[0] _ IF mode = '\000 THEN CARDINAL.LAST ELSE ORD[mode]; file.SetIndex[file.GetLength-bytesPerPressPage]; file.UnsafePutBlock[block: [base: LOOPHOLE[documentDirectory], startIndex: 0, count: bytesPerWord*SIZE[PressFormat.DDV]]]; file.Close; expl _ IO.PutFR["Mode used to be %g", IF was < 128 THEN IO.char[LOOPHOLE[was]] ELSE IF was = CARDINAL.LAST THEN IO.rope["normal"] ELSE IO.int[was]]; EXITS Quit => { expl _ "Sorry, not a press file"; }; }; SetPressPrintingModeCommand: Commander.CommandProc ~ { stream: IO.STREAM _ IO.RIS[cmd.commandLine]; fileName: ROPE _ GetToken[stream]; mode: ROPE _ GetToken[stream]; charMode: CHAR _ IF mode.Length = 0 THEN '\000 ELSE Ascii.Upper[mode.Fetch[0]]; expl: ROPE; IF fileName = NIL THEN {cmd.out.PutRope["Please supply a file name.\n"]; RETURN}; SELECT charMode FROM '\000, 'R, 'S, 'T => NULL; ENDCASE => {cmd.out.PutRope["Mode options are (R = reverse, S = solid, T = transparent)\n"]; RETURN}; expl _ SetMode[fileName, charMode ! FS.Error => {expl _ error.explanation; CONTINUE}; IO.Error => {expl _ FS.ErrorFromStream[stream].explanation; CONTINUE} ]; cmd.out.PutRope[expl]; cmd.out.PutRope["\n"]; }; Commander.Register["SetPressPrintingMode", SetPressPrintingModeCommand, "Force the Printing mode of a press file (R = reverse, S = solid, T = transparent), e.g.,\n SetPressPrintingMode myPress.press T"]; END. ’SetPressPrintingModeImpl.mesa Copyright (C) 1984, Xerox Corporation. All rights reserved. Michael Plass, November 1, 1984 4:21:07 pm PST Κ/˜Jšœ™J™<™.J™—šΟk œ!œœ˜>J˜—šœœ˜'Jšœœœ˜&Jšœ˜– "cedar" stylešœœœ˜J– "cedar" style˜—Jšœœœ˜Jšœœ˜Jšœœ˜(šΟn œœ œœœœ œœ˜PJš œœ œœ œ˜0Jšœ œ˜"Jšœ œœœ˜7Jšœ œœ˜1Jšœ-˜-Jšœ(œ*œ œ˜rJšœ&œœ˜7Jšœ*œœ˜;Jšœ˜ Jšœ˜J˜—– "cedar" stylešžœœ œœœ œœ˜BJšœ$œœ˜FJšœ˜J˜—– "cedar" styleš žœœœœœ˜3Jšœ œœ ˜!Jšœ œ œ œ œ œœ˜UJšœ ˜Jšœ˜J˜—š žœœ œœœœ˜CJšœœœœRœœœœœ˜ζJšœœ œœ˜PJšœœ˜,Jš œœœœœœœ˜PJšœ0˜0Jšœ"œ8œ œ˜zJšœ ˜ Jšœœœ œœœœœœœœœœœ ˜”šœ ˜Jšœ!˜!Jšœ˜—Jšœ˜J˜—šžœ˜6Jš œœœœœ˜,Jšœ œ˜"Jšœœ˜Jš œ œœœœ˜OJšœœ˜ Jšœ œœ3œ˜Qšœ ˜Jšœœ˜JšœVœ˜e—šœ#˜#Jšœ%œ˜1Jšœœ&œ˜EJšœ˜—Jšœ˜Jšœ˜Jšœ˜J˜—šœΜ˜ΜJ˜—Jšœ˜J˜—J˜—…—  a