Converting ASCII to numbers

conlin1992's icon

Hey guys

I'm wondering if there is a way to convert ascii to numbers in max?
Any help would be greatly appreciated

Wetterberg's icon
conlin1992's icon

@Wetterberg Thanks :) I tried that out and I'm getting one small problem.
When I try convert the ascii I don't get a . in my number box.
The numbers are coming from a group object and in ascii 46 = . but that isn't coming through in my flonum object. Any reason this might be happening? I'm using a fromsymbol object as well is this necessary?

Wetterberg's icon

post your patch :) Remember to use Copy Compressed.

Wetterberg's icon

well, "." isn't a number, so you can't really "convert" to it. Are you sure you don't want to convert from integers *to* ascii?

conlin1992's icon
Max Patch
Copy patch and select New From Clipboard in Max.

@WETTERBERG Here's the code. I'm getting the input through a programme called hyperIMU which transfers data through a wifi network and this data comes in in ascii

Wetterberg's icon

right, so you're processing an ascii as integers, but then you're turning it into ascii with atoi - that way your flonum obviously won't work with the ".".

Tell me what you're trying to achieve with this patch again? I think there has to be a different - and simpler - way of solving this. And I'm fairly sure it doesn't involve coaxing a dot through a numberbox of some sort. :)

conlin1992's icon

Thanks for helping i really appreciate this :) Its for my final year project in college. I'm trying to get accelerometer data into max via hyperIMU. My problem is when I get the data in its all in ASCII and I need to convert it to its numbers to be able to use it. The raw data looks like this "50 46 57 51 54 52 56 56 52 44 45 48 46 51 55 57 52 56 48 57 54 44 49 53 46 51 54 56 51 56 49 44 35". I want to be able to convert these to the numbers they're supposed to be so that I can use them. So for example this should be 2.936484, -0.37948096, 15.36831, # the "#" means the end of the line. The patch that i linked is the basic converting idea that my supervisor suggested.

Jan M's icon
Max Patch
Copy patch and select New From Clipboard in Max.

the naming of [atoi] and [itoa] might be confusing. What you need it [itoa]:

conlin1992's icon
Max Patch
Copy patch and select New From Clipboard in Max.

So if I added this to my patch it would be something like this?

I tried it in my patch and I'm getting no change in numbers when the data comes in :/

Jan M's icon
Max Patch
Copy patch and select New From Clipboard in Max.
conlin1992's icon

@JAN Thanks for all your help. I think this is certainly putting me on the right track. I'm just having trouble with the livestreaming data into the patch. I seems to work with messages but I'm not getting anything coming through when I turn on the accelerometer. I'm sure its just a small fix somewhere along the line