String.To Chars queston

About Monkey 2 Forums Monkey 2 Programming Help String.To Chars queston

This topic contains 6 replies, has 4 voices, and was last updated by  EdzUp 1 year, 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #8914

    EdzUp
    Participant

    MX1 had String.ToChar and String.ToChars to convert a string to a char array, MX2 has a C string thing in the String class but it has a Void Ptr and I can’t see any info on Void Ptr I’ve tried casting to no avail.

     

    Anyone have any idea how to convert a string to a array of chars?

     

    Thanks in advance 🙂

    #8917

    Jesse
    Participant

    would this work for you?:

    [/crayon]
    #8918

    EdzUp
    Participant

    Ah thanks Jesse didn’t know it was that easy to do 🙂

    #8932

    nerobot
    Participant

    @edzup How do you want to use chars array?

    You can access to chars by index operator [ ], but it return INT not CHAR.

    Example:

    #8960

    EdzUp
    Participant

    I was trying to do something like this:

    Im getting ‘Error : Value ‘Self.FontString[Pos]’ is not assignable’ on the FontString[ Pos ] = Chr line, from the posts above I thought this was the way to use it but it doesnt seem to work the same as Monkey1 is there something im missing?

    #8966

    Mark Sibly
    Keymaster

    Strings in monkey2 are ‘immutable’: they cannot be modified. To do what you’re trying to do you’ll need to build a new string.

    #8973

    EdzUp
    Participant

    ah okay thanks I will recode to use slices 🙂

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.