System.Declared - Manhunter07/MFL GitHub Wiki

Declaration

function Declared(Name: System.String): System.Boolean = \built-in\

Description

The Declared function in the System package determines whether or not the identifier is declared in the current program. This includes both qualified and unqualified identifiers. The function returns a boolean value. It returns either True if the identifier with the given name is declared or False if it is undeclared.

The function does not work with parameter names. If used inside a function, constructor or converter, Declared only checks the global namespace, not the local one. To check if a function has a parameters with this name, you must access the Params local function helper:

function Foo1(Arg) = Declared("Arg") \returns False\
function Foo2(Arg) = Has(Params, "Arg") \returns True\

For this reason you cannot use Declared(...) on function helpers like Params, Args and Caller.

Declared and Has

Declared checks if an object has been globally-declared. It cannot check if that object has a certain member. Thereby, the identifier passed as Parameter has to be either just the object name, or the package and the object names split by a dot (.). Anything in front of the last dot will be treated as the qualified package name. If you want to check if an object has a member with a certain name you must use the Has function:

\Returns "Yes" if there is an object "Pt" with a member "X" and "No" otherwise\
if Declared("Pt") + Has(Pt, "X") then "Yes" else "No"

See also