Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program Project9;
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- Function SizeOfMatrix(var MyFile: TextFile) : Integer;
- var
- Numb, n, NumbEx, Temp:Integer;
- IsCorrect, FirstIt: Boolean;
- begin
- n := 0;
- FirstIt := True;
- IsCorrect := True;
- while (not Eof(MyFile)) and IsCorrect do
- begin
- NumbEx := Numb;
- Numb := 0;
- while not Eoln(MyFile) do
- begin
- Inc(Numb);
- Read (MyFile, Temp);
- end;
- if NumbEx <> Numb then
- IsCorrect := False;
- if FirstIt then
- begin
- IsCorrect := True;
- FirstIt := False;
- end;
- Inc(n);
- Readln(MyFile);
- end;
- if (Numb = n) and IsCorrect then
- SizeOfMatrix := n
- else
- SizeOfMatrix := 0;
- end;
- procedure ReadFileName (var MyFile: TextFile);
- var
- FName: string;
- IsValidInput: boolean;
- begin
- IsValidInput := False;
- repeat
- Writeln ('Enter a file name for data entry in the format Name.txt');
- Readln(FName);
- if FileExists (FName) then
- begin
- AssignFile(MyFile, FName);
- Reset(MyFile);
- if EoF(MyFile) then
- Writeln('File is empty.')
- else
- IsValidInput := True;
- end
- else
- Writeln('Input Error. This file is empty.');
- until IsValidInput;
- end;
- function IsTheMatrixCorrect(FName: string): boolean;
- var
- MyFile: TextFile;
- Number: Integer;
- TrueMatrix: Boolean;
- begin
- TrueMatrix := True;
- AssignFile(MyFile, FName);
- reset(MyFile);
- while (not EOF(MyFile)) do
- begin
- try
- read(MyFile, Number)
- except
- TrueMatrix := false
- end;
- end;
- CloseFile(MyFile);
- IsTheMatrixCorrect := TrueMatrix;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment