[fpc-pascal] using functions from units & main programme

Sven Barth pascaldragon at googlemail.com
Fri Nov 18 17:04:06 CET 2011


Am 18.11.2011 16:49, schrieb John Lee:
> I have a normal fpc unit, call it jim, with 2 functions fna & fnb . fnb
> uses internally fna.
>
> My main program, has a uses clause including jim, and also a _different_
> version of fna, with same parameters as for that in jim, but no fnb.
>
> The problem I get is that when, in main program fnb doesn't use the
> _new_ version in the main program of fna but still uses the version that
> is in the unit. I'd thought that versions of fns in the main program are
> used in place of those in the unit when they both have the same name,
> but maybe not when a function is used another function?
>
> Never seen this before - is there a way I can force fnb to use the main
> program's version of fna, not the version that's in the unit?

Now I that I reread your mail I might get what is going on.

You expect "fnb" which is declared in "jim" to use the function "fna" 
declared in the main program? If so, then this isn't possible. The unit 
"jim" is already compiled, thus the call from "fnb" to "jim.fna" is 
fixed. Your only possibilty would be to use function/procedure variables 
and pass the function to call as a parameter to "fnb".

Regards,
Sven




More information about the fpc-pascal mailing list