I need to pass a boolean variable from one class to another. How can I archive this ? I have 2 classes, one create and set the boolean value and the other class need to get this value. It's all because I need to run code on true value for a different form. How should I declare new classB in here ? It dont let me use my class ProdParmReportFinishedWG_Extension.
[ExtensionOf(formStr(ProdParmReportFinished))]
final class ProdParmReportFinishedWG_Extension
{
public boolean TestB;
public boolean parmIsTest(boolean _test = TestB)
{
TestB = _test;
return TestB;
}
public void run()
{
next run();
if(TestB)
{
Ok.enabled(false);
Info("@SRM:SRM00049");
}
else
{
Info('im false');
}
}
}
[ExtensionOf(formdatasourcestr(ProdTableListPage, ProdTable))]
final class ProdParmReportFinishedActiveWG_Extension
{
public boolean Test;
public int active()
{
int ret;
next Active();
ProdTable tableBuffer = this.cursor();
ProdTable prodtable;
ProdParmReportFinishedWG_Extension ClassB = new ProdParmReportFinishedWG_Extension();
;
if(tableBuffer.ProdId == tableBuffer.CollectRefProdId
&& tableBuffer.ProdStatus != ProdStatus::ReportedFinished)
{
select firstonly RecId,ProdId from ProdTable where
ProdTable.CollectRefProdId == tableBuffer.ProdId
&& ProdTable.Prodstatus != ProdStatus::ReportedFinished
&& tableBuffer.RecId != prodtable.RecId;
{
Test = true;
ClassB.parmIsTest(Test);
ClassB.Run();
}
}
else
{
Global::info(strFmt("%1 , %2, %3, %4",
tableBuffer.prodid, tableBuffer.CollectRefProdId, tableBuffer.InventRefType, tableBuffer.ProdStatus));
}
return ret;
}
}
There are several ways, you can try something like this:
Example, in class A define and set boolean variable, in class B pass the boolean variable and use your logic.
Code example:
Class A
class A
{
boolean Test;
}
private void Run()
{
B ClassB = new B();
;
//Your logic to set boolean variable
Test = true;
ClassB.parmIsTest(Test);
ClassB.Run();
}
Class B
class B
{
boolean TestB;
}
public boolean parmIsTest(boolean _test = TestB)
{
TestB = _test;
return TestB;
}
public void Run()
{
//Do your logic
if(TestB)
{
//Your code...
}
else
{
//Your code...
}
//Do your logic END
}
That's exactly what I needed. Tried to write it alone but as I see I lacked a bit code from classB. Will try as soon as possible and comment it. Thanks !
How should i declare B classB value on this.. [ExtensionOf(formStr(ProdParmReportFinished))] final class ProdParmReportFinishedWG_Extension
ProdParmReportFinishedWG_Extension ClassB = new ProdParmReportFinishedWG_Extension(); Since I can't use extended classes how can I init it ?
You can try with Chain of Command (CoC)
But how can I pass values with CoC ?