Bitwise IO: Difference between revisions
Replace deprecated functions
(Added FreeBASIC) |
(Replace deprecated functions) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 26:
<syntaxhighlight lang="11l">T BitWriter
accumulator = 0
bcount = 0
F (fname)
.out = File(fname,
F _writebit(bit)
Line 61:
F (fname)
.input = File(fname
F _readbit()
I .bcount == 0
V a = .input.read_bytes(at_most' 1)
I !a.empty
.accumulator = a[0]
Line 100:
12345abcde
</pre>
=={{header|6502 Assembly}}==
===Storing Bytes As ASCII Strings===
Line 3,485 ⟶ 3,486:
}</syntaxhighlight>
=={{header|Seed7}}==
The Seed7 library [
several functions to do bitwise I/O. Bitwise data can be read from (or written to) a string or a file.
The direction of bits can be from LSB (least significant bit) to MSB (most significant bit) or vice versa.
In the program below the functions
[
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
Line 3,516 ⟶ 3,517:
const proc: finishWriteAscii (inout file: outFile, inout integer: bitPos) is func
begin
putBitsMsb(outFile, bitPos, 0, 7); # Write a terminating NUL char.
write(outFile, chr(ord(outFile.bufferChar)));
end func;
const
result
var string: stri is "";
Line 3,530 ⟶ 3,527:
var char: ch is ' ';
begin
while
ch := chr(
if
stri &:= ch;
end if;
Line 3,542 ⟶ 3,539:
var file: aFile is STD_NULL;
var integer: bitPos is 0;
var msbBitStream: aBitStream is msbBitStream.value;
begin
aFile :=
initWriteAscii(aFile, bitPos);
writeAscii(aFile, bitPos, "Hello, Rosetta Code!");
finishWriteAscii(aFile, bitPos);
seek(aFile, 1);
writeln(literal(readAscii(
end func;</syntaxhighlight>
Line 3,556 ⟶ 3,554:
"Hello, Rosetta Code!"
</pre>
=={{header|Tcl}}==
<syntaxhighlight lang="tcl">package require Tcl 8.5
|