[futurebasic] Re: [FB] ASCII Text Not Being Print#ed??

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2001 : Group Archive : Group : All Groups

From: Ken Shmidheiser <k.shmidheiser@...>
Date: Thu, 20 Dec 2001 08:50:30 -0500
Responding to Jeff, Alain wrote:

>  > Can anyone ansewer my original question?
>  >
>  > Hi,
>  >
>  > Do these two functions work with the entire ASCII character set?
>[barring any
>  > known bugs in FB]
>  >           READ#1, rectRecord$;1
>  >           PRINT#2, rectRecord$;
>  >
>
>I would say yes (try this in the Console):

I have modified Alain's code

1.) So it will run on Jeff's version of FB^3
2.) To better return what characters it is reading

Best,

Ken

p.s. Watch for lost underscores such as "SYSTEM(_aplVol)" which
should have an underscore before "aplVol"

'--------- BEGIN FB^3 CODE ----------

LOCAL FN SaveFile( fName$, vRef% )
DIM i      AS INTEGER
DIM theStr AS STR255

DEF OPEN "TEXT"
OPEN "O",1,fName$,,vRef%
FOR i = 0 TO 255
theStr = CHR$(i)
         //WRITE#1, theStr;1
PRINT#1, theStr;
NEXT
CLOSE #1

END FN

LOCAL FN ReadCharacter( c AS INT, i AS INT )

SELECT CASE c
CASE 0 : PRINT c;". "; "Null"
CASE 1 : PRINT c;". "; "Home (Start of header)"
CASE 2 : PRINT c;". "; "ctrl-b (Start of Tx)"
CASE 3 : PRINT c;". "; "Enter (End of Tx)"
CASE 4 : PRINT c;". "; "End"
CASE 5 : PRINT c;". "; "Help"
CASE 6 : PRINT c;". "; "ctrl-f"
CASE 7 : PRINT c;". "; "Bell (ctrl-g)"
CASE 8 : PRINT c;". "; "Delete or Backspace""
CASE 9 : PRINT c;". "; "Tab"
CASE 10 : PRINT c;". "; "Line feed (ctrl-j)"
CASE 11 : PRINT c;". "; "Page"
CASE 12 : PRINT c;". "; "Page down"
CASE 13 : PRINT c;". "; "Carriage return"
CASE 14 : PRINT c;". "; "ctrl-n"
CASE 15 : PRINT c;". "; "ctrl-o"
CASE 16 : PRINT c;". "; "F-Keys"
CASE 17 : PRINT c;". "; "ctrl-q"
CASE 18 : PRINT c;". "; "ctrl-r"
CASE 19 : PRINT c;". "; "ctrl-s"
CASE 20 : PRINT c;". "; "ctrl-t"
CASE 21 : PRINT c;". "; "ctrl-u"
CASE 22 : PRINT c;". "; "ctrl-v"
CASE 23 : PRINT c;". "; "ctrl-w"
CASE 24 : PRINT c;". "; "ctrl-x"
CASE 25 : PRINT c;". "; "ctrl-y"
CASE 26 : PRINT c;". "; "ctrl-x"
CASE 27 : PRINT c;". "; "Escape"
CASE 28 : PRINT c;". "; "Left arrow"
CASE 29 : PRINT c;". "; "Right arrow"
CASE 30 : PRINT c;". "; "Up arrow" 
CASE 31 : PRINT c;". "; "Down arrow" 
CASE 32 : PRINT c;". "; "Space"
CASE Else : PRINT c;". "; CHR$(i)
END SELECT

END FN

LOCAL FN ReadFile( fName$, vRef% )
DIM i      AS INTEGER
DIM c      AS INTEGER
DIM theStr AS STR255

OPEN "I",1,fName$,,vRef%
FOR i = 0 TO 255
READ#1, theStr;1
c = ASC(theStr)
FN ReadCharacter( c, i )
NEXT
CLOSE #1

END FN

FN SaveFile("Test",SYSTEM(_aplVol))
FN ReadFile("Test",SYSTEM(_aplVol))

'--------- END CODE -----------