Author
Topic: Why does DelChars not work here? (Read 375 times)

I wrote a program where it reads from a textfile until it gets to a certain line which contains one of twelve possible strings. Four of those strings have a comma in it. This comma annoys me because I want to write down the exact line into a csv file in the next step. If I tell the programm to write down the read line my string will not appear in one, but two cells in excel, which is understandable as I work with comma-seperated-values...

I had two ideas: one was to delete the comma out of my string (this would be fine for me), but DelChars(Zeile,','); wouldn't work for me (Zeile is the name of my string, the line i read from my textfile)... I don't know why...then I tried the following:

(Zeile ='4-2-4-0 Falsche Neun');//this were the twelve possible strings. This works fine so far... if I try to writeln(csv,Zeile) then my string will be in two cells when there is a comma in my string...

So now I didnt want to writeln(csv,Zeile); and instead told the program to write an individual string (without commas) for each string... strangely this doesn't work, I still get the strings with commas in two cells as if I still used writeln(csv,Zeile);...

Does anyone have an idea what I could do?And could someone explain me why DelChars doesn't work here in the first place (or how I could make it work)?

You don't show the code using DelChars that does not give you the expected result.However, no doubt bytebites has divined at least one error in your algorithm.Try a variation of this, which successfully removes commas for me:

And why does my second idea not work at all? I told the programm that if it reaches a certain string in my textfile, it should write down another string... Still I get the string that the programm read instead of my string allthough I never told it to write down the textfile-string...

So in my csv file there should be '4-3-3 Halb offensiv + Konter' in a single cell.If i open the file then it has '4-3-3 Halb offensiv' in one cell and ' Konter' (with a space before the K)... Why isn't there the string '4-3-3 Halb offensiv + Konter' in one cell instead?

I am dumb, my code worked just as it should with the second idea, I just looked at the wrong part. I had two strings which might have commas, and I only fixed it for the second string in my program but forgot the first string