I have ARRAY [0..iReceivedData] OF BYTE where iReceivedData (UINT) is around 769 - depends on answer that is send by sensor. So i want to break up this array to more arrays. Is that possible? I want to break it where the value 32 is (that means space, so its space between the data parts). That is why i need to found value 32 in array and need to know its position. Anyone knows how to find that? so i will have aprox 30 arrays at the end and each represents specific information.
Hope someone has an idea.
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
NbMaxSubArrays :=UPPER_BOUND(ptArray,0);//ClearpointerandlengtharrayFORindex:=0TONbMaxSubArraysDO
  ptArray[index]:=0;
  LengthArray[index]:=0;END_FOR//FillpointerarrayStartPosition :=0;EndPosition :=0;CurrentSubArray :=0;FORindex:=0TOiReceivedDataDO
  //Onlywhenwefindtheseparator
  IFByteArrayBuffer[index] =32THEN
    EndPosition :=index;
    ptArray[CurrentSubArray ]:=ADR(ByteArrayBuffer[StartPosition]); // Pointer to the first byte
    LengthArray[CurrentSubArray ]:=EndPosition-StartPosition+1; // Length of the array (count of elements)
    CurrentSubArray :=CurrentSubArray +1; // Use next record in sub array we are saving those records in
    StartPosition :=index+1; // Update start position
    //protectoverflowingpointerbuffer
    IFCurrentSubArray>NbMaxSubArraysTHEN
      EXIT;
    END_IF
  END_IFEND_FOR
Unless you have to copy your data to save it from a change, I would just define pointers to every sub array. This will save memory and computations.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
dFx hat geschrieben:
to find "32", just use a for loop :
NbMaxSubArrays :=UPPER_BOUND(ptArray,0);//ClearpointerandlengtharrayFORindex:=0TONbMaxSubArraysDO
  ptArray[index]:=0;
  LengthArray[index]:=0;END_FOR//FillpointerarrayStartPosition :=0;EndPosition :=0;CurrentSubArray :=0;FORindex:=0TOiReceivedDataDO
  //Onlywhenwefindtheseparator
  IFByteArrayBuffer[index] =32THEN
    EndPosition :=index;
    ptArray[CurrentSubArray ]:=ADR(ByteArrayBuffer[StartPosition]); // Pointer to the first byte
    LengthArray[CurrentSubArray ]:=EndPosition-StartPosition+1; // Length of the array (count of elements)
    CurrentSubArray :=CurrentSubArray +1; // Use next record in sub array we are saving those records in
    StartPosition :=index+1; // Update start position
    //protectoverflowingpointerbuffer
    IFCurrentSubArray>NbMaxSubArraysTHEN
      EXIT;
    END_IF
  END_IFEND_FOR
Unless you have to copy your data to save it from a change, I would just define pointers to every sub array. This will save memory and computations.
Hello, Thank you i will try that.
I asumme that ptArrapt is pointer po my new array and ByteArrayBuffer is my data array?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Josep M. Rams hat geschrieben:
You can substitute 32 by 0 in all array. Afteer tath you can:
Str1 :pointer to string;
If pos[index]=0 then str1:=adr(arr[index+1]) end_if
Sent from my Moto G (5S) Plus using Tapatalk
Hello,
Thank you.
But i can not change 32 with 0 because i have also Nulls in my array that are important for me. but i can say pos[index] = 32, or? What is pos?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have ARRAY [0..iReceivedData] OF BYTE where iReceivedData (UINT) is around 769 - depends on answer that is send by sensor. So i want to break up this array to more arrays. Is that possible? I want to break it where the value 32 is (that means space, so its space between the data parts). That is why i need to found value 32 in array and need to know its position. Anyone knows how to find that? so i will have aprox 30 arrays at the end and each represents specific information.
Hope someone has an idea.
Thank you.
to find "32", just use a for loop :
Unless you have to copy your data to save it from a change, I would just define pointers to every sub array. This will save memory and computations.
You can substitute 32 by 0 in all array. Afteer tath you can:
Str1 :pointer to string;
If pos[index]=0 then str1:=adr(arr[index+1]) end_if
Sent from my Moto G (5S) Plus using Tapatalk
Unless you have to copy your data to save it from a change, I would just define pointers to every sub array. This will save memory and computations.
Hello, Thank you i will try that.
I asumme that ptArrapt is pointer po my new array and ByteArrayBuffer is my data array?
Hello,
Thank you.
But i can not change 32 with 0 because i have also Nulls in my array that are important for me. but i can say pos[index] = 32, or? What is pos?
Pos would be your input array. I was thinking that your input array be an group of strings separated by number 32...
Sorry
Sent from my Moto G (5S) Plus using Tapatalk
You're assuming right.
Can anyone help define the VARS for this program?
I am a noob