Here is a simple macro which converts an entire file from ASCII to "hex".
It is available at ftp.vedit.com/share/bin-hex.vdm.
The opposite macro to convert from hex to ASCII is available at ftp.vedit.com/share/hex-bin.vdm.
(I will try attaching these files to this message too.)
// BIN-HEX.VDM - Convert bytes to ASCII "Hex", similar to hex display mode.
//
// I.e., 0xff ==> "FF " (ASCII) (0x464620).
//
Config(F_OVER_MODE,0) //Turn off overwrite-only mode
if ( Config(F_F_TYPE) < 8) {
#10 = 0 //Flag - text file; don't convert CR+LF
} else {
#10 = Config(F_F_TYPE) //Flag - binary file; convert all chars
}
Begin_Of_File()
while (!At_EOF) {
if (!At_EOL || #10) {
#0 = (Cur_Char & 0xf0) >> 4
#1 = Cur_Char & 0xf
if ( #0 > 9 ) {
#0 = 'A' + (#0 - 10)
} else {
#0 += '0'
}
Ins_Char(#0,OVERWRITE)
if ( #1 > 9 ) {
#1 = 'A' + (#1 - 10)
} else {
#1 += '0'
}
Ins_Char(#1)
Ins_Char(' ')
} else {
Line(1)
}
}
//
// For binary file, add CR+LF at the current record length.
//
Config(F_F_TYPE,0,LOCAL) //Set the new file-type
Begin_of_File()
#11=0
if (#10>0) {
while (! At_EOF) {
Char(#10*3) //Advance past end of record
Ins_Newline(1) //Insert the Newline
#11++
//
// Display progress
//
if ( (#11 % 100)==0) {
Reg_Set(104,"Record # ")
Out_Reg(104,APPEND)
Num_Type(#11,LEFT+NOCR)
Out_Reg(CLEAR)
Message(@104,STATLINE)
}
}
}
(File attachment removed)
|
|