home *** CD-ROM | disk | FTP | other *** search
- {
-
- File: Echo.p
-
- Contains: Pascal source for the Echo dcmd
-
- Written by: JM3 = Jim Murphy
-
- Copyright: ⌐ 1994 by Apple Computer, Inc., All Rights Reserved.
-
- Change History (most recent first):
-
- <2> 14-Dec-94 JM3 Updated to support the new format 3 dcmd requirements.
-
- }
-
- UNIT Echo;
-
- (* The following MPW commands will build the dcmd and copy it to the
- "Debugger Prefs" file in the System folder. The dcmd's name in
- MacsBug will be the name of the file built by the Linker.
-
- Pascal Echo.p
- Link dcmdGlue.a.o Echo.p.o {Libraries}Runtime.o {PLibraries}PasLib.o -o Echo
- BuildDcmd Echo 101
- Echo 'include "Echo";' | Rez -a -o "{systemFolder}Debugger Prefs"
- *)
-
- {$R-}
-
- INTERFACE
-
- USES MemTypes, dcmd;
-
- { Public declaration for dcmdGlue. Must be in every dcmd. The name cannot be changed. }
- PROCEDURE CommandEntry (paramPtr: dcmdBlockPtr);
-
-
- IMPLEMENTATION
-
- CONST CR = $0D;
-
-
- PROCEDURE NumberToHex (number: LONGINT; VAR hex: Str255);
- VAR digits: Str255;
- n: INTEGER;
- BEGIN
- digits := '0123456789ABCDEF';
- hex := '00000000';
- FOR n := 8 DOWNTO 1 DO
- BEGIN
- hex[n] := digits[1 + (number MOD 16)];
- number := number DIV 16;
- END;
- END;
-
-
- PROCEDURE CommandEntry (paramPtr: DCmdBlockPtr);
- VAR pos: INTEGER;
- ch: CHAR;
- value: LONGINT;
- ok: BOOLEAN;
- str: Str255;
- BEGIN
- IF paramPtr^.request = dcmdInit THEN
- BEGIN { The dcmd gets called once when loaded to init itself }
- END
- ELSE
- IF paramPtr^.request = dcmdDoIt THEN
- BEGIN { Do the command's normal function }
- dcmdDrawLine ('Echoing parameters');
-
- REPEAT
- { Save the position so we can rewind if we get an error }
- pos := dcmdGetPosition;
- ch := dcmdPeekAtNextChar;
- IF ch IN ['A'..'Z', 'a'..'z'] THEN
- BEGIN { Get the parameter as a text string }
- ch := dcmdGetNextParameter (str);
- dcmdDrawLine (str);
- END
- ELSE
- BEGIN { Get the parameter as a 32 bit value }
- ch := dcmdGetNextExpression (value, ok);
- IF ok THEN
- BEGIN { The expression was parsed correctly }
- NumberToHex (value, str);
- dcmdDrawLine (str);
- END
- ELSE
- BEGIN { The expression contained an error. Get it as a string }
- dcmdSetPosition (pos);
- ch := dcmdGetNextParameter (str);
- dcmdDrawLine (str);
- END;
- END;
- UNTIL ch = CHR(CR);
- END
- ELSE IF paramPtr^.request = dcmdHelp THEN { Display the command's help information }
- BEGIN
- dcmdDrawLine ('Echo the command line parameters.');
- END
- ELSE IF paramPtr^.request = dcmdGetInfo THEN
- BEGIN { Return the command's usage information and version so MacsBug can draw them }
- GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.usageStr := '[params...]';
-
- { Set the version to 3.0 final. }
-
- GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.dcmdVersion.majorRev := $03;
- GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.dcmdVersion.minorAndBugRev := $00;
- GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.dcmdVersion.stage := $80;
- GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.dcmdVersion.nonRelRev := $00;
- END;
- END;
-
- END.
-