Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure CheckCoordinate(Str: String; var Err: String; var IsCorrect: Boolean; var CoordinateX: Integer; var CoordinateY: Integer; var F: TextFile);
- var
- I: Integer;
- IsFirst: Boolean;
- begin
- if (Str = '') then
- begin
- Err := 'В файле не найдено элементов. ';
- IsCorrect := False;
- end
- else
- try
- IsFirst := true;
- I := 1;
- while (I <= Length(Str)) do
- begin
- if (Str[I] = ' ') then
- begin
- if I = 1 then
- begin
- Delete(Str, 1, 1);
- if (IsFirst) then
- Dec(I)
- else
- Inc(I);
- end;
- if (I > 1) and (IsFirst) then
- begin
- CoordinateX := StrToInt(Copy(Str, 1, (I - 1)));
- IsFirst := false;
- Delete(Str, 1, (I - 1));
- I := 0;
- end;
- if (I > 1) and not(isFirst) then
- begin
- CoordinateY := StrToInt(Copy(Str, 1, I));
- I := Length(Str);
- end;
- end;
- Inc(I);
- end;
- if (CoordinateX > MAX_VALUE) or (CoordinateX < MIN_VALUE) or
- (CoordinateY > MAX_VALUE) or (CoordinateY < MIN_VALUE) then
- begin
- Err := 'Значение одной из координат вне диапазона. ';
- IsCorrect := false;
- end;
- except
- IsCorrect := False;
- Err := 'Обнаружена некорректно записанная координата. ';
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement