Announcement

Collapse
No announcement yet.

Indexing array of String

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Indexing array of String

    All,
    I am receiving a string of data from my COM port. I am wanting to check the end of the string (index 211) for the "*" character. I can read and parse different strings withing the COM string but when I want to index and check for the 1 character, I am not having any luck.

    You can see that I have tried a couple of different ways to check for either a "*" or '*'.
    What am I doing wrong here?

    Thanks,
    Keith
    ****************************************************************************
    Below is a snippet of my code:

    repeat

    com_Init(combuf, 212, ':' ); // set up a comms buffer, requires ':' lead in character

    print("Waiting for buffer to fill....\n");

    //=======================================================================
    repeat
    until(com_Full()); // loop until buffer fills - lead in + 208 chars

    print("buffer full....\n");

    //========================================================================

    putstr(combuf);

    print("\n\n");

    var CK[1];

    src := str_Ptr(combuf); // assign src as the same as combuf
    dest := str_Ptr(CK); str_ByteMove(src + 211, dest, 1);
    // if (combuf[211] == '*')
    // print("CK found");
    // else
    // print([STR]combuf[211]," found instead");
    // endif

    putstr(CK);

    repeat
    forever

  • #2
    All, I figured it out..... use str_GetC( &ptr, &var);
    I set str to point to my combuffer, then add 211 to the pointer which should be pointing at my ChecK character then check to make sure it is an asterisk. This signals that I have a complete fixed length buffer with a good chance of the correct data in the correct location.



    HTML Code:
    var CK;
    var str;
    
    str := str_Ptr(combuf);  // point str to combuf location
    str += 211;                  // add my offset into the combuffer
    
        str_GetC(&str, &CK);  // get char that str is pointing to
    
            if (CK == '*') // now check to see if that location has the character I am expecting
                  IN HERE PERFORM OPERATIONS WITH A GOOD COMPLETE BUFFER
            endif

    Comment


    • #3
      Hi,

      Glad to know that you have figured it out on your own. If you still have questions with your code, please don’t hesitate to ask.

      Best Regards,
      Eran

      Comment

      Working...
      X