Hello,
I'm currently trying to set-up a catalog of errors using 3-D arrays.
The idea is to define bunch of errors on different levels (by levels - I mean Warning, info, errors). Here's an example:
DECL CHAR C_msg[3,80,80] ; where plane 1: info/ plane 2: Warning / plane 3: errors
C_msg[1,1,]="(I01) Gripper Changed to "
C_msg[2,1,]="(A01) Could not change GRIPPER. Please put back the previous gripper "
C_msg[3,1,]="(E01) Error returned by the gripper - See device"
The idea behind defining all the errors in one 3-D array is to keep the code nice and clean rather than defining bunch of 1-D array for each level of errors (at least, to my liking).
I'm after that trying to build strings by adding values at for example the end of sentence and therefore display them using msgNotify().
I first tried to simply write to C_msg[1,1,] using SWRITE command then display the string using msgNotify but an error is returned.
Then I thought about copying the 2-D char array to a 1-D char array using a for loop to finally display the 1-D array using msgNotify():
DEF copyString(C_array1[]:OUT, C_array2[,,]:IN, I_index1:IN, I_index2:IN)
DECL CHAR C_array1[], C_array2[,,]
DECL INT I_index1, I_index2, I_lenArray2, it
I_lenArray2 = STRLEN(C_array2[I_index1,I_index2,])
FOR it = 1 to I_lenArray2
C_array1[it] = C_array2[I_index1,I_index2,it]
msgNotify(C_array1[], "Test")
ENDFOR
END
When I set manually the for loop maximum value to be exactly the length of the string, it works all fine but if the value is one value above the exact length, an error is returned.
So I tried STRLEN but it doesn't look like to be working with 2-D arrays. Any ideas (or maybe a better way to solve the problem)?
Cheers,
Zaid