Thanks for the feedback, I’ll try to address the issues raised in order.
Maybe I should first say that I think I know where my problem lies - but I don’t yet have a solution.
@WP
I am aware that #13 is a carriage return and that #10 is a line feed and that they are often used together. I had used both in testing but #13 does the job on its own.
I don’t have a problem with the honesty of ‘nonsense’
but in fact re-use of the same variable doesn’t have the impact you suggest since I [save] the result after each use so the existing value is of no consequence. The reason for this (rather than a single string of all values) is because the Data_File is declared as a file of string[20]. I think this is my basic problem so changing the declaration may well be the solution. I did try declaring it as ‘file of string’ but that threw up the error ‘Typed files cannot contain reference-counted types’.
There would be no point in adding the first comma (line 5 of your code) and then removing it later.
I did try ‘writeln’ but got an error at compile time ‘can’t use readln or writeln on a typed file’. That’s why I used ‘write’ and #13.
@lainz
I’ve no idea where you get the idea that CSV is separated by a semi-colon (“;”) it is one of the options in Excel but CSV = Comma Separated Values. I have done some tests (just in case I was mistaken) but there is no doubt that using ‘;’ does not separate the values when imported into Excel, the string all goes into the first column.
@WP
Using tab might be an option but that wouldn’t be a CSV file so would have to be ‘imported’ into Excel using the Get External Data facility (aka the import wizard). Using .TXT does use the import wizard but worse than that it ignores the commas unless you go through the lengthy process of [next][next] etc.
The import wizard does allow you to select which separator should be considered - tab, semi-colon, comma, space or other but a ‘normal’ CSV file is simply ‘opened’ - it even displays the Excel icon as it’s filetype.
As I’ve said, I think my problem is that I used string[20] as the ‘type’ and that is simply collecting the ‘junk’ in memory adjacent to the real data. Why it doesn’t just use the formatted string and leave the rest as spaces or, better still, just trim the string to the characters used I can’t understand so I’ll have to do some more testing.
I also don’t understand why I can’t use writeln or why ‘file of string’ is unacceptable.