Is this OK?
Because I get one error message with v_c variable.
the message says that dimension definition size size is fewer than what is created
a_dig has dimension size property = 9
v_c has dimension size property = 9
d_control :=v_c[9,9];
a_dig[1] := v_c[1,1] * 9;
a_dig[2] := v_c[2,2] * 8;
a_dig[3] := v_c[3,3] * 7;
a_dig[4] := v_c[4,4] * 6;
a_dig[5] := v_c[5,5] * 5;
a_dig[6] := v_c[6,6] * 4;
a_dig[7] := v_c[7,7] * 3;
a_dig[8] := v_c[8,8] * 2;
Why this error ?
Thanks
You’re referencing the array v_c as a two-dimensional array, although it looks like you’ve defined it as uni-dimensional. In the Dimension property for the integer variable v_c, specify its size using 2 integers separated by a semicolon, like this … 9;9.
That should solve your issue.
Also, your in-code syntax for referring to v_c needs to change, from v_c[n,n] to v_c[n][n].
Actually, a typo on my first reply … 9;9 should be 9;2, for a two-dimensional array with 9 elements.
I call my function like this:
EVALUATE(neuvariale[9][2], “VAT Registration No.”);
Valida_NIF(newvariable);
but there is a error messagem when I insert a new value in Vendor.“VAT Registration No”.
Error Message: The indexing 9 in the array is outsider of the permited range.
Function:
Valida_NIF(v_c : ARRAY [9,2] OF Integer) : Boolean
d_control :=v_c[9][9];
a_dig[1] := v_c[1][1] * 9;
a_dig[2] := v_c[2][2] * 8;
a_dig[3] := v_c[3][3] * 7;
a_dig[4] := v_c[4][4] * 6;
a_dig[5] := v_c[5][5] * 5;
a_dig[6] := v_c[6][6] * 4;
a_dig[7] := v_c[7][7] * 3;
a_dig[8] := v_c[8][8] * 2;
…
Thanks
Remember that your array is 9 x 2, not 9 x 9. If you look at the second index that you’re using in your code to address the c_v array, you’ll see that you’re using values that exceed 2. (I’ve noticed that the html actually interprets certain strings within brackets as special characters, so I’ll use parenthesis instead to avoid that …)
So, you can iterate through your list like this …
v_c(1)(1)
v_c(1)(2)
v_c(2)(1)
v_c(2)(2) …
but the second index may not exceed 2, since that’s how you’ve defined the array.
Hello
OK, but i have my dimension property Var = 9;9
but I can not get the first, second,… positions value of my array, why not?
EX: d_control = 526396874
digito_controlo :=v_contribuinte[9][2];
MESSAGE(‘ESTA VAR = %1’,v_contribuinte[9][2]); // OK VALUE RESULT = 526396874
a_dig[1] := v_contribuinte[1][1] * 9;
MESSAGE(‘P1 = %1’,a_dig[1]); // NOK VALUE RESULT = 0 (SHOULD BE = 5)
a_dig[2] := v_contribuinte[2][2] * 8;
a_dig[3] := v_contribuinte[3][3] * 7;
a_dig[4] := v_contribuinte[4][4] * 6;
a_dig[5] := v_contribuinte[5][5] * 5;
a_dig[6] := v_contribuinte[6][6] * 4;
a_dig[7] := v_contribuinte[7][7] * 3;
a_dig[8] := v_contribuinte[8][8] * 2;
How can I do this. I only pretend read variable d_control = 526396874, and for each number position make one operation.
Thanks
Well, my first thought would be that the array element c_v(1)(1) is empty. I don’t see anything in your existing code that populates the c_v array. Have you made code to do that? Have you confirmed that it’s working?
You might want to make a loop to inspect the c_v array to be sure it’s populated as you expect it to be.
for x := 1 to 9 do begin
for y := 1 to 2 do
if not confirm(‘c-v(%1)(%2) value is’,true,x,y, c_v(x)(y)) then error(’’);
end;
That will help you determine what values you have in the c_v array to begin with.
My apologies … these typos are going to be the death of me
The break line that begins If Not Confirm needs and additional parameter.
Instead of
if not confirm(‘c-v(%1)(%2) value is’,true,x,y, c_v(x)(y)) then error(’’);
use …
if not confirm(‘c-v(%1)(%2) value is %3’, true, x, y, c_v(x)(y)) then error(’’);
Hopefully, you get the general idea from the example code. It’s not intended to be drop-in executable.
Cheers,
g