WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Number Conversion

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Retrieve Ascii Characters from a Hex Dump

Keywords: 	  hex dump ascii convert characters

Here is a winbatch program for retrieving plain ascii text file from hexa dump file.
;==================================================
; Retrieve plain text from hexa dump
; Winbatch program  for decoding in ascii
; an hexa file.
;==================================================
;

; EXAMPLE ( hexa data from Visual C++ watch memory window ):
;
; 0013D185  23 17 00 74 6F 74 61 6C 68 6F 74 6B 65 79 73 3D 32 30 0D  #..totalhotkeys=20.
; 0013D198  68 6F 74 6B 65 79 3D 41 72 72 44 69 6D 65 6E 73 69 6F 6E  hotkey=ArrDimension
; 0013D1AB  28 74 6F 74 61 6C 68 6F 74 6B 65 79 73 29 0D 46 6F 72 20  (totalhotkeys).For 
;
; launching from command line: prog_winbatch   
; in example : prog_winbatch  1 20
;
; Author : Delgove jean-jacques 
; Version 1.0
; Date : 15 march 2002


if ( %param0% != 3) then
	message("ERROR",strcat("Usage res1.wbt   "))
	exit
endif
file="%param1%"
deb="%param2%"
fin="%param3%"



;param1 fichier à analyser
;param2 début des colonnes à prendre en compte
;param3 fin des colonnes

if ( ! isInt(deb) ) then
	message("ERROR","Second parameter must be numeric")
	exit
endif
if ( ! isInt(fin) ) then
	message("ERROR","Third parameter must be numeric")
	exit
endif

if ( FileExist(file) == 0) then
	message("INFO",strcat("File ",file,"does not exist"))
	exit
endif
if ( FileExist(file) == 2) then
	message("INFO",strcat("Cannot read  ",file))
	exit
endif
in=FileOpen(file,"READ")
if( in == 0) then
	message("INFO",strcat("Cannot read  ",file))
	exit
endif
out=FileOpen("result.txt","WRITE")
if( out == 0) then
	message("INFO",strcat("Cannot write  to file : result.txt"))
	exit
endif
msg=""
while @TRUE
	line=""
	ErrorMode(@OFF)
	line=FileRead(in)
	ErrorMode(@CANCEL)
	if( line == "*EOF*" ) then break

	if( line == "") then break

	array1=Arrayize(line," ")
	le=ArrInfo (array1, 1)
	if( le > fin) then le=fin

	if( le < deb) then continue
 
	for i=deb to le 
		b=""
		ErrorMode(@OFF)
		b=array1[i]
		ErrorMode(@CANCEL)
		if (b == "") then continue

		if ( Strlen(b) == 2)then
			k=StrSub(b,1,1)
			l=StrSub(b,2,1)
			k1=0
			if( k == "A" || k == "a") then k1=10
			if( k == "B" || k == "b") then k1=11
			if( k == "C" || k == "c") then k1=12
			if( k == "D" || k == "d") then k1=13
			if( k == "E" || k == "e") then k1=14
			if( k == "F" || k == "f") then k1=15
			if(k1 == 0) then k1=k+0

			l1=0
			if( l == "A" || l == "a") then l1=10
			if( l == "B" || l == "b") then l1=11
			if( l == "C" || l == "c") then l1=12
			if( l == "D" || l == "d") then l1=13
			if( l == "E" || l == "e") then l1=14
			if( l == "F" || l == "f") then l1=15
			if(l1 == 0) then l1=l+0
				
			j=k1*16 + l1
			if ( j == 13) then
				FileWrite(out,msg)
				msg=""
			else
				msg=strcat(msg,Num2Char(j))
			endif
		endif
	next
	drop(array1)	
endwhile
FileWrite(out,msg)
FileClose(in)
FileClose(out)

Article ID:   W15220
File Created: 2002:09:05:13:50:42
Last Updated: 2002:09:05:13:50:42