Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hex file to text
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01251476
Message ID:
01251499
Vues:
16
Hi mark,

>I have a program BinToAScii that will show actual file contents if I open a binary file with it. Is something like this possible to accomplish in Fox?

Something like this?
PROCEDURE HexView
LParameter tcString

	Local lnPos, lnChar, lnCol, lnRow, lcascii
	lnCol = 0
	lnRow = 0
	lcascii = ""
	For lnPos = 1 To Len(tcString)
		If lnCol%16 = 0
			If lnPos > 1
			  ?? "   " + lcascii
			Endif
			? Transform(lnRow,"@0")+" : "
			lnRow = lnRow+16
			lcascii = ""
		Endif
		lnCol = lnCol + 1
		lnChar = Asc(SubStr(tcString,lnPos,1))
		?? RighT(Transform(lnChar,"@0"),2)+" "
		if lnchar >= 32
			lcascii = lcascii + chr(lnchar)
		else
			lcascii = lcascii + "."
		endif
	Endfor
    ?? space((16-len(lcascii))*3)+"   " + lcascii
Call it with
HexView( FileToStr("filename") )
Alternatively, you can use HexEdit.App which comes with VFP.
--
Christof
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform