在另一个论坛上,我找到了这个公式,它似乎有效,除了我不断收到 2 个不同的错误
第一个错误
我得到“这里需要一个字符串”错误。我在它所说的代码的第 8 行(计算空白行)上收到错误
replace({ACCOUNT_CARD_DATA.CARD_NUMBER}," ","")
第二个错误
如果我添加 totext 并让它说
replace(totext({ACCOUNT_CARD_DATA.CARD_NUMBER})," ","")
它会毫无错误地保存,但是当我尝试将其放入报告中时,它会给我一个“字符串是非数字”错误。当我单击确定时,它显示代码中的错误位于第 18 行(计算空白行),它说
v_calc := tonumber(v_temp) * 2
我觉得我陷入了无法解决的循环......我做错了什么?
谢谢!
整个代码
whileprintingrecords;
stringvar v_cc := "";
stringvar v_temp := "";
numbervar v_calc := 0;
numbervar v_result := 0;
numbervar v_counter := 0;
v_cc := replace({ACCOUNT_CARD_DATA.CARD_NUMBER}," ",""); //THIS IS THE 1ST PLACE I'M GETTING THE ERROR
// Double every other digit starting with the last digit.
numbervar v_counter := len(v_cc);
while v_counter > 0
do
(v_temp := mid(v_cc,v_counter,1);
v_calc := tonumber(v_temp) * 2; //THIS IS THE 2ND PLACE I'M GETTING THE ERROR
if v_calc >= 10 then v_calc := tonumber(left(totext(v_calc,"#",0),1))+ tonumber(right(totext(v_calc,"#",0),1))
else
v_calc;
v_result := v_result + v_calc;
v_counter := v_counter - 2);
// Add in the non-doubled digits
v_counter := len(v_cc) - 1;
while v_counter > 0
do
(v_temp := mid(v_cc,v_counter,1);
v_calc := tonumber(v_temp);
if v_calc >= 10 then v_calc := tonumber(left(totext(v_calc,"#",0),1)) + tonumber(right(totext(v_calc,"#",0),1))
else
v_calc;
v_result := v_result + v_calc;
v_counter := v_counter - 2);
// Calculate check digit
v_cc + right(totext(v_result * 9,"#",0),1)