"steven.borley" wrote:
I would like to use the built-in Round() function, but its getting masked by the round() function if fp.pas in the Universal Interfaces, and they are not compatible (one returns a Integer, the other a double).
In the past, with other Pascal dialects, I have solved this by using System.Round() to get the built-in routine, but I don't believe this syntax is supported by GPC.
I could in theory arrange my uses clause to avoid using the fp unit, but as it turns out I only ever use Round() in routines that also require the fp unit's functions.
Is there a simple solution to this?
round is a standard system function returning integer, so it is effectively declared at level 0, and any redeclaration of round will mask it. However you could declare a function at level 1 (global functions) that calls round and returns integer. Call this function sysround, for example. Now the scope of that function is all of level 1, before or after it was declared, so you can't have, and for similar reasons you can't declare a round at level 1. However you can at level 2. Thus:
(* level 0 surrounds the program *)
PROGRAM blah(output);
(* This is level 1 *)
FUNCTION sysround(x : real) : integer; BEGIN sysround = round(x); END;
PROCEDURE foo; FUNCTION round(x : real) : real; BEGIN (* whatever *) END;
(* This is level 2 *) (* in here the new function round is available *)
FUNCTION bar(y : real) : char; BEGIN (* This is level 3 *) (* code calling round *) (* code calling sysround *) END;
BEGIN (* foo *) (* This is level 2 again *) (* code calling round *) (* code calling sysround *) END;
(* Back to level 1 *) (* Now round : real is no longer available *) (* however both sysround and round : integer are *) BEGIN ... END.