cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-327821%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHow%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-327821%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%22Text.blk%22%20is%20a%20binary%20file%20saved%20in%20C%3A%5C%2C%20how%20JSL%20can%20write%2C%20rewrite%2C%20and%20replace%20the%20data%20in%20the%20data%20table.%3CBR%20%2F%3EThe%20following%20code%20is%20the%20VBA%20code%20of%20Excel%2C%20which%20can%20write%20the%20data%20of%20excel%20column%20A%20to%20C%20%3A%5C%3C%2Fimg%3E%20text.blk.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222020-10-29_19-57-29.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-10-29_19-57-29.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-10-29_19-57-29.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F27856i27C1EA371BDA2AB6%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222020-10-29_19-57-29.png%22%20alt%3D%222020-10-29_19-57-29.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ESub%20text()%0A%20%20%20%20Dim%20arr%2C%20I%2C%20filename%20As%20String%2C%20t%20As%20Long%0A%20%20%20filename%20%3D%20%22c%3A%5Ctext.BLK%22%0A%20%20%20%20Open%20filename%20For%20Binary%20As%20%231%3A%20arr%20%3D%20Range(%22a2%3Aa%22%20%26amp%3B%20Cells(Rows.Count%2C%20%22a%22).End(3).Row)%0A%20%20%20%20For%20r%20%3D%201%20To%20UBound(arr)%0A%20%20%20%20%20%20%20%20If%20Left(arr(r%2C%201)%2C%202)%20%3D%20%2212%22%20Then%20arr(r%2C%201)%20%3D%201000000%20%2B%20arr(r%2C%201)%0A%20%20%20%20Next%0A%20%20%20%20For%20I%20%3D%201%20To%20UBound(arr%2C%201)%0A%20%20%20%20%20%20%20%20If%20IsNumeric(arr(I%2C%201))%20Then%20Put%20%231%2C%20%2C%20CLng(arr(I%2C%201))%0A%20%20%20%20Next%0A%20%20%20%20Close%20%231%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-327821%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EAutomation%20and%20Scripting%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-328608%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-328608%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CUL%3E%3CLI%3E%3CP%20class%3D%22src%22%3EJMP%20is%20powerful%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222020-11-01_10-30-10.png%22%20style%3D%22width%3A%20889px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-11-01_10-30-10.png%22%20style%3D%22width%3A%20889px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-11-01_10-30-10.png%22%20style%3D%22width%3A%20889px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F27964i9CD5B609762CD8B2%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222020-11-01_10-30-10.png%22%20alt%3D%222020-11-01_10-30-10.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-328606%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-328606%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EThank%20Craige!%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22transSent%22%3EThat%20will%20do.%3C%2FSPAN%3E%3CSPAN%20class%3D%22transSent%22%3EIt%20can%20be%20done%20directly%20with%20JSL%20in%20the%20future.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22transSent%22%3EI%20tried%3A%20the%20specific%20data%20still%20needs%20%2B1000000.%3C%2FSPAN%3E%3C%2FP%3E%3CUL%3E%3CLI%3E%3CP%20class%3D%22src%22%3EThe%20BLK%20file%20is%20read%20by%20other%20software.%3C%2FP%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22transSent%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222020-11-01_07-36-52.png%22%20style%3D%22width%3A%20202px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-11-01_07-36-52.png%22%20style%3D%22width%3A%20202px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-11-01_07-36-52.png%22%20style%3D%22width%3A%20202px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F27963i6A7BFFA932DB4EEC%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222020-11-01_07-36-52.png%22%20alt%3D%222020-11-01_07-36-52.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-328520%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-328520%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EYou'll%20still%20need%20to%20add%201%2C000%2C000%20if%20that's%20what%20you%20need%2C%20but%20something%20like%20this%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%20%22%24desktop%2F1T.jmp%22%20)%3B%0Afilename%20%3D%20Save%20Text%20File(%0A%20%22%24temp%2Fdeleteme.blk%22%2C%0A%20Matrix%20To%20Blob(%20dt%3Acode%20%26lt%3B%26lt%3B%20getvalues%2C%20%22int%22%2C%204%2C%20%22little%22%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EAnyone%20following%20along%3A%3C%2FP%3E%3CUL%3E%3CLI%3Ethe%20LoadTextFile%20and%20SaveTextFile%20functions%20normally%20work%20with%20character%20string%20text%20data%20and%20will%20possibly%20change%20the%20CRLF%20endings%2C%20add%20UNICODE%20Byte%20Order%20Mark%2C%20and%20can't%20deal%20with%20the%20ASCII%20NUL%20character.%20But%2C%20when%20used%20with%20JMP's%20BLOB%20type%2C%20the%20file%20is%20read%2Fwritten%20with%20just%20the%20binary%20data.%3C%2FLI%3E%3CLI%3EBlobToMatrix%20and%20MatrixToBlob%20are%20inverse%20functions.%20They%20treat%20all%20the%20array%20elements%20or%20all%20the%20blob%20elements%20as%201%2C%202%2C%204%2C%20or%208%20byte%20chunks.%20They%20also%20can%20make%20the%20array%20elements%20(which%20are%20always%20double%20precision%208%20byte%20numbers)%20be%20signed%20or%20unsigned%20integers%20or%20floating%20point%20numbers%20in%20the%20blob.%20And%20they%20can%20handle%20big-%20vs%20little-endian%20representations%20in%20the%20blob.%20And%20BlobToMatrix%20has%20an%20extra%20argument%20to%20make%20multiple%20columns%20in%20the%20matrix.%3C%2FLI%3E%3CLI%3EYou%20might%20want%20to%20use%20BlobPeek%20to%20deal%20with%20sections%20of%20the%20binary%20data%20that%20are%20not%20uniform%20chunk%20sizes%2C%20and%20the%20%7C%7C%20concatenate%20operator%20to%20join%20blobs%20back%20together.%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-328452%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-328452%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CSPAN%3EPlease%20download%20the%20%221T.blk%22%20file%20again%2C%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Esee%20its%20structure%2C%20and%20how%20to%20save%20the%204%20rows%20in%20the%20table%20in%20the%20form%20of%20%221T.blk%22.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20Craige!%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222020-10-31_08-06-24.png%22%20style%3D%22width%3A%20948px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-10-31_08-06-24.png%22%20style%3D%22width%3A%20948px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-10-31_08-06-24.png%22%20style%3D%22width%3A%20948px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F27954iAB0ECA46E453D25D%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222020-10-31_08-06-24.png%22%20alt%3D%222020-10-31_08-06-24.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-328450%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-328450%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EThank%20Craige!%3CBR%20%2F%3EI%20see.%20It's%20the%20wrong%20direction.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EInstead%20of%20writing%20%221T.blk%22%20data%20to%20the%20table%2C%20save%20the%20data%20in%20the%20table%20as%20%221T.blk%22.%3CBR%20%2F%3EI%20give%20%221T.%20BLK%20%22%2C%20just%20to%20indicate%20the%20file%20form%20in%20which%20the%20data%20in%20the%20table%20will%20be%20saved.%3CBR%20%2F%3EI%20tried%20writing%20JSL%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222020-10-31_07-59-01.png%22%20style%3D%22width%3A%20886px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-10-31_07-59-01.png%22%20style%3D%22width%3A%20886px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-10-31_07-59-01.png%22%20style%3D%22width%3A%20886px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F27953iC0D2AB957AEC0DE0%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222020-10-31_07-59-01.png%22%20alt%3D%222020-10-31_07-59-01.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CBR%20%2F%3EBut%20I%20still%20don't%20know%20how%20to%20save%20the%20data%20in%20the%20table%20in%20the%20form%20of%20the%20graph.The%20saved%20file%20suffix%20name%20is%20not%20the%20key.%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Current%20Data%20Table()%3B%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%20%22new%22%2C%20formula(%20If(%20Left(%20Char(%20%3Acode%20)%2C%202%20)%20%3D%3D%20%2212%22%2C%201000000%20%2B%20%3Acode%2C%20%3Acode%20)%20)%20)%3B%0Adt%20%26lt%3B%26lt%3B%20run%20formulas%3B%0AColumn(%20%22new%22%20)%20%26lt%3B%26lt%3B%20deleteFormula%3B%0AWait(%200%20)%3B%0Amx%20%3D%20dt%20%26lt%3B%26lt%3B%20GetAsMatrix(%20%7B2%7D%20)%3B%0A%0Amx%20%26lt%3B%26lt%3B%20Save(%20%22C%3A%5C1T.BLK%22%20)%3B%2F%2FThe%20saved%20file%20suffix%20name%20is%20not%20the%20key.%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-328263%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-328263%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EI%20don't%20know%20anything%20about%20BLK%20files%20and%20very%20little%20about%20VBA%2C%20but%20it%20*might*%20be%20the%20case%20that%20a%20BLK%20file%20is%20really%20simple%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eb%20%3D%20loadTextFile(%22z%3A%2Ftext.blk%22%2Cblob())%3B%20%2F%2F%20load%20your%20file%0A%0Amat%20%3D%20blobtomatrix(b%2C%22int%22%2C4%2C%22little%22)%3B%20%2F%2F%20operate%20on%20matrix%20data%0A%0A%2F*%3A%0A%0A%5B1123029%2C%201113555%2C%201110044%2C%201113038%2C%201113581%2C%201128108%2C%201110073%2C%201113509%2C%201113521%2C%0A1113037%2C%201113576%2C%201113586%2C%201113580%2C%201113035%2C%201113027%2C%201113592%2C%201113599%2C%201110059%2C%0A1113556%2C%201113565%2C%201113595%2C%201113543%2C%201113600%2C%201113520%2C%201113575%2C%201110072%2C%201113571%2C%0A1110067%2C%201113029%2C%201113582%2C%201113601%2C%201113011%2C%201110058%2C%201113034%2C%201113561%2C%201113593%2C%0A1113550%2C%201113008%2C%201110066%2C%201113548%2C%201113583%2C%201113039%2C%201113562%2C%201113537%2C%201113577%2C%0A1113527%2C%201113587%2C%201113541%2C%201113596%2C%201110053%2C%201113578%2C%201113526%2C%201113566%2C%201113591%2C%0A1113585%2C%201113589%2C%201110074%2C%201113572%2C%201110060%2C%201113590%2C%201113568%2C%201113021%2C%20113555%2C%0A113038%5D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EIf%20you%20were%20expecting%2064%20integers%20in%20the%20earlier%20file%2C%20that's%20all%20it%20contains.%20I%20have%20no%20idea%20what%20order%20(row%20major%3F%20column%20major%3F%20other%3F)%20the%20values%20are%20in.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-328230%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-328230%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EThank%20Craige!%3CBR%20%2F%3EI%20have%20learned%20your%20JSL%20code%2C%20I%20have%20no%20cleavage.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20was%20so%20careless%20that%20I%20uploaded%20the%20%22text.blk%22%20file%20by%20mistake.I'm%20sorry.%3C%2FP%3E%3CP%3EThe%20original%20upload%20was%20not%20corresponding%20to%20the%20four%20data%20in%20the%20table.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EMy%20requirement%20is%20to%20output%20the%204%20data%20points%20of%20the%20table%20as%20a%20new%20file%20as%20*.blk%20file.The%20original%20BLK%20file%20was%20deleted%20before%20the%20output.%3CBR%20%2F%3EI%20re-uploaded%20the%20specific%20VBA%20Excel%20file%2C%20opened%20it%20and%20clicked%20the%20%22BLK%22%20button%2C%20which%20would%20generate%20a%20%221t.%20BLK%22%20file%20in%20the%20path%20of%20%22C%3A%5C%22.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222020-10-30_23-02-21.png%22%20style%3D%22width%3A%20677px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-10-30_23-02-21.png%22%20style%3D%22width%3A%20677px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-10-30_23-02-21.png%22%20style%3D%22width%3A%20677px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F27927i07BBC9BC28BCD930%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222020-10-30_23-02-21.png%22%20alt%3D%222020-10-30_23-02-21.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CBR%20%2F%3EThe%20request%20how%20to%20write%20JSL%20code%20can%20achieve%20this%20function%20of%20VBA%3A%20the%20four%20data%20in%20the%20table%20is%20directly%20generated%20and%20VBA%20generated%20BLK%20file%20exactly%20the%20same.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-328120%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-328120%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eb%20%3D%20loadTextFile(%22z%3A%2Ftext.blk%22%2Cblob())%3B%20%2F%2F%20load%20your%20file%0A%0Ahex%20%3D%20hex(b)%3B%20%2F%2F%20operate%20on%20hex%20data%0Ashow(hex)%3B%20%2F%2F%20the%20binary%20data%20is%20now%20character%20data%0Alast4hex%20%3D%20right(hex%2C8)%3B%20%2F%2F%20two%20hex%20characters%20per%20byte%0A%0Alast4blob%20%3D%20blobpeek(b%2Clength(b)-4%2C4)%3B%20%2F%2F%20operate%20on%20blob%20data%0Ashow(hex(last4blob))%3B%20%2F%2F%20same%20data%20as%20above%0A%0Amat%20%3D%20blobtomatrix(b%2C%22int%22%2C4%2C%22big%22)%3B%20%2F%2F%20operate%20on%20matrix%20data%0Ashow(mat%5Bnrows(mat)%5D%2Chextonumber(last4hex)%2Cblobtomatrix(last4blob%2C%22int%22%2C4%2C%22big%22))%3B%20%2F%2F%20all%20the%20same%0A%0A%2F%2F%20change%20the%20hex%20data%20(1-based%20offset%20to%20substr%20function%2C%20doubled.%20this%20is%20why%20programmers%20count%20from%200.)%0Ashow(substr(hex%2C5%2C4))%3B%20%2F%2F%20the%203rd%20and%204th%20bytes%2C%20%221100%22.%20lets%20change%20them%20to%20%22FE23%22%20%0Ahex%20%3D%20substr(hex%2C1%2C4)%20%7C%7C%20%22FE23%22%20%7C%7C%20substr(hex%2C9)%3B%0Ashow(hex)%3B%0Af1%3Dsavetextfile(%22%24temp%2Ftext1.blk%22%2C%20hextoblob(hex))%3B%20%2F%2F%20convert%20hex%20to%20blob%20before%20saving%0A%0A%2F%2F%20do%20the%20same%20with%20a%20blob%20(0-based%20offset%20to%20blobpeek%20function)%0Af2%3Dsavetextfile(%22%24temp%2Ftext2.blk%22%2Cblobpeek(b%2C0%2C2)%7C%7Chextoblob(%22FE23%22)%7C%7Cblobpeek(b%2C4))%3B%0A%0A%2F%2F%20do%20the%20same%20with%20a%20matrix.%20the%20matrix%20above%20is%204-bytes%2Felement%2C%20lets%20use%201%20instead%0Amat%20%3D%20blobtomatrix(b%2C%22int%22%2C1%2C%22big%22)%3B%0Amat%5B3%5D%3Dhextonumber(%22FE%22)%3B%20%2F%2F%201-based%20matrix%20index%0Amat%5B4%5D%3Dhextonumber(%2223%22)%3B%0Af3%3Dsavetextfile(%22%24temp%2Ftext3.blk%22%2Cmatrixtoblob(mat%2C%22int%22%2C1%2C%22big%22))%3B%0A%0A%2F%2F%20check%20our%20work%3A%0Ab1%3Dloadtextfile(f1%2Cblob())%3B%0Ab2%3Dloadtextfile(f2%2Cblob())%3B%0Ab3%3Dloadtextfile(f3%2Cblob())%3B%0A%0Aif(b1%3D%3Db2%3D%3Db3%2C%20write(%22%5C!nmatch%2C%20as%20expected%22)%2C%20write(%22%5C!nERROR%22))%3B%0A%0A%2F%2F%20this%20shows%20the%20changed%20data%20%0Ashow(shortesteditscript(hex(b)%2Chex(b1)))%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-328112%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-328112%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EI%20tried%20to%20write%20it%2C%20but%20the%20key%20points%20remained%20unclear.%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222020-10-30_08-11-42.png%22%20style%3D%22width%3A%20899px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-10-30_08-11-42.png%22%20style%3D%22width%3A%20899px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222020-10-30_08-11-42.png%22%20style%3D%22width%3A%20899px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F27905i65B5ADF97368A06F%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222020-10-30_08-11-42.png%22%20alt%3D%222020-10-30_08-11-42.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-328110%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-328110%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EThank%20Craige!%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ECan%20these%20operations%20be%20done%20directly%20using%20JSL%3F%3CBR%20%2F%3EI%20was%20wondering%20if%20you%20could%20write%20the%20first%20method%20as%20JSL.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20Experts!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-327884%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-327884%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EUse%20loadTextFile%20with%20the%20blob%20option%20(it%20ignores%20the%20file%20type).%20Then%2C%20depending%20what%20you%20want%20to%20do%2C%20one%20of%20these%3A%3C%2FP%3E%3COL%3E%3CLI%3Econvert%20the%20blob%20to%20hex%2C%20manipulate%20the%20hex%20(twice%20as%20many%20characters%20as%20binary%20bytes)%2C%20convert%20the%20hex%20back%20to%20blob%3C%2FLI%3E%3CLI%3Euse%20blobPeek()%20to%20segment%20the%20blob%2C%20then%20reassemble%20the%20blob%20with%20your%20data%20injected%3C%2FLI%3E%3CLI%3Euse%20blobToMatrix%20to%20extract%20the%20data%20and%20matrixToBlob%20to%20reassemble%20the%20blob.%20This%20is%20perhaps%20the%20most%20powerful%2C%20fastest%2C%20and%20either%20easiest%20or%20hardest%20to%20use%2C%20depending%20on%20the%20file.%20The%20blobToMatrix%20function%20will%20decompose%20the%20entire%20blob%20(which%20might%20be%20from%202%2C%20above)%20into%201%2C%202%2C%204%2C%20or%208%20byte%20chunks%20in%20a%20matrix%3B%20the%20chunks%20can%20be%20big-%20or%20little-%20endian%20integers%20or%20floats.%20(If%20the%20data%20was%20a%20stereo%20wav%20file%2C%20you%20could%20make%20a%202-column%20matrix%20of%2016-bit%20integer%20samples%2C%20for%20example.)%3C%2FLI%3E%3C%2FOL%3E%3CP%3EFinally%2C%20save%20the%20blob%20with%20saveTextFile.%20It%20does%20not%20need%20a%20blob%20option%20because%20you%20either%20give%20it%20a%20blob%20or%20a%20text%20string%20to%20save.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-327840%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20How%20can%20JSL%20modify%20data%20in%20a%20table%20directly%20to%20a%20specified%20binary%20file%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-327840%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Etext.BLK%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ecode%3CBR%20%2F%3E123029%3CBR%20%2F%3E128108%3CBR%20%2F%3E113555%3CBR%20%2F%3E113038%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
lwx228
Level VIII

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 :\ text.blk.

2020-10-29_19-57-29.png

 

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
Craige_Hales
Super User

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
lwx228
Level VIII

Re: How can JSL modify data in a table directly to a specified binary file?

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.

 

2020-11-01_07-36-52.png

lwx228
Level VIII

Re: How can JSL modify data in a table directly to a specified binary file?

  • JMP is powerful

  • 2020-11-01_10-30-10.png

Recommended Articles