Reading file, line by line
Posted
#1
(In Topic #352)
Regular

This file contains this data:
aaaaaaaa
bbbbbb
cccc
dd
And the result that I am getting is :
ddccbbaa
That means, that the line input command is reading all the lines one by one, and storing them in the same variable, without executing the next instructions in the while loop.
Why is this? What am I doing wrong?
Gambas 3.14.2 pi
Posted
Guru

Consider this code: -
aaaaaaaa
bbbbbb
cccc
dd
This may be easier to understand: -
Have a look at the Split command here, Join command http://gambaswiki.org/wiki/comp/gb/string[]/join
String &/ String Concatenate two strings that contain file names. Add a path separator between the two strings if necessary.
Posted
Regular

seany said
…And the result that I am getting is :
ddccbbaa
That means, that the line input command is reading all the lines one by one, and storing them in the same variable, without executing the next instructions in the while loop.
Why is this? What am I doing wrong?
Its because you are using a carriage return (decimal 13) instead of a line feed (decimal 10).
Windows likes CR + LF but Linux likes just LF.
1 guest and 0 members have just viewed this.


