主题:改进版!dos下看文件(支持汉字)需要hzk16、asc16支持
DECLARE FUNCTION bin2binstr$ (b%)
DIM hz%(16), bstr1$(16), bstr$(16), asci%(8)
SCREEN 12
LOCATE 1, 1
INPUT "Input FileName:", f$
CLS
OPEN "hzk16" FOR BINARY AS #1
OPEN f$ FOR INPUT AS #2
OPEN "asc16" FOR BINARY AS #3
WHILE NOT EOF(2)
a$ = INPUT$(1, #2)
a = ASC(a$)
WHILE a < &H80
IF a = 10 THEN
y = y + 19
ELSE
IF a = 13 THEN
x = 0
ELSE
c = a * 16
SEEK #3, c
FOR i = 1 TO 8
GET #3, , asci%(i)
NEXT i
FOR i = 1 TO 8
bstr1$(i) = bin2binstr$(asci%(i))
bstr$(i * 2) = LEFT$(bstr1$(i), 8)
bstr$(i * 2 - 1) = RIGHT$(bstr1$(i), 8)
NEXT i
IF x >= 640 THEN y = y + 19: x = 0
IF y >= 475 THEN SLEEP: x = 0: y = 0: CLS
FOR i = 1 TO 16
FOR j = 1 TO 8
IF MID$(bstr$(i), j, 1) = "1" THEN
PSET (j + x, i + y)
ELSE
PRESET (j + x, i + y)
END IF
NEXT j
NEXT i
x = x + 8
END IF
END IF
IF EOF(2) THEN SLEEP: CLOSE #1, #2,#3: END
a$ = INPUT$(1, #2)
a = ASC(a$)
WEND
b$ = INPUT$(1, #2): b = ASC(b$)
a = (a - &HA1) * 94
b = b - &HA1
c = (a + b) * 32 + 1
SEEK #1, c
FOR i = 1 TO 16
GET #1, , hz%(i)
NEXT i
FOR i = 1 TO 16
bstr1$(i) = bin2binstr$(hz%(i))
bstr$(i) = RIGHT$(bstr1$(i), 8) + LEFT$(bstr1$(i), 8)
NEXT i
IF x >= 632 THEN y = y + 19: x = 0
IF y >= 475 THEN SLEEP: x = 0: y = 0: CLS
FOR i = 1 TO 16
FOR j = 1 TO 16
IF MID$(bstr$(i), j, 1) = "1" THEN
PSET (j + x, i + y)
ELSE
PRESET (j + x, i + y)
END IF
NEXT j
NEXT i
x = x + 16
WEND
CLOSE #1, #2,#3
SLEEP
END
FUNCTION bin2binstr$ (b%) STATIC
t$ = STRING$(16, "0")
IF b% THEN
IF b% < 0 THEN
MID$(t$, 1, 1) = "1"
END IF
mask% = &H4000
FOR i% = 2 TO 16
IF b% AND mask% THEN
MID$(t$, i%, 1) = "1"
END IF
mask% = mask% / 2
NEXT i%
END IF
bin2binstr$ = t$
END FUNCTION
DIM hz%(16), bstr1$(16), bstr$(16), asci%(8)
SCREEN 12
LOCATE 1, 1
INPUT "Input FileName:", f$
CLS
OPEN "hzk16" FOR BINARY AS #1
OPEN f$ FOR INPUT AS #2
OPEN "asc16" FOR BINARY AS #3
WHILE NOT EOF(2)
a$ = INPUT$(1, #2)
a = ASC(a$)
WHILE a < &H80
IF a = 10 THEN
y = y + 19
ELSE
IF a = 13 THEN
x = 0
ELSE
c = a * 16
SEEK #3, c
FOR i = 1 TO 8
GET #3, , asci%(i)
NEXT i
FOR i = 1 TO 8
bstr1$(i) = bin2binstr$(asci%(i))
bstr$(i * 2) = LEFT$(bstr1$(i), 8)
bstr$(i * 2 - 1) = RIGHT$(bstr1$(i), 8)
NEXT i
IF x >= 640 THEN y = y + 19: x = 0
IF y >= 475 THEN SLEEP: x = 0: y = 0: CLS
FOR i = 1 TO 16
FOR j = 1 TO 8
IF MID$(bstr$(i), j, 1) = "1" THEN
PSET (j + x, i + y)
ELSE
PRESET (j + x, i + y)
END IF
NEXT j
NEXT i
x = x + 8
END IF
END IF
IF EOF(2) THEN SLEEP: CLOSE #1, #2,#3: END
a$ = INPUT$(1, #2)
a = ASC(a$)
WEND
b$ = INPUT$(1, #2): b = ASC(b$)
a = (a - &HA1) * 94
b = b - &HA1
c = (a + b) * 32 + 1
SEEK #1, c
FOR i = 1 TO 16
GET #1, , hz%(i)
NEXT i
FOR i = 1 TO 16
bstr1$(i) = bin2binstr$(hz%(i))
bstr$(i) = RIGHT$(bstr1$(i), 8) + LEFT$(bstr1$(i), 8)
NEXT i
IF x >= 632 THEN y = y + 19: x = 0
IF y >= 475 THEN SLEEP: x = 0: y = 0: CLS
FOR i = 1 TO 16
FOR j = 1 TO 16
IF MID$(bstr$(i), j, 1) = "1" THEN
PSET (j + x, i + y)
ELSE
PRESET (j + x, i + y)
END IF
NEXT j
NEXT i
x = x + 16
WEND
CLOSE #1, #2,#3
SLEEP
END
FUNCTION bin2binstr$ (b%) STATIC
t$ = STRING$(16, "0")
IF b% THEN
IF b% < 0 THEN
MID$(t$, 1, 1) = "1"
END IF
mask% = &H4000
FOR i% = 2 TO 16
IF b% AND mask% THEN
MID$(t$, i%, 1) = "1"
END IF
mask% = mask% / 2
NEXT i%
END IF
bin2binstr$ = t$
END FUNCTION