If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!
Moderators: Pete , Mods
Sinuvoid
Veteran
Posts: 155 Joined: Wed Jul 25, 2007 8:20 am
Post
by Sinuvoid » Sat Feb 02, 2008 11:55 pm
How do I open something up in hexadecimal in Qbasic, then edit it?
Im guess it woudl go something like this....
Code: Select all
CLS
OPEN "test.exe" FOR BINARY AS #1
'a for next loop here
INPUT #1, hexnumbers%
CLOSE #1
Mac
Veteran
Posts: 151 Joined: Mon Aug 06, 2007 2:00 pm
Post
by Mac » Sun Feb 03, 2008 1:45 am
Lee wrote: How do I open something up in hexadecimal in Qbasic, then edit it?
Read it
Code: Select all
CLS
PRINT "First 5 characters in test.exe"
PRINT
DIM X AS STRING * 1
OPEN "test.exe" FOR BINARY AS #1
FOR i = 1 TO 5
GET #1, i, X
PRINT ASC(X);
NEXT i
PRINT
CLOSE #1
To write, use PUT.
If you want hex, then convert the ASCII.
Mac
Michael Calkins
Veteran
Posts: 76 Joined: Tue Apr 05, 2005 8:40 pm
Location: Floresville, Texas
Contact:
Post
by Michael Calkins » Mon Mar 24, 2008 1:23 am
hex$(number) converts to hex
val("&h"+text) converst from hex.
you might want to zero pad the hex number
t$=hex$(asciivalue)
if len(t$)<2 then t$="0" + t
or perhaps
t$=string$(2-len(t$),&h30)+t$ 'adaptable to padding to more than 2 places.
Regards,
Michael