0

I'm new into NAV so maybe my question will seem a bit noob but here it goes. I created a table which has a field called ID number where user needs to enter a 10-digit Biginteger (or Code, IDK what is better) which represents his/her's ID. I must create a function that will check if this number is correct by checking if it satisfies following criteria:

If number is ABCDEFGHIJ, then digit J (which is called control digit) must be equal to: J=13-( 7*(A+G) + 6*(B+H) + 5*(C+I) + 4*(D+J)) MOD 13

and also, needs to satisfy criteria below:

J <= 9 -> X = J
J > 9 -> X = 0

I thought using function FORMAT first to convert integer to string and then COPYSTR for each of local variables A,B,C,D... but it doesn't work :( Can anyone please help me out with correct code?

Lux
  • 17,835
  • 5
  • 43
  • 73
aquinco
  • 3
  • 1

2 Answers2

1

Str := format("Id"); A:=Str[1]; B:=Str[2];

Etc...

Or if you want A,B,C as integers then.

Str := format("Id"); Evaluate(A, Str[1]); Evaluate(B, Str[2]);

Mak Sim
  • 2,148
  • 19
  • 30
0

You can try this code as it worked for me:

Num : BigInteger;
Digits : Array of Byte;
I : Integer;

FOR i := 10 DOWNTO 1 DO BEGIN
  Digits[i] := Num MOD 10;
  Num := Num DIV 10;
END;

Let me know if it doesn't work for you.

Gynteniuxas
  • 7,035
  • 18
  • 38
  • 54