Dear All
I have a funny situation that has developed with Pos. In a graphical programme I want to use it multiple times to find #10. I am using a string that has received multiple lines of text from memo.text
MemoString := Memo1.Lines.Text;
The actual content is:
Alasdair Roberts/Farewell Sorrow/Farewell Sorrow.mp3
Didgeridoo Dreaming - Aboriginal Spiritual Music 1/The First Kangaroo.mp3
Donald Fagen/The Nightfly/Track 02.mp3
Agua de Pena\ROMARIAS\BAILE DA NOITE.mp3
Using Pos and searching on the #10 that must be present at the end of each line I can find and extract the first line of text
Tag := Pos(#10, MemoString); // Tag is 0 at start. Pos returns zero if not found
path2MP3 := Copy(MemoString, 1, (Tag-1));
I concat an existing string with path2MP3
path2Musicfolder := concat(path2Musicfolder, path2MP3);
I have checked the output using a label caption and the content is correct
Label3.Caption := path2Musicfolder;
Output of:
“/media/stephanos/Sport Go/Music/Alasdair Roberts/Farewell Sorrow/Farewell Sorrow.mp3”
I became suspicious that I was not able to use a third party tool called BASS to retrieve the play time of this MP3 file. So I did some checking. I added a ‘[’ to the beginning of the file and a ‘]’ to the end and output to a label caption again. The output was over 2 lines
Line 1: [/media/stephanos/Sport Go/Music/Alasdair Roberts/Farewell Sorrow/Farewell Sorrow.mp3
Line 2: ]
Simple I thought, I still have a #10 at the end, and I can remove it, just as I did with MemoString.
First find the position of #10 in the string. I tried 2 methods and got a return of zero for both.
Label3.Caption := IntToStr(Pos(#10, path2Musicfolder));
and
Tag := Pos(#10, path2Musicfolder);
Label3.Caption := IntToStr(Tag);
This is very peculiar. Pos could not find the #10 that has to be present. It must be present because I had output over 2 lines.
Any help appreciated