Mar 19th, 2005, 10:11 PM
#1
Thread Starter
Hyperactive Member
string replacement problem **RESOLVED**
Hi you helped me a great deal a few weeks ago with my xml updater. I have a very small query now - what it is is this when my xml is written using this it adds a space before the filename i.e [SPACE]audiolist.xml and this cannot be read by our app. If I remove the space between the slash and the quotation mark I get an unwanted slash.
mp3path = "C:\Program Files\mgamerz\XML Updater\my_mp3s\"
xmlpath = "C:\Program Files\mgamerz\XML Updater\ "
Hope you get what I mean
Thanks in advance
R
Last edited by robvr6; Mar 20th, 2005 at 08:57 PM .
Mar 19th, 2005, 10:51 PM
#2
Re: dglienna - please help again
I don't have the code anymore. Paste in the code concerning the filename.
I don't remember offhand anything other than the path was different in two different spots. You should be able to use the left() function to leave off the rightmost charcter, but if you are getting an extra slash, maybe you should remove the space and the first slash?
Mar 19th, 2005, 11:04 PM
#3
Thread Starter
Hyperactive Member
Re: dglienna - please help again
Here is my code
VB Code:
Private Sub Command2_Click()
Dim f1 As Integer, xmlpath As String, songpath As String, mp3path As String, f2 As Integer, i As Integer, pos As Integer
Dim Artist As String, SongName As String, artname As String, fname As String, MyPath As String
Dim mytag As Boolean
mp3path = "C:\mgamerz\my_mp3s\"
xmlpath = "C:\mgamerz\"
SongName = Dir(mp3path & "\*.mp3")
fname = mp3path & SongName
With Form4
While Not Len(SongName) = 0
' Artist = GetMP3Tag(fname)
If Not i = 0 Then
Load .Label1(i): Load .Text1(i)
.Label1(i).Top = .Label1(i - 1).Top + 350
.Text1(i).Top = .Text1(i - 1).Top + 350
.Label1(i).Visible = True: .Text1(i).Visible = True
End If
.Label1(i) = SongName
mytag = GetMP3Tag(fname)
.Text1(i) = RTrim(MP3Info.sArtist)
SongName = Dir
fname = mp3path & SongName
i = i + 1
Wend
.Height = .Text1(.Text1.Count - 1).Top + 1600
.TAG = mp3path
MDIForm1.Caption = "You must close this form before continuing"
.Show
' .WindowState = 2
End With
TAG = "wait"
While TAG = "wait"
DoEvents
Wend
i = 1
f2 = FreeFile
Open mp3path & "mp3.txt" For Output As #f2
f1 = FreeFile
Open xmlpath & "audiolist.xml" For Output As #f1
Print #f1, "<?xml version=""1.0""?>"
Print #f1, "<songs>"
SongName = Dir(mp3path & "\*.mp3")
i = 1
While Not Len(SongName) = 0
' if you can return the name of the artist you put the code in here
mytag = GetMP3Tag(mp3path & SongName)
'pos = InStr(mytag, "\")
mytag = Replace(mytag, "\", "/")
Do While InStr(mytag, " ")
mytag = Replace(mytag, " ", "")
Loop
Artist = RTrim(MP3Info.sArtist)
If Len(Artist) = 0 Then Artist = "UNKOWN"
MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath) + 1)) & " " & SongName
MyPath = Replace(MyPath, "\", "/")
MyPath = Replace(MyPath, " ", "", 1, 1)
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """/> "
Print #f1, songpath
Print #f2, SongName
Sleep 100
SongName = Dir
Wend
Print #f1, "</songs>"
Close
End Sub
Mar 19th, 2005, 11:05 PM
#4
Thread Starter
Hyperactive Member
Re: dglienna - please help again
This image ma help to explain what I mean
Attached Files
Mar 19th, 2005, 11:30 PM
#5
Re: dglienna - please help again
Looks like we are adding the space right here:
VB Code:
MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath) + 1)) & [B]" " &[/B] SongName
try this to fix it.
VB Code:
MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath) + 1)) & SongName
let me know if it works.
Mar 19th, 2005, 11:48 PM
#6
Thread Starter
Hyperactive Member
Re: dglienna - please help again
now Im getting an extra slash but I need it like this
<song path="my_mp3s/01.mp3" artist="The Worlds Greatest" title="01.mp3"/>
instead of below
<?xml version="1.0"?>
<songs>
<song path="/my_mp3s/01.mp3" artist="The Worlds Greatest" title="01.mp3"/>
<song path="/my_mp3s/02-NeverSay Goodbye.mp3" artist="Hayley Westenra" title="02-Never Say Goodbye.mp3"/>
<song path="/my_mp3s/05- Swamp.mp3" artist="Michael Kamen" title="05 - Swamp.mp3"/>
<song path="/my_mp3s/09- Shoot You Down.mp3" artist="The Stone Roses" title="09 - Shoot You Down.mp3"/>
</songs>
Mar 20th, 2005, 12:03 AM
#7
Re: dglienna - please help again
I don't remember why we did this, but we put the slash at the end:
VB Code:
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """/[B]>[/B] "
to remove it, change to this:
VB Code:
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """> "
Mar 20th, 2005, 12:13 AM
#8
Thread Starter
Hyperactive Member
Re: dglienna - please help again
<song path="/ my_mp3s/01.mp3" artist="The Worlds Greatest" title="01.mp3">
sorry I meant I get a slash wherer it is bold
Mar 20th, 2005, 12:27 AM
#9
Re: dglienna - please help again
This one I did in the IDE. It should be correct, just replace this line:
VB Code:
mypath = Right(mp3path, (Len(mp3path) - Len(xmlpath))) & " " & songname
I moved it all over one character to the right, which should eliminate the "/"
also, change the subject of the first thread. I don't need my username in the forum. plus, others don't like to answer if they see it directed towards someone else. what if I wasn't here tonight? change it to 'string replacement problem'
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width