It seems easy, but I can not. I want to be able to define a variable type when creating a function or procedure, but only accept integer numbers between 1 and 4 for example during function / procedure call. These numbers can already be used on it.
something like:
function Algo(TAlgo: array [1...4] of integer);
Where I can not even compile if I call:
Something (5); // return error, neither accept compile
Something (1); // ok
Something (2); // ok
Something (3); // ok
Something (4); // ok
I was able to get close, but I'm trying to simplify the code below, as shown above. So far I've achieved something similar by creating a Type as below:
I created a Type :
TQtd = (xUma, xDuas, xTres, xQuatro);
And inside the function, a var and a case:
var
iQtd:Integer;
...
case Precision of
xUma: iQtd := 1;
xDuas: iQtd := 2;
xTres: iQtd := 3;
xQuatro: iQtd := 4;
end;
So, I use the iQtd variable and get what I need, calling the function this way:
functionTal(xTres);
Is there any way I can create, by specifying integer, accepting only 1 to 4?