我需要将布尔变量从一类传递到另一类。我该如何存档?我有2个类,一个创建并设置布尔值,另一个类需要获取此值。这是因为我需要为其他表单按真实值运行代码。我应该如何在这里声明新的classB?它不允许我使用我的类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;
}
}
有几种方法,您可以尝试如下操作:
例如,在A类中定义和设置布尔变量,在B类中传递布尔变量并使用您的逻辑。
代码示例:
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();
}
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
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句