turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Creating Blob object

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Dec 10, 2015 8:50 AM
(883 views)

My problem is very simple but I am stuck with it: I Have a column called "Code". Let's say it is full of "3".

This column is the result of the reading of a memory encoded with 8-bit binary.

In my exemple, 3 is actually 00000011.

I would like to convert 3 into 00000011. I tried the script:

New Column**(** "**NEW_COLUMN**", Numeric, Continuous **)**;

**Column ( "NEW_COLUMN" ) <<Set Formula(**Char To Blob

But it fails. Any idea how to handle it?

Thanks in advance!

Jérôme

1 REPLY

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Dec 10, 2015 10:48 AM
(787 views)

Hi Jérôme,

If you use the following formula, it will create the character string you want

base = Function**(** **{**n**}**,

{default local},

If**(** n != **0**,

ndash = "";

digits = "0123456789ABCDEF";

While**(** n > **0**,

remainder = Mod**(** n, **2** **)**;

newdigit = Substr**(** digits, **(****1** + remainder**)**, **1** **)**;

ndash = newdigit || ndash;

n = **(**n - remainder**)** / **2**;

);

ndash = Substr**(** "00000000", **1**, **8** - Length**(** ndash **)** **)** || ndash;

,

Ndash = "00000000"

);base**(**:Code**)**

**Assuming the target column is called "Code"**

**Jim**

Jim