CPCWiki forum

General Category => Programming => Topic started by: remax on 20:48, 28 July 16

Title: Displaying an ascii file
Post by: remax on 20:48, 28 July 16
Hello, i'm using a prog from CPC power to display Ascii files :

Code: [Select]
MODE 2:OPENIN "fichier.txt":WHILE NOT EOF:INPUT #9,a$:print a$:WEND:CLOSEIN


It works well, except when it must display commas (ascii 44), then it just do a CR...


Is there any way to modify this program to display also commas ?
Title: Re: Displaying an ascii file
Post by: Devilmarkus on 20:58, 28 July 16
Hello, i'm using a prog from CPC power to display Ascii files :

Code: [Select]
MODE 2:OPENIN "fichier.txt":WHILE NOT EOF:INPUT #9,a$:print a$:WEND:CLOSEIN


It works well, except when it must display commas (ascii 44), then it just do a CR...


Is there any way to modify this program to display also commas ?

I once needed the same, then I used a semicolon as comma, and defined new SYMBOL for semicolon....
Title: Re: Displaying an ascii file
Post by: remax on 21:01, 28 July 16
I once needed the same, then I used a semicolon as comma, and defined new SYMBOL for semicolon....

Yeah... dirty but efficient :D

I'll do that if nobody thinks of another solution.
Title: Re: Displaying an ascii file
Post by: Fessor on 21:42, 28 July 16
Do you tried LINE INPUT? ;)


Title: Re: Displaying an ascii file
Post by: remax on 22:37, 28 July 16
Do you tried LINE INPUT? ;)


That was the tidy way, thank you very much !
Title: Re: Displaying an ascii file
Post by: AMSDOS on 11:11, 29 July 16
Sorry if this sounds like a silly question, when an European CPC finds ASCII 44, CR occurs instead of ASCII 13? I'm confused!  ???
Title: Re: Displaying an ascii file
Post by: PulkoMandy on 11:48, 29 July 16
The problem is that INPUT uses the comma as a separator. You can use "INPUT a$,b$" to read two strings at once, for example.
This also work for reading from a file, so you can use it for a kind of structured data (CSV files).


LINE INPUT instead always reads a whole line, so it does not ahve this feature.