DIRECTORY TerminalIO, CD, CDSequencer, CDOps, CDCommandOps, CDBasics, CDMenus USING [CreateEntry], IO; CDCountCommands: CEDAR PROGRAM IMPORTS TerminalIO, CD, CDMenus, CDSequencer, CDOps, CDCommandOps, IO = BEGIN stopFlag: REF BOOLEAN = NEW[BOOLEAN]; rectCounter: INT; childCounter: INT; MyDrawChild: CD.DrawProc = BEGIN childCounter _ childCounter+1; inst.ob.class.drawMe[inst: inst, pos: inst.location, orient: inst.orientation, pr: pr]; END; MyDrawRect: CD.DrawRectProc = BEGIN rectCounter _ rectCounter+1; END; ProtectedCount: PROCEDURE [comm: CDSequencer.Command] = BEGIN myDrawRef: CD.DrawRef _ CD.CreateDrawRef[comm.design]; rectCounter _ childCounter _ 0; myDrawRef.interestClip _ CDBasics.universe; myDrawRef.drawChild _ MyDrawChild; myDrawRef.drawRect _ MyDrawRect; CDOps.DrawDesign[design: comm.design, pr: myDrawRef]; myDrawRef _ NIL; TerminalIO.WriteRope[IO.PutFR["rectangles %g objects %g\n", IO.int[rectCounter], IO.int[childCounter] ]]; END; CountComm: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Count rectangles\n"]; [] _ CDCommandOps.CallWithResource[ProtectedCount, comm, $myDrawRef, stopFlag]; END; CDMenus.CreateEntry[menu: $ProgramMenu, entry: "count rectangles", key: $CountRects]; CDSequencer.ImplementCommand[$CountRects, CountComm,, dontQueue]; END. CDCountCommands.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. by: Ch. Jacobi, February 20, 1985 10:41:19 am PST Last Edited by: Ch. Jacobi, May 29, 1985 6:50:31 pm PDT --the global variables mare monitored using CDCommandOps.CallWithResource; --these variables are global so they can be used by MyDrawChild --PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation, pr: REF CD.DrawInformation] --PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation, pr: REF CD.DrawInformation] Κ˜™Jšœ Οmœ1™Jšžœ˜Jšžœ˜Jšœ˜—Jšžœ˜—J™š  œžœ˜-Jšžœ˜Jšœ,˜,JšœO˜OJšžœ˜J˜—IcodešœU˜UJšœA˜AJšžœ˜J˜—…—$ S