convert characters into integer


    Aug 08 2006 | 5:24 pm
    Hi all,
    I am using Max/MSP to read information I send out via serial. I made a patch which translate this data to me in a message box. The data I receive exists of three characters, mostly numbers (345). But sometimes I receive two numbers and the -character (34-). I want to convert this message box into integers. I want to read the symbols into a numberbox as 345 or in the second example 34 (instead of 34-).
    I have no idea how to do this!
    I was thinking of putting spaces after each character to seperate them. Then I can compare the last character with the - and if it is true then I must only pack the first two characters into an integer. But I think this method is very time consuming (and I have no idea how to put spaces in between characters!). Does anybody now an easier method?
    Thanks in advance

    • Aug 08 2006 | 5:45 pm
      What comes first in my mind is : check the Jasch's objects, there's a
      lot in there for this kind of situation.
      Or you could "easily" do a 5-10 lines Java or Javascript external for
      this...
      f.e
      f.e chanfrault | aka | personal computer music
      > >>>>>> http://www.personal-computer-music.com
      > >>>>>> |sublime music for a desperate people|
      Slemmo wrote:
      > Hi all,
      >
      > I am using Max/MSP to read information I send out via serial. I made a patch which translate this data to me in a message box. The data I receive exists of three characters, mostly numbers (345). But sometimes I receive two numbers and the -character (34-). I want to convert this message box into integers. I want to read the symbols into a numberbox as 345 or in the second example 34 (instead of 34-).
      > I have no idea how to do this!
      >
      > I was thinking of putting spaces after each character to seperate them. Then I can compare the last character with the - and if it is true then I must only pack the first two characters into an integer. But I think this method is very time consuming (and I have no idea how to put spaces in between characters!). Does anybody now an easier method?
      >
      > Thanks in advance
      >
      >
    • Aug 08 2006 | 6:12 pm
    • Aug 09 2006 | 8:43 am
      Thanks, the regexp works just fine.