RobotStudio event

Arrays Rank and dimensions

Options
Hi,



I know the question has already been placed by Antoine but without any answer.



When a rapiddata returns IsArray, is there a way to know the rank and size of each dimensions.



there is a not too dirty solution with try/catch to get the number of dimensions (copied hereunder) but I do not see an acceptable workaround for the sizes.



As this information is available under the debug window via the dimensions int[] it should be possible to reach it from the application.





image



Any help warmly welcomed.



BR



Laurent



Note: Code to find an array number of dimensions



static int NbDim(RapidData d)

          {

               string s;



               try

               {

                    s=d.ReadItem(1).ToString();

                    return 1;

               }

               catch

               {

                    try

                    {

                         s=d.ReadItem(1,1).ToString();

                         return 2;

                    }

                    catch

                    {

                         try

                         {

                              s=d.ReadItem(1,1,1).ToString();

                              return 3;

                         }

                         catch

                         {

                              try

                              {

                                   s=d.ReadItem(1,1,1,1).ToString();

                                   return 4;

                              }

                              catch

                              {

                                   return -1;

                              }

                         }

                    }

               }

          }