cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
lala
Level VIII

How to use JSL how to modify decimal numbers to binary data in this format?

Hello!

How to use JSL how to modify decimal numbers to binary data in this format?

Thanks!

000903
999999

2022-07-08_13-31-17.png

 

 

 

9 REPLIES 9
lala
Level VIII

Re: How to use JSL how to modify decimal numbers to binary data in this format?

D:\E\download1.dat
txnelson
Super User

Re: How to use JSL how to modify decimal numbers to binary data in this format?

This is just a conversion to Hex

Names Default To Here( 1 );
a = "000903";
theHex = "";
i = 1;
While( Substr( a, i, 1 ) != "",
	theHex = theHex || Hex( Substr( a, i, 1 ) );
	i++;
);
Show( theHex );

This returns

theHex = "303030393033";
Jim
lala
Level VIII

Re: How to use JSL how to modify decimal numbers to binary data in this format?

Thank Jim!

So I understand the principle of calculation.But I still can't figure out how to end up adding something else and saving it in this format.

 

Thanks Experts!

2022-07-08_14-39-03.png

lala
Level VIII

Re: How to use JSL how to modify decimal numbers to binary data in this format?

 

2022-07-08_14-58-14.png

lala
Level VIII

Re: How to use JSL how to modify decimal numbers to binary data in this format?

c = "0000000000000000000000000000000000";

34——OK

 

 

c = "0000000000000000000000";

22——wrong

txnelson
Super User

Re: How to use JSL how to modify decimal numbers to binary data in this format?

d="0100303030393033000000000000000000000001003939393939390000000000000000000000"

 

I don't understand  34=OK and 33=wrong

Jim
lala
Level VIII

Re: How to use JSL how to modify decimal numbers to binary data in this format?

  • That's what's right. C has to have 34 zeros.

d="0100303030393033000000000000000000000000000000000001003939393939390000000000000000000000000000000000"

d="0100303030393033000000000000000000000000000000000001003939393939390000000000000000000000000000000000"

 

Georg
Level VII

Re: How to use JSL how to modify decimal numbers to binary data in this format?

@lala , it's really hard to follow you, what you do and what you want. I think the suggestion of Jim is fine, and your problem is not in JSL but in file operations.

My feeling is that you shouldn't write binary data in a text file. If this would work, you should be able to re-read it, but this is not the case, JMP throws an errror.

 

Names Default To Here( 1 );

tem = {"000903", "999999"};
b = "0100";
c = "0000000000000000000000000000000000";
d = "";
j = 1;
For( j = 1, j <= N Items( tem ), j++,
	a = tem[j];
	theHex = "";
	i = 1;
	While( Substr( a, i, 1 ) != "",
		theHex = theHex || Hex( Substr( a, i, 1 ) );
		i++;
		
	);
	d = d || b || theHex || c;
);
Show( d );
Show( "d = 0100303030393033000000000000000000000000000000000001003939393939390000000000000000000000000000000000" );
filename = Save Text File( "TEMP\try1.dat", Hex To Blob( d ) );
text = Load Text File( filename );
Show( (Blob To Char( text )) );
Georg
Georg
Level VII

Re: How to use JSL how to modify decimal numbers to binary data in this format?

Sorry, I've been wrong, Load/Save Text File supports BLOB, see scripting index. But I think anything else is going wrong during file operation. Below JSL with option for reading BLOB.

 

Names Default To Here( 1 );

tem = {"000903", "999999"};
b = "0100";
c = "0000000000000000000000000000000000";
d = "";
j = 1;
For( j = 1, j <= N Items( tem ), j++,
	a = tem[j];
	theHex = "";
	i = 1;
	While( Substr( a, i, 1 ) != "",
		theHex = theHex || Hex( Substr( a, i, 1 ) );
		i++;
		
	);
	d = d || b || theHex || c;
);
Show( d );
Show( "d = 0100303030393033000000000000000000000000000000000001003939393939390000000000000000000000000000000000" );
filename = Save Text File( "$TEMP\try1.dat", Hex To Blob( d ) );
text = Load Text File( filename, BLOB );
Show( (Blob To Char( text )) );
Georg