0

I made a little script that checks if total value is above 10000. If it is; it returns true and gives a warning, if not; it returns false. Somehow my script always returns true. Does someone know why?

public Boolean Execute()
    {
        ScriptRecordset offerItemRS = this.GetRecordset("R_OFFERDETAILITEM", "" , "FK_OFFER = "+this.RecordId, "");
        if(offerItemRS != null && offerItemRS.RecordCount > 0)
        {
            offerItemRS.MoveFirst();
            double total = 0.00;

            while(!offerItemRS.EOF)
            {
                double price = (double)offerItemRS.GetField("TOTALAMOUNT").Value;
                total += price;
                offerItemRS.MoveNext();
            }

            if(total > 10000)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    else
        {
            return false;
        }
    }
4

1 回答 1

0

单步执行您的代码并观察Totalwhile 循环读取到文件末尾时的值。

可能性是您永远不会达到 10000 条记录。

但正如那家伙所提到的,使用调试器是成为软件开发人员的关键组成部分。如果您选择忽略使用此功能,您将不会走得太远。

于 2013-11-05T08:46:00.257 回答