Passing functions of one namespace to function in different namespaceAll,
I have a script which has multiple namespaces - for simplicity, let's call them Namespace A and Namespace B.
When I call a function from Namespace B and I require
Test1 = Namespace("A");
Test1:IsLeapYear = function({Input_Year},{Default Local},
If(Is String(Input_Year),
Input_Year = Num(Input_Year);
);
If( (Mod(Input_Year,400) == 0 | (Mod(Input_Year,4) == 0 & Mod(Input_Year,100)!= 0)),
return(1);
,
return(0);
);
);
Test2 = Namespace("B");
Test2:MyFun = function({dt_In,TableVarName,Value},{Default Local},
dt_In << New Table Variable(TableVarName,Value);
);it to use a function from Namespace A - how can this be achieved ? So, in the above example, if I wanted to pass IsLeapYear to MyFun for use in its evaluation - how can I do that ?
Re: Passing functions of one namespace to function in different namespace@txnelson,
I failed to realize until I saw your comment that since the namespace has already been included within the script, I could call the function the way I would do it if the namespaces were defined in the same script.
Re: Passing functions of one namespace to function in different namespaceI am sorry, but I don't understand the issue. Where the source code comes from does not impact names spaces. Can you supply a sample of what the include files look like?
Re: Passing functions of one namespace to function in different namespace@txnelson,
I should have probably explained this a little better in the question.
Include(FilePathToNamespaceA);
Include(FilePathToNamespaceB);
If my script looks likes this where namespaces are being included, now how do I call IsLeapYear which belongs to Namespace A in a function of Namespace B?
Re: Passing functions of one namespace to function in different namespaceI am not exactly sure what you are going after, but is this script doing what you want?
names default to here(1);
Test1=New Namespace("A");
Test2=New Namespace("B");
Test1:IsLeapYear = Function( {Input_Year},
{Default Local},
If( Is String( Input_Year ),
Input_Year = Num( Input_Year )
);
If(
(Mod( Input_Year, 400 ) == 0 | (Mod( Input_Year, 4 ) == 0 & Mod( Input_Year, 100 ) != 0)
),
Return( 1 ),
Return( 0 )
);
);
Test2:MyFun = Function( {date},
{Default Local},
Return=Test1:IsLeapYear(date)
);
show(Test2:MyFun(1960))