CPCWiki forum

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

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


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 18:58, 28 July 16
Quote from: remax on 18:48, 28 July 16
Hello, i'm using a prog from CPC power to display Ascii files :


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 19:01, 28 July 16
Quote from: Devilmarkus on 18:58, 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 19:42, 28 July 16
Do you tried LINE INPUT? ;)


Title: Re: Displaying an ascii file
Post by: remax on 20:37, 28 July 16
Quote from: Fessor on 19:42, 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 09: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 09: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.
Powered by SMFPacks Menu Editor Mod