Home AMX User Forum AMX Technical Discussion

removing first characters of a string

Hi!

Is there a better way to do this?

acAux = remove_string(left_string(acMessage,2),acMessage,1)

What i´m trying to do here is just to take the first two digits from "acMessage" and remove them from the string, but i think that this code is not a pretty way to solve it....

Any ideas?


P.D: How can i insert "code text-box" in a forum message?

Comments

  • It's maybe slightly clearer to use:
    acAux = left_string(acMessage, 2);
    remove_string(acMessage, acAux, 2);
    
    The [ CODE ] and [ /CODE ] tags are used to format code on the forum. Remove the spaces between the square brackets - I had to put them in to avoid them being used as code tags!

    Andy
  • Try acAux = GET_BUFFER_STRING(acMessage,2)
  • truetrue Posts: 307
    acAux = right_string(acMessage, length_string(acMessage) - 2)
    

    plenty of ways to do this
  • viningvining Posts: 4,368
    Try acAux = GET_BUFFER_STRING(acMessage,2)
    This would be my choice.........
    true
    Code:
    acAux = right_string(acMessage, length_string(acMessage) - 2)
    I believe this does the complete opposite and copies everything in the string into acAux except the first two chars and doesn't remove anything from the original string either.
  • Joe HebertJoe Hebert Posts: 2,159
    MorgoZ wrote: »
    What i´m trying to do here is just to take the first two digits from "acMessage" and remove them from the string

    If you don't care what the first 2 characters are and simply want to remove them from the string you can also do just this:
    GET_BUFFER_STRING(acMessage,2)
    

    You don't have to assign the first 2 characters to another variable if you don't want to.
  • MorgoZMorgoZ Posts: 116
    Ok,

    thanks to all of you!

    this will be my choice for now
    GET_BUFFER_STRING(acMessage,2)
    

    ;)
Sign In or Register to comment.