|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Parsing string
Hi all
![]() I am a relative novice to Delphi programming and I have come unstuck! I am trying to create a program that will allow me to take a string (an MP3 filename), specify the format it is written in and take the parts of the filename and store them in the ID3 tag of the file. For example, the filename may be as follows: Oasis - Don't Believe the truth - 1 - Turn up the sun And the format would (for my program) %artist - %album - %trackNo - %title What I would like to do is to then take the seperate sections of the filename and store them in the ID3 tag. Saving the ID3 information is not the problem, separating the string is. I could quite easily parse the filename string if I knew the format which it was to come in but that is the problem, I don't know. Could anyone be so kind as to offer some advice as to how I might go about this? Kind regards Stu |
|
#2
|
||||
|
||||
|
You could use Pos() to find the position of '-' in the string and then use Copy() to copy a substring out of a string:
Code:
sStr := 'Oasis - Don''t Believe the truth - 1 - Turn up the sun';
nPos := Pos('-', sStr);
sName := Copy(sStr, 1, nPos - 1);
// Get next part
sStr := Copy(sStr, nPos + 1, 99999);
nPos := Pos('-', sStr);
sAlbum := Copy(sStr, 1, nPos - 1);
// Rinse and repeat
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month |
|
#3
|
|||
|
|||
|
Thank you for your post Scorpions4ever, it looks very ınteresting and could be just want I want/need. I'm currently on holiday at the minute but I wıll have a play with your suggestion when I return.
Thanks very much and I will keep you posted! PS Apologies for any weird characters which may randomly appear. I'm a touch typist who doesn't very well adjust to another keyboard layout (Turkish in this case!). |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Delphi Programming > Parsing string |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|