cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
lala
Level VIII

How to use JSL to split a contiguous binary file into segments in bytes?

This is what happens after reading binary files with JSL:

  • It's segmented by 12 bytes

2023-02-12_20-10-00.png


b = Load Text File( "……\abc.spr", blob() );

Thanks Experts!

 

6 REPLIES 6
jthi
Super User

Re: How to use JSL to split a contiguous binary file into segments in bytes?

I would guess using Blob Peek and loop should work. There might also be additional ideas in  

-Jarmo
lala
Level VIII

Re: How to use JSL to split a contiguous binary file into segments in bytes?

Thank you for your help! "Blob Peek" is a method I learned about in the last question. Is there a more efficient way? For example regular?
lala
Level VIII

Re: How to use JSL to split a contiguous binary file into segments in bytes?

  • For example, regular substitution with EmEditor is easy to implement2023-02-12_21-59-57.png

Craige_Hales
Super User

Re: How to use JSL to split a contiguous binary file into segments in bytes?

There are only two choices. BlobPeek() and LoadTextfile(... , BLOB( ReadOffsetFromBegin(), ReadLength() ) ).

Using BlobPeek multiple times is faster than calling LoadTextfile multiple times.

 

What efficiency concern do you have? How big is the blob? How slow is it?

Craige
lala
Level VIII

Re: How to use JSL to split a contiguous binary file into segments in bytes?

Thanks!

Well, it looks like it can only be done in a circular way.
There are many such files that need to be written to the JMP table.
Want to increase speed.
I wrote JSL

b = Load Text File( ……|| "abs.spr", blob() );
s = Length( b ) / 12;
ar = [];
ar = J( s, 5, . );
For( k = 1, k <= s, k++,
	a = Blob Peek( b, (k - 1) * 12, 12 );
	ar[k, 3] = Blob To Matrix( a, "int", 4, "little", 8 )[1, 1];
	ar[k, 4] = Blob To Matrix( a, "int", 4, "little", 8 )[1, 2];
	ar[k, 5] = Blob To Matrix( a, "float", 4, "little", 8 )[1, 3];
);

If it is able to implement segmentation
Does this code increase speed?

lala
Level VIII

Re: How to use JSL to split a contiguous binary file into segments in bytes?

If the binary can be segmented after reading, can the following JSL be used?

  • Read the whole b directly, without looping:

	ar[0, 3] = Blob To Matrix( b, "int", 4, "little", 8 )[0, 1];
	ar[0, 4] = Blob To Matrix( b, "int", 4, "little", 8 )[0, 2];
	ar[0, 5] = Blob To Matrix( b, "float", 4, "little", 8 )[0, 3];
  • Thanks!