In a post I found ( I used the formula that was presented here and it seems to work except that I keep getting "A string is required here" error.
I'm getting the error on line 8 (counting blank lines) of the code where it says replace({ACCOUNT_CARD_DATA.CARD_NUMBER}," ","")
If I add totext and make it say replace(totext({ACCOUNT_CARD_DATA.CARD_NUMBER})," ","") it will save with no errors but when I try to put it in the report it gives me a "The string is non-numeric" error. When I click ok it shows me the error in the code is on line 18 (counting blank lines) where it says v_calc := tonumber(v_temp) * 2
I feel like I'm in a loop that can't be resolved...what am I doing wrong?
Thank you!
I'm getting the error on line 8 (counting blank lines) of the code where it says replace({ACCOUNT_CARD_DATA.CARD_NUMBER}," ","")
If I add totext and make it say replace(totext({ACCOUNT_CARD_DATA.CARD_NUMBER})," ","") it will save with no errors but when I try to put it in the report it gives me a "The string is non-numeric" error. When I click ok it shows me the error in the code is on line 18 (counting blank lines) where it says v_calc := tonumber(v_temp) * 2
I feel like I'm in a loop that can't be resolved...what am I doing wrong?
Thank you!
Code:
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)