0

About code Questions

上面的代码出现了问题,数据变得一样了。

“物流码”

HTTPS://M.LZLJ.COM/R/122169506032380086
HTTPS://M.LZLJ.COM/R/122119277562447981
HTTPS://M.LZLJ.COM/R/122121718875948831
HTTPS://M.LZLJ.COM/R /122179735097552622
HTTPS://M.LZLJ.COM/R/122179678496578329
HTTPS://M.LZLJ.COM/R/122188838537349135
HTTPS://M.LZLJ.COM/R/122144854082161745
HTTPS://M.LZ力杰网/R/122105768913848444
HTTPS://M.LZLJ.COM/R/122164082606346965
HTTPS://M.LZLJ.COM/R/132008762391372701  
                让 aa := 这个;
                let s := split(text(aa.'入库产品明细'.'物流码'), "
");
                aa.('是/否' := false);
                aa.('订单状态':= 1);
                aa.('录入物流码' := 1);
                for i from 0 to number(extractx(text('入库产品明细'.'物流码数量统计'), "[0-9]+")) do let i := (create '物流码')
                    ;
                    i.('日期' := datetime(now()));
                    i.('产品' := first(aa.'入库产品明细'.'产品'));
                    for item in s do
                        i.('物流码' := item)
;

怎样才能变回原来的品种呢?我期待您的帮助。

3 replies

null
    • gold_cat
    • 6 mths ago
    • Reported - view

    The above code caused a problem, and the data became the same. How can I change it back to the original variety? I look forward to your help.

    • Fred
    • 6 mths ago
    • Reported - view

    The problem is you put the old for loop inside another for loop and now Ninox takes the record you create and in the field 物流码 it copies each instance in the array "s" until it reaches the end so you are left with the last instance of the array.

    HTTPS://M.LZLJ.COM/R/132008762391372701

    I don't know what you are trying to accomplish with the new for loop in line 7. Before you wanted to create a new record for each instance of the URL. Now you want to create new records based on a range of numbers which has no relationship to the number of URLs in 物流码.

    You should also try to stay away from using variable names that have the same name as Ninox command. item() is a Ninox command.

    You can change your code to:

    for i from 0 to number(extractx(text('入库产品明细'.'物流码数量统计'), "[0-9]+")) do
        let newRec := (create '物流码');
        newRec.(
          '日期' := datetime(now());
          '产品' := first(aa.'入库产品明细'.'产品');
          '物流码' := item(s,i)
          )
        end;
    end
    

    I recommend that you don't reuse the variable "i", in line 2, so I changed it to newRec. Then in line 6 you see that I use the item() command to get the instance in the URL that matches the number of the loop your on from "i".

    But as stated earlier the number in "i" may not match the number of URL instances in "s" so you may not get all of the URLs copied over.

      • gold_cat
      • 6 mths ago
      • Reported - view

      This is good news to wake up to, You've helped me again. I don't know where else I could have gotten this knowledge besides the forum. I appreciate your help.

Content aside

  • Status Answered
  • 6 mths agoLast active
  • 3Replies
  • 46Views
  • 2 Following