Posts: 354
Threads: 28
Joined: Feb 2004
I know what the problem is now. The last variable is being read as part of the second to last variable. So, I made the string the last variable, the problem is gone. However, how can I avoid this problem, say if there is a string variable after another a string variable.
Not yet Snake! It's not over yet!
Posts: 544
Threads: 27
Joined: Jan 2005
Just make sure you have a comma (,) immediately after each string variable, as for this data file containing 5 digits and 2 strings:
1 2 3 4A, 5 6B, 7
For numbers, a space is OK, as is a comma. So, this data could also be written as:
1,2,3,4A,5,6B,7
To write this file in QuickBASIC, you would use:
OPEN "Test1.txt" FOR OUTPUT AS #1
PRINT #1, 1; 2; 3;"4A"; ","; 5; "6B"; ","; 7
CLOSE #1
which will write a file that looks like this:
1 2 3 4A , 5 6B , 7
As a matter of principal and consistancy, you might just write ALL your data files with comma separators, thus:
OPEN "Test1.txt" FOR OUTPUT AS #1
PRINT #1, 1; ","; 2;","; 3;",";"4A"; ","; 5;","; "6B"; ","; 7
CLOSE #1
This will write a file that looks like this:
1 , 2 , 3 , 4A , 5 , 6B , 7
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Posts: 354
Threads: 28
Joined: Feb 2004
OK, thanks for all the help.
Not yet Snake! It's not over yet!