Reading ASCII FILES

Anything QL Software or Programming Related.
Post Reply
mhanias
Brittle Membrane
Posts: 105
Joined: Mon Jul 11, 2011 10:12 pm

Reading ASCII FILES

Post by mhanias »

I have create the xor ascii file
0 0 0
1 0 1
0 1 1
1 1 0
with note pad (windows )and saved it as txt file. I try to read with qpc2 from dos2_ device
input#4 X(i),y(i),z(i) but it inputs the firts column only. How can I make it input by rows?


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Reading ASCII FILES

Post by RWAP »

The spaces are probably the problem....

The statement -

Code: Select all

input#4 X(i),y(i),z(i) 
is trying to fetch 3 lines of numbers

The first three lines you have are invalid numbers after the first column, as a space cannot be converted to a number.

You need to use:

Code: Select all

OPEN #4,'dos2_xor.txt'
i=1
REPeat loop
IF EOF(#4) EXIT loop
INPUT #4, a$
x(i)=a$(1)
y(i)=a$(3)
z(i)=a$(5)
i=i+1
END REPeat loop
CLOSE #4


Post Reply