cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
robust1972
Level IV

how to convert binary data into ascii codes


I have some analog data I need to convert it to binary basing on its value(done). Then I managed to put 8 bits together to make a binary data by jmp script. Where I need help is how to convert the binary data into text/number using ascii codes. I tried use blob to char but it reporting wrong data type....

I attached jmp table.

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: how to convert binary data into ascii codes

The binary numbers in your table do not always correspond to A-Z or 0-9. These show up: " # & 0 1 2 3 4 5 6 7 ? @ A B C D E F G H I J K L M N P Q R S T U V W X _ o { } ~

And in the many cases of non-printable ascii "characters" there will be empty cells in JMP.

I've probably misunderstood your goal, but try this formula, which will make an exception for all wl among {12, 13, 26, 27, 40, 41}.

If( Contains( {12, 13, 26, 27, 40, 41}, :wl ),

  Char(

  (Matrix(

  {:Name( "0" ), :Name( "1" ), :Name( "2" ), :Name( "3" ), :Name( "4" ),

  :Name( "5" ), :Name( "6" )}

  )` * 2 ^ Index( 0, 6 )`)[1]

  ),

  Hex To Char(

  Right(

  Hex(

  (Matrix(

  {:Name( "0" ), :Name( "1" ), :Name( "2" ), :Name( "3" ),

  :Name( "4" ), :Name( "5" ), :Name( "6" )}

  )` * 2 ^ Index( 0, 6 )`)[1],

  "integer"

  ),

  2

  ),

  "us-ascii"

  )

)

View solution in original post

4 REPLIES 4
ms
Super User (Alumni) ms
Super User (Alumni)

Re: how to convert binary data into ascii codes

There is probably a simpler way, but try to paste the code below into a column formula field in the posted data table. It should give the ascii character (the first argument of Hex() alone calculates the ascii decimal code)

Hex To Char(

  Right(

  Hex(

  (Matrix(

  {:Name( "0" ), :Name( "1" ), :Name( "2" ), :Name( "3" ), :Name( "4" ), :Name( "5" ), :Name( "6" )} )` * 2 ^ [0, 1, 2, 3, 4, 5, 6])[1],

  "integer"

  ),

  2

  ),

  "us-ascii"

)

robust1972
Level IV

Re: how to convert binary data into ascii codes

Thanks MS!

I know nothing about matrix usage in jmp. for the data I posted, my ultimate goal are A: convert "wl" 0~11, 14~25 and 28~39 to text composing A-Z and 0-9. B: Other "wl"s represent a 2 digit decimal number.

your script work for A but not for B.

ms
Super User (Alumni) ms
Super User (Alumni)

Re: how to convert binary data into ascii codes

The binary numbers in your table do not always correspond to A-Z or 0-9. These show up: " # & 0 1 2 3 4 5 6 7 ? @ A B C D E F G H I J K L M N P Q R S T U V W X _ o { } ~

And in the many cases of non-printable ascii "characters" there will be empty cells in JMP.

I've probably misunderstood your goal, but try this formula, which will make an exception for all wl among {12, 13, 26, 27, 40, 41}.

If( Contains( {12, 13, 26, 27, 40, 41}, :wl ),

  Char(

  (Matrix(

  {:Name( "0" ), :Name( "1" ), :Name( "2" ), :Name( "3" ), :Name( "4" ),

  :Name( "5" ), :Name( "6" )}

  )` * 2 ^ Index( 0, 6 )`)[1]

  ),

  Hex To Char(

  Right(

  Hex(

  (Matrix(

  {:Name( "0" ), :Name( "1" ), :Name( "2" ), :Name( "3" ),

  :Name( "4" ), :Name( "5" ), :Name( "6" )}

  )` * 2 ^ Index( 0, 6 )`)[1],

  "integer"

  ),

  2

  ),

  "us-ascii"

  )

)

robust1972
Level IV

Re: how to convert binary data into ascii codes

thanks MS.

Sorry, in fact that I realized later that  "wl" 0~11, 14~25 and 28~39 are 2 digits decimal number, which only need be convert to decimal.