File: readbinary_test.kbs

package info (click to toggle)
basic256 2.0.99.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,888 kB
  • sloc: cpp: 17,185; yacc: 4,025; lex: 1,466; java: 1,091; sh: 39; xml: 33; makefile: 20
file content (33 lines) | stat: -rw-r--r-- 537 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
openb 1,"readbinary_test.data"
for t = 0 to 255
   writebyte 1,t
next t
close 1


openb 1,"readbinary_test.data"
n = 0
s$ = ""
while not eof(1)
   c = readbyte(1)
   if n%8 = 0 then
      print " " + s$
      s$ = ""
      print hex$(n\256) + hex$(n%256) + "  ";
   end if
   print hex$(c) + " ";
   if c < 32 or c > 127 then
      s$ = s$ + "."
   else
      s$ = s$ + chr(c)
   end if
   n = n + 1
end while
print " " + s$
close 1
end

function hex$(n)
   x$ = "0123456789abcdef"
   hex$=mid(x$,n\16+1,1)+mid(x$,n%16+1,1)
end function