convert characters into integer

Aug 8, 2006 at 5:24pm

convert characters into integer

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?

#27079
Aug 8, 2006 at 5:45pm

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?
>
>
>

#81616
Aug 8, 2006 at 6:12pm

#81617
Aug 9, 2006 at 8:43am

Thanks, the regexp works just fine.

#81618

You must be logged in to reply to this topic.