{$linesize:130,$symtab-,$title:'Byte(base 10) File Dump'}
{$line+}
{$entry+}

program BDUMP( input, output );

function GetNextArg(var SwitchType,Numeric:boolean;var SwitchChar:char;
			var StringArg:lstring;var NumericArg:integer):boolean;external;
			{ returns next argument from command line }
			{ returns true if there was an argument }
			{ arguments are fields separated by spaces or a slash (/) }
{			SwitchType      true if argument begins with a slash
			Numeric         true if argument is an integer
			SwitchChar      char following / for switch type args
								 (SwitchChar is folded to upper case)
			StringArg       contains the ASCII argument (not the /)
			NumericArg      contains the value of arg, if applicable

			double quotes ("...") must be used to enclose an arg 
				containing a space or slash (/). 
}



const  
 nothing = 0;

var
	ch : char;
	i : byte;
	Count : integer;
	Inp : file of byte;
	SwitchType,Numeric : boolean;
	SwitchChar : char;
	StringArg : Lstring(80);
	NumericArg : integer;

	filestr : lstring(30);

{$subtitle:'MAIN PROGRAM'}
BEGIN															 { MAIN PROGRAM }
	writeln('Byte File Dump program -- output in base 10 and base 16');
	writeln;

	if not GetNextArg(SwitchType,Numeric,SwitchChar,FileStr,NumericArg)
		then { null command line } begin { get file name from operator }
	   write('Enter input file name: ');
  		readln(filestr);
	end;

   assign(Inp,filestr);
   reset(Inp);
	Count := 0;

while not eof(Inp) do begin
	if (Count MOD 8) = 0 then begin
		writeln;  { new line }
		write(Count:5,' :',Count:4:16,'|  ');
	end;
	read(Inp,i);
	if (i < 32) or (i > 126) then ch := '.'
		else ch := chr(i);
	write(' ',ch,i:3,':',i:2:16);
	Count := Count + 1;
end;

writeln; writeln;

end.			    { main }
