Announcement

Collapse
No announcement yet.

delete last value of buffer

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

  • Jerson
    replied
    Hello Alex,

    To replace the first element in the array, make sure the pointer in the str_PutByte points to the first address.
    In the case of the code str_PutByte(ptr + (ctr), 0); ctr should be equal to 0 to point to the first element.

    Best Regards,

    Leave a comment:


  • AlexBln
    replied
    Thanks for your reply!
    the second code example works good for me.

    i'am trying to implement a 'backspace' function for my keyboard. it needs to delete the last value in the buffer..
    when i use your way, i can delete the last char, but i can't get the first one deleted
    ___________________________
    For example:


    buffer['s','f','e'];
    backspace();
    print([STR]buffer) --> sf

    backspace();
    print([STR]buffer) --> s

    backspace();
    print([STR]buffer) --> s
    ____________________________

    any ideas why ?

    Leave a comment:


  • Eran
    replied
    Hi Alex,

    You can delete the last character of your buffer by setting your last element as a NULL value.

    For example, if your last element is in the 5th position, then:

    Code:
    array[4]:=0;
    You may use this another example as well :

    Code:
        var buffer[30];   // buffer array
        var ptr;          // byte aligned pointer to buffer
            ptr:=str_Ptr(buffer);
        var ctr := 0;     // number of characters stored
        var chr;
    
        for (chr := 'a'; chr < 'z'; chr++)
            // Assumming characters are stored using the line of code below:
            str_PutByte(ptr + (ctr++), chr); // chr is the new character to store
        next
    
        // The last character can be removed using:
        str_PutByte(ptr + (ctr--), 0);
    
        print([STR] buffer);
    Hope this helps and Best Regards

    Leave a comment:


  • AlexBln
    started a topic delete last value of buffer

    delete last value of buffer

    Hello,

    how can i delete the last char of a buffer ?

    best regards,
    alex
Working...
X