Is it possible to make a binary (or hex) read?
No native way but this will work.
file$ = "hexdump.kbs" # replace with your file name
temp$ = "tempfile.txt" # temporary file name
# this statement converts binary file to a hex dump of one byte
# per line
# used LINUX command line hex dump program
# if Windows you will need to find a hex dump program
# and change the command accordingly
system "xxd -p -c 1 " + file$ + " > " + temp$
while not eof
#read 2 digit hex number (one byte)
hex$ = read()
#delete temporary file
by zombiepigman96, Sunday, August 26, 2012, 16:29 (1707 days ago)
I am still learning this language, what does the $ do?
The $ on the end of the variables temp$, hex$ and file$ tell BASIC256 that these variables contain "string" values and not numeric values. A string is a chunk of text that contains letters, numbers, and special characters.
by Gordon, Wednesday, October 17, 2012, 21:56 (1655 days ago)
May I suggest adding real binary-safe file handling (preferably before 1.0)?
I am working on a CipherSaber implementation, but the lack of this is a real show-stopper. Moreover, I think that the current state of affairs is kind of inconsistent -- reads can only be performed in "records" (so to speak) whereas writes are not bound by this (yes, I am aware of the corner cases and workarounds, but I figure it is a very bad thing in a primarily educational product).
Having the record-oriented I/O is not necessarily a bad thing, but a bit more consistency there would be preferred (don't know how, though). Having binary I/O is a must IMHO.
OK. You asked for it - real work not done :) must play :)
READBYTE, WRITEBYTE and OPENB have been committed to SVN.
b = readbyte(filenum)
writebyte filenum, b
and openb is same as open but binary safe in Windows (does not matter in LINUX)
It is a bit slow but this is BASIC. :) What do you think???
by Gordon, Thursday, October 18, 2012, 12:07 (1655 days ago)
This also seems to be working well, thank you for the prompt support!
Now... bitwise XOR, please... :) (I'm discovering things needed as I progress :)
Try the following...
xr = (p&(~q))|((~p)&q)
XOR is already an operator so you have to call the function something else.