From: Mark A J. <maj...@ra...> - 2003-05-29 04:09:21
|
All, This is NOT a MAC question, but I have not been able to find help with this on the internet and I thought I'd ask my question here and hopefully someone could answer my question. I am reading binary data from a file in a specific order and then I want to write the data IN BINARY FORM to an output file. [begin code snippet] -------------------- set my_binary_data ""; set in_file_id [ open my_binary_file r ]; set out_file_id [ open my_output_file w ]; loop starts here ... set offset { someplace in the binary file }; seek $in_file_id $offset start; # go to the data in the file binary scan [ $in_file_id 1 ] H2 data_piece; # read binary data in HEX append my_binary_data $data_piece; # appends just read binary # data to what what # previously read and # appended end loop ... puts -nonewline $out_file_id "$my_binary_data"; # write string of extracted # binary data to a file close $in_file_id; close $out_file_id; ------------------- [end code snippet] I am reading the binary data file and extracting the correct data, but when I write the data to a file ... it is being written in ASCII ... NOT in binary ... i.e., if I read '8e' ... I want to write '8e' to my file, but what is happening is ... '3865' is being written to my output file. 38 is ASCII for 8 65 is ASCII for e Any help would be appreciated. I have verified this is happening because I am looking at the file with a BINARY EDITOR. btw, fyi ... I am trying to run this tcl code on a PC running LINUX 8.0. TIA, Mark |