- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How can JSL modify data in a table directly to a specified binary file?
"Text.blk" is a binary file saved in C:\, how JSL can write, rewrite, and replace the data in the data table.
The following code is the VBA code of Excel, which can write the data of excel column A to C
Sub text()
Dim arr, I, filename As String, t As Long
filename = "c:\text.BLK"
Open filename For Binary As #1: arr = Range("a2:a" & Cells(Rows.Count, "a").End(3).Row)
For r = 1 To UBound(arr)
If Left(arr(r, 1), 2) = "12" Then arr(r, 1) = 1000000 + arr(r, 1)
Next
For I = 1 To UBound(arr, 1)
If IsNumeric(arr(I, 1)) Then Put #1, , CLng(arr(I, 1))
Next
Close #1
End Sub
12 REPLIES 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How can JSL modify data in a table directly to a specified binary file?
You'll still need to add 1,000,000 if that's what you need, but something like this
dt = Open( "$desktop/1T.jmp" );
filename = Save Text File(
"$temp/deleteme.blk",
Matrix To Blob( dt:code << getvalues, "int", 4, "little" )
);
Anyone following along:
- the LoadTextFile and SaveTextFile functions normally work with character string text data and will possibly change the CRLF endings, add UNICODE Byte Order Mark, and can't deal with the ASCII NUL character. But, when used with JMP's BLOB type, the file is read/written with just the binary data.
- BlobToMatrix and MatrixToBlob are inverse functions. They treat all the array elements or all the blob elements as 1, 2, 4, or 8 byte chunks. They also can make the array elements (which are always double precision 8 byte numbers) be signed or unsigned integers or floating point numbers in the blob. And they can handle big- vs little-endian representations in the blob. And BlobToMatrix has an extra argument to make multiple columns in the matrix.
- You might want to use BlobPeek to deal with sections of the binary data that are not uniform chunk sizes, and the || concatenate operator to join blobs back together.
Craige
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How can JSL modify data in a table directly to a specified binary file?
Created:
Oct 31, 2020 07:45 PM
| Last Modified: Oct 31, 2020 4:49 PM
(1044 views)
| Posted in reply to message from Craige_Hales 10-31-2020
Thank Craige!
That will do.It can be done directly with JSL in the future.
I tried: the specific data still needs +1000000.
The BLK file is read by other software.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How can JSL modify data in a table directly to a specified binary file?
JMP is powerful
- « Previous
-
- 1
- 2
- Next »