[INHERIT ('SYS$LIBRARY:STARLET.PEN')]
MODULE Format(OUTPUT);

{ Module containing procedures for processing FORMAT commands. }

(******************** Declare External Variables and Constants ****************)

%INCLUDE 'HEX$DIRECTORY:HEXGLOB.INC/NOLIST'

(********************* External RTL Routine Declarations **********************)

%INCLUDE 'HEX$DIRECTORY:LIB.INC/NOLIST'

(******************* External Homemade Routine Declarations *******************)

[EXTERNAL] PROCEDURE Process_Command(Command_String: String_80); EXTERN;

[EXTERNAL] PROCEDURE Check_Extra_Chars; EXTERN;

(******************************************************************************)
(******************************************************************************)
(******************************************************************************)

[GLOBAL] FUNCTION Show_Format: INTEGER;

BEGIN

  IF (Current_Format = Intel) THEN
    WRITELN('Format: INTEL')
  ELSE IF (Current_Format = Motorola) THEN
    WRITELN('Format: MOTOROLA')
  ELSE IF (Current_Format = Rockwell) THEN
    WRITELN('Format: ROCKWELL')
  ELSE IF (Current_Format = RCA) THEN
    WRITELN('Format: RCA')
  ELSE IF (Current_Format = Tekhex) THEN
    WRITELN('Format: TEKHEX')
  ELSE IF (Current_Format = Extended_Tekhex) THEN
    WRITELN('Format: EXTENDED TEKHEX')
  ELSE IF (Current_Format = Texas) THEN
    WRITELN('Format: TEXAS')
  ELSE IF (Current_Format = Mostek) THEN
    WRITELN('Format: MOSTEK')
  ELSE IF (Current_Format = TCI) THEN
    WRITELN('Format: TCI')
  ELSE IF (Current_Format = Fairchild) THEN
    WRITELN('Format: FAIRCHILD');

  Show_Format := SS$_NORMAL;

END;

(******************************************************************************)

[GLOBAL] FUNCTION Set_Format: INTEGER;


VAR
	Error		: BOOLEAN;

BEGIN

  Error := FALSE;
  CASE (Tparse_Block.TPA$L_PARAM::INTEGER) OF

	1:	BEGIN
		  Current_Format := Intel;
		  Default_File_Type := '.HEX';
		  Default_Width := 32;
		  Maximum_Width := 250;
		END;

	2:	BEGIN
		  Current_Format := Motorola;
		  Default_File_Type := '.HEX';
		  Default_Width := 32;
		  Maximum_Width := 252;
		END;

	3:	BEGIN
		  Current_Format := Rockwell;
		  Default_File_Type := '.HEX';
		  Default_Width := 32;
		  Maximum_Width := 252;
	 	END;

	4:	BEGIN
		  Current_Format := RCA;
		  Default_File_Type := '.HEX';
		  Default_Width := 32;
		  Maximum_Width := 168;
		END;

	5:	BEGIN
	 	  Current_Format := Tekhex;
		  Default_File_Type := '.HEX';
		  Default_Width := 32;
		  Maximum_Width := 250;
	 	END;

	6:	BEGIN
		  Current_Format := Extended_Tekhex;
		  Default_File_Type := '.HEX';
		  Default_Width := 32;
		  Maximum_Width := 250;
	 	END;

	7:	BEGIN
	 	  Current_Format := Texas;
		  Default_File_Type := '.OBJ';
		  Default_Width := 32;
		  Maximum_Width := 200;
	 	END;

	8:	BEGIN
		  Current_Format := Mostek;
		  Default_File_Type := '.HEX';
		  Default_Width := 32;
		  Maximum_Width := 250;
	 	END;

	14:	BEGIN
		  Current_Format := TCI;
		  Default_File_Type := '.HEX';
		  Default_Width := 32;
		  Maximum_Width := 253;
	 	END;

	15:	BEGIN
		  Current_Format := Fairchild;
		  Default_File_Type := '.HEX';
		  Default_Width := 32;
		  Maximum_Width := 254;
	 	END;

  END; { case statement }

  IF (NOT Error) THEN
    BEGIN
      Check_Extra_Chars;
      Process_Command('FORMAT');
    END;

  Set_Format := SS$_NORMAL;

END;

(******************************************************************************)

END. { module format }
