@adrian the problem you are having is that. In Pascal, in order for a procedure/function to call another procedure/function that is in the same unit file. It has to know about the procedure/function before it can call the procedure/function.
There is two ways to do this in Pascal:
Place the procedure/function that is being called by a procedure/function. Someplace prior to the procedure/function that is calling that procedure/function.
function UltimoDiaMes(P1,P2: Variant): Variant;
begin
Result := P1 + P2;
end;
// here there are others functions in the same script file, like the following:
function AMD(Par: String): Variant;
begin
ShowMessage(UltimoDiaMes(3,4));
end;
Defining a forward for the procedure/function.
function AMD(Par: String): Variant; forward;
function UltimoDiaMes(P1,P2: Variant): Variant; forward;
function AMD(Par: String): Variant;
begin
ShowMessage(UltimoDiaMes(3,4));
end;
// here there are others functions in the same script file, like the following:
function UltimoDiaMes(P1,P2: Variant): Variant;
begin
Result := P1 + P2;
end;
Which of the two ways to use is up to you. But, understand that there will come a time when you will create a procedure/function that is calling a procedure/function. And it is also being called by another procedure/function. Or you will create a procedure/function that will use two, or more, procedures/functions. In either case you will find that you are unable to place of this procedure/function so that it can see the other procedures/function. And/Or it can not be seen by other procedures/function that might being calling it.
It is with this in mind that I would recommend that you would use the second way. As this will ensure that all procedures/functions have a forward defined for them prior to any other procedure/function that may call them. Thus allowing any procedure/function to call another procedure/function. No matter where in the unit file the calling procedure/function is in relation to the procedure/function it is calling.