home *** CD-ROM | disk | FTP | other *** search
- {|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
- - HatchZap - This program will remove the cross-hatching from a Lotus -
- | 1-2-3 bar graph. |
- - -
- | Doug Senalik - Nov. 3, 1985 |
- - -
- |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|}
-
- {These are the values which specify what type of information is to follow}
- const Font=$A7; {Specify font to use for labels}
- LblSiz=$AC; {Set size of following label}
- Labl=$A8; {Text label follows}
- PlotUp=$A0; {Position "pen" without drawing}
- PlotDn=$A2; {Move "pen", drawing line}
- Color=$B0; {Select "pen" color with bits 0-3 of this byte}
- MaxSiz=$00; {Maximum coordinates of plane}
- EndFile=$60; {PIC file end of file marker}
- CtrlZ=$1A; {DOS end of file marker}
-
- type FileString=string[80];
- CharString=string[80];
-
- var InstructionCount, HatchesZapped,
- Skip, XStart, YStart, XEnd, YEnd,
- XPos, YPos, I, J: integer;
- DoingString: boolean;
- InFileName, OutFileName: FileString;
- InFile, OutFile: file of byte;
- AByte, Byte1, Byte2, Byte3, Byte4: byte;
-
-
- procedure Strip (var AnyString: CharString);
- {Removes leading and trailing spaces from a string.}
-
- begin
- while (length(AnyString)>0) and (AnyString[1]=' ') do
- delete (AnyString,1,1);
- while (length(AnyString)>0) and (AnyString[length(AnyString)]=' ') do
- AnyString[0]:=chr (length(AnyString)-1); {Delete last character}
- end; {Strip}
-
-
- function UpperCase (AnyString: CharString): CharString;
- {Converts a string to entirely upper case characters.}
-
- var I: integer;
-
- begin
- UpperCase:=AnyString; {Get new string of correct length first}
- for I:=1 to length (AnyString) do
- UpperCase[I]:=upcase (AnyString[I]); {Now to upper case}
- end; {UpperCase}
-
-
- procedure PicCheck (var AnyName: FileString);
- {Now check for the proper extension of PIC, or put it on if none supplied}
-
- var I: integer;
-
- begin
- I:=pos('.',AnyName);
- if (I=0) then
- AnyName:=AnyName + '.PIC'
- else
- if (I=length(AnyName)) then
- AnyName:=AnyName + 'PIC'
- else
- if copy(AnyName,I,4)<>'.PIC' then
- begin
- writeln ('Lotus picture files can only have an extension of .PIC');
- writeln ('Program aborted!');
- halt;
- end;
- end; {PicCheck}
-
-
- begin {Main program}
- InstructionCount:=0; {Just to show user how many instructions done so far}
- HatchesZapped:=0; {How many cross-hatching lines deleted}
- Skip:=12; {Don't look at first 12 bytes. Their function remains}
- {unknown. Transfer them to the new file unchanged.}
- DoingString:=false; {true when string instruction found}
- XStart:=-1;
- YStart:=-1;
- clrscr;
- normvideo;
- gotoxy (25,1);
- writeln ('HatchZap');
- writeln;
- writeln ('This handy program will remove the cross-hatching from a');
- writeln ('Lotus-generated bar graph, leaving open bars. Don''t use');
- writeln ('this program on other graph types unless you want nonsense.');
- writeln;
- writeln;
- if paramstr(1)='' then
- begin
- write ('Select input file: ');
- readln (InFileName);
- end
- else
- InFileName:=paramstr(1);
- {Manipulate file names to remove spaces, make all upper case}
- Strip (InFileName);
- InFileName:=UpperCase (InFileName);
- {Now check for the proper extension of PIC, or put it on if none supplied}
- PicCheck (InFileName);
- if paramstr(2)='' then
- begin
- write ('Select output file: ');
- readln (OutFileName);
- end
- else
- OutFileName:=paramstr(2);
- Strip (OutFileName);
- OutFileName:=UpperCase (OutFileName);
- PicCheck (OutFileName);
- if InFileName=OutFileName then
- begin
- writeln ('Big error! You can''t use the same name for both files!');
- halt;
- end;
- writeln;
- writeln;
- assign (InFile, InFileName);
- assign (OutFile, OutFileName);
- reset (InFile);
- rewrite (OutFile);
- writeln ('Now converting ', InFileName, ' to ', OutFileName);
- writeln;
- write (' Instruction count = ');
- XPos:=wherex;
- YPos:=wherey;
- writeln;
- writeln ('Crosshatches zapped = 0');
- writeln;
-
- {Now do the conversion}
-
- while not (eof(InFile)) do
- begin
- read (InFile, AByte);
- if Skip>0 then
- begin
- Skip:=Skip-1;
- write (OutFile, AByte);
- end
- else if DoingString then
- begin
- if AByte=0 then DoingString:=false; {0 is end of string marker}
- write (OutFile, AByte);
- end
- else if (AByte and $F0)=Color then
- begin
- write (OutFile, AByte);
- InstructionCount:=InstructionCount + 1;
- gotoxy (XPos, YPos);
- write (InstructionCount);
- end
- else
- begin
- InstructionCount:=InstructionCount + 1;
- gotoxy (XPos, YPos);
- write (InstructionCount);
- case AByte of
- EndFile,
- CtrlZ: write (OutFile, AByte);
- Font: begin
- Skip:=1;
- write (OutFile, AByte);
- end;
- PlotUp: begin
- Read (InFile, Byte1, Byte2, Byte3, Byte4);
- XStart:=Byte1*256+Byte2;
- YStart:=Byte3*256+Byte4;
- write (OutFile, AByte, Byte1, Byte2, Byte3, Byte4);
- end;
- LblSiz,
- MaxSiz: begin
- Skip:=4;
- write (OutFile, AByte);
- end;
- Labl: begin
- DoingString:=true;
- Skip:=1; {Skip over the next byte, which is a flag,}
- {and can be 00, the end of string marker}
- write (OutFile, AByte);
- end;
- PlotDn: begin
- Read (InFile, Byte1, Byte2, Byte3, Byte4);
- XEnd:=Byte1*256+Byte2;
- YEnd:=Byte3*256+Byte4;
- {Only send this command for horizontal or vertical lines}
- {This therefore excludes diagonal cross-hatching!}
- if (XStart=XEnd) or (YStart=YEnd) then
- write (OutFile, AByte, Byte1, Byte2, Byte3, Byte4)
- else
- begin
- HatchesZapped:=HatchesZapped + 1;
- gotoxy (XPos, YPos+1);
- write (HatchesZapped);
- end;
- XStart:=XEnd;
- YStart:=YEnd;
- end;
- else
- write (OutFile, AByte); {Unanticipated stuff goes through}
- write (' Warning! - Unknown instruction of ',AByte:3);
- end; {case}
- end; {else}
- end; {while not eof}
- close (InFile);
- close (OutFile);
- gotoxy (1,YPos+2);
- writeln;
- writeln ('Completed.');
- writeln;
- end.
-
-
- {End of file}