使用在其他 class 扩展中创建的变量

Using a variable created in other class extension

我需要将布尔变量从一个 class 传递给另一个。我该如何存档? 我有 2 个 class,一个创建并设置布尔值,另一个 class 需要获取这个值。这都是因为我需要 运行 对不同形式的真值进行编码。 我应该如何在这里声明新的 classB ? 它不让我使用我的 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;
}

}

有几种方法,你可以这样试试:

例如,在class A中定义并设置布尔变量,在class B中传递布尔值变量并使用你的逻辑。

代码示例:

Class一个

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
}