A
A
Alertoso2021-02-27 12:57:57
Delphi
Alertoso, 2021-02-27 12:57:57

How to pass array values ​​to check in val procedure?

Help, please, something does not fit (

Procedure Val(S: String; A: TMyArray; var Error: Integer);
Var I: Integer;
Begin
  Val(S, A[I,1], Error);
  if  Error <> 0 then
    writeln('Incorrect input. Please try again.');
End;

//Procedure for filling an array with integer or fractional values
Procedure MatrixInput(var A: TMyArray);
Var I, Error: Integer;
  Input: String;
Begin
  writeln('Filling an array with numbers:');
  for I:=1 to M do
  Begin
    readln(input);
    Val(Input, A[I,1], Error);
    writeln('Pixels[', I:2, '] = (', A[I,1]:3:1, ', ', A[I,2]:3:1, ')');
  End;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
Hemul GM, 2021-02-27
@Alertoso

If you want to pass an array value, then accept it, not an array.

Procedure Val(S: String; var A: real; var Error: Integer);

Pass a variable of the array value type to the procedure, and then, if everything is OK, assign it to the array.
And you will have an infinite recursion, because you have the same names of the system procedure Val and your procedure.

K
kalapanga, 2021-02-27
@kalapanga

You don't need to send anything to it. You need to throw out your Val procedure completely. She is not needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question