Qbasicnews.com
January 26, 2021, 08:21:19 AM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
Back to Qbasicnews.com
|
QB Online Help
|
FAQ
|
Chat
|
All Basic Code
|
QB Knowledge Base
Home
Help
Search
Login
Register
Qbasicnews.com
>
Qbasic "like" compilers/interpreters
>
FB Discussion & Programming Help
>
What the heck is up with BINARY file i/o?
Pages: [
1
]
« previous
next »
Print
Author
Topic: What the heck is up with BINARY file i/o? (Read 6248 times)
Zack
*/-\*
Posts: 3974
What the heck is up with BINARY file i/o?
«
on:
April 11, 2007, 07:34:03 PM »
I want to make a program, very basic, that will XOR the first byte in a file with a code, and replace that byte with the new character.
Code:
dim as string infile
input "infile: ",infile
dim as ubyte code
input "code:",code
open infile for binary as #1
dim as ubyte temp,c
get #1,1,temp
c=temp xor code
put #1,1,temp xor code
close #1
It simply doesn't work. It ruins the file, adding extra characters and changing the size of the file. Any insight?
Logged
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
DrV
Na_th_an
Posts: 1553
What the heck is up with BINARY file i/o?
«
Reply #1 on:
April 11, 2007, 09:19:17 PM »
The expression 'temp xor code' that you are using in the PUT statement is evaluated in a full 32-bit integer. Cast to a UByte or do it in a temporary variable to get the right results.
Logged
Zack
*/-\*
Posts: 3974
What the heck is up with BINARY file i/o?
«
Reply #2 on:
April 12, 2007, 12:24:57 AM »
Thanks, it works. Funny, I tried that with the c=... line, but I forgot to use c instead in the PUT statement.
Logged
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Forum has moved
-----------------------------
=> Forum has moved
-----------------------------
QbasicNews.Com
-----------------------------
=> QB/FB News
=> Site/Forum Issues
=> Challenges
-----------------------------
QBasic
-----------------------------
=> QB Discussion & Programming Help
=> QB Projects
-----------------------------
Qbasic "like" compilers/interpreters
-----------------------------
=> General QB "like"
=> QB64
=> FB Discussion & Programming Help
===> FB Projects
===> FB Documentation
-----------------------------
General
-----------------------------
=> General/Misc
===> Art & Music
===> General Programming
Loading...