Page 1 of 1

Reading ASCII FILES

Posted: Fri Jan 17, 2014 9:06 pm
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?

Re: Reading ASCII FILES

Posted: Fri Jan 17, 2014 9:30 pm
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