Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
STEFHOLZ
Level II

Checksum for tables

Hi,

 

I want to create a unit test for a module which manipulates a table at many cells. So I thought to test against a checksum of the table

I could not find a function wich gives you a checksum for a table out-of-the-box.

 

Does anyone have neat idea how to do it?

 

Best regards

Stefan

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Craige_Hales
Staff (Retired)

Re: Checksum for tables

I'd suggest using the BlobMD5 function. You might want to checksum the data inside the table rather than the table's disk image because JMP might add a date to the binary data on disk or even change the format in a future release. The first example is probably NOT what you want for a unit test.

 

// capture the md5 of the data the table saves to disk
Show(
	Hex(/* make it printable */
		Blob MD5(/* get the hash */
			Load Text File(
				"$SAMPLE_DATA/big class.jmp",
				BLOB/* the result is a BLOB, not a string */
			)
		)
	)
);

// capture the md5 of the script that will produce the table
dt = Open( "$SAMPLE_DATA/big class.jmp" );
Show( Hex( Blob MD5( Char To Blob( Char( dt << getscript ) ) ) ) );

// capture the md5 of some numeric columns in the table; avoids numeric to character conversions
Show( Hex( Blob MD5( Matrix To Blob( dt[0, {height, age, weight}], "float", 8, "little" ) ) ) );

// capture the md5 of some mixed columns in the table
Show( Hex( Blob MD5( Char To Blob( Char( dt[0, {name, height, age, weight}] ) ) ) ) );

 

Craige

View solution in original post

1 REPLY 1
Highlighted
Craige_Hales
Staff (Retired)

Re: Checksum for tables

I'd suggest using the BlobMD5 function. You might want to checksum the data inside the table rather than the table's disk image because JMP might add a date to the binary data on disk or even change the format in a future release. The first example is probably NOT what you want for a unit test.

 

// capture the md5 of the data the table saves to disk
Show(
	Hex(/* make it printable */
		Blob MD5(/* get the hash */
			Load Text File(
				"$SAMPLE_DATA/big class.jmp",
				BLOB/* the result is a BLOB, not a string */
			)
		)
	)
);

// capture the md5 of the script that will produce the table
dt = Open( "$SAMPLE_DATA/big class.jmp" );
Show( Hex( Blob MD5( Char To Blob( Char( dt << getscript ) ) ) ) );

// capture the md5 of some numeric columns in the table; avoids numeric to character conversions
Show( Hex( Blob MD5( Matrix To Blob( dt[0, {height, age, weight}], "float", 8, "little" ) ) ) );

// capture the md5 of some mixed columns in the table
Show( Hex( Blob MD5( Char To Blob( Char( dt[0, {name, height, age, weight}] ) ) ) ) );

 

Craige

View solution in original post

Article Labels

    There are no labels assigned to this post.