Rev 618 | Blame | Compare with Previous | Last modification | View Log | Download
{.PA}{*******************************************************************}{* SOURCE CODE MODULE: MC-MOD03 *}{* PURPOSE: Read, Save and Print a spread sheet. *}{* Display on-line manual. *}{*******************************************************************}typeString3 = string[3];varFileName: string[14];Line: string[100];function Exist(FileN: AnyString): boolean;var F: file;begin{$I-}assign(F,FileN);reset(F);{$I+}if IOResult<>0 then Exist:=falseelse Exist:=true;end;procedure GetFileName(var Line: AnyString; FileType:String3);beginLine:='';repeatRead(Kbd,Ch);if Upcase(Ch) in ['A'..'Z',^M] thenbeginwrite(Upcase(Ch));Line:=Line+Ch;end;until (Ch=^M) or (length(Line)=8);if Ch=^M then Delete(Line,Length(Line),1);if Line<>'' then Line:=Line+'.'+FileType;end;{.CP20}procedure Save;var I: screenIndex;J: integer;beginLowVideo;Msg('Save: Enter filename ');GetFileName(Filename,'MCS');if FileName<>'' thenbeginAssign(MCFile,FileName);Rewrite(MCFile);for I:='A' to FXmax dobegin {WriteLn('I=',I);}for J:=1 to FYmax dowrite(MCfile,Screen[I,J]);end;Grid;Close(MCFile);NormVideo;GotoCell(FX,FY);end;end;{.CP30}procedure Load;beginLowVideo;Msg('Load: Enter filename ');GetFileName(Filename,'MCS');if (Filename<>'') then if (not exist(FileName)) thenrepeatMsg('File not Found: Enter another filename ');GetFileName(Filename,'MCS');until exist(FileName) or (FileName='');if FileName<>'' thenbeginClrScr;Msg('Please Wait. Loading definition...');Assign(MCFile,FileName);Reset(MCFile);for FX:='A' to FXmax dofor FY:=1 to FYmax do read(MCFile,Screen[FX,FY]);FX:='A'; FY:=1;NormVideo;UpDate;end;GotoCell(FX,FY);end;{.PA}procedure Print;varI: screenIndex;J,Count,LeftMargin: Integer;P: string[20];MCFile: Text;beginLowVideo;Msg('Print: Enter filename "P" for Printer> ');GetFileName(Filename,'LST');Msg('Left margin > '); Read(LeftMargin);if FileName='P.LST' then FileName:='Printer';Msg('Printing to: ' + FileName + '....');Assign(MCFile,FileName);Rewrite(MCFile);For Count:=1 to 5 do Writeln(MCFile);for J:=1 to FYmax dobeginLine:='';for I:='A' to FXmax dobeginwith Screen[I,J] dobeginwhile (Length(Line)<XPOS[I]-4) do Line:=Line+' ';if (Constant in CellStatus) or (Formula in CellStatus) thenbeginif not (Locked in CellStatus) thenbeginif DEC>0 then Str(Value:FW:DEC,P) else Str(Value:FW,P);Line:=Line+P;end;end else Line:=Line+Contents;end; { With }end; { One line }For Count:=1 to LeftMargin do Write(MCFile,' ');writeln(MCFile,Line);end; { End Column }Grid;Close(MCFile);NormVideo;GotoCell(FX,FY);end;{.PA}procedure Help;varH: text;HelpFileName: string[14];Line: string[80];I,J: integer;Bold: boolean;beginif Exist('MC.HLP') thenbeginAssign(H,'MC.HLP');Reset(H);while not Eof(H) dobeginReadln(H,Line);ClrScr; I:=1; Bold:=false; NormVideo;repeatFor J:=1 to Length(Line) dobeginif Line[J]=^B thenbeginBold:=not Bold;if Bold then LowVideo else NormVideo;end else write(Line[J]);end;Writeln;I:=I+1;Readln(H,Line);until Eof(H) or (I>23) or (Copy(Line,1,3)='.PA');GotoXY(26,24); LowVideo;write('<<< Please press any key to continue >>>');NormVideo;read(Kbd,Ch);end;GotoXY(20,24); LowVideo;write('<<< Please press <RETURN> to start MicroCalc >>>');NormVideo;Readln(Ch);UpDate;end else { Help file did not exist }beginMsg('To get help the file MC.HLP must be on your disk. Press <RETURN>');repeat Read(kbd,Ch) until Ch=^M;GotoCell(FX,FY);end;end;