Results 1 to 9 of 9

Thread: string replacement problem **RESOLVED**

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Resolved 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.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: dglienna - please help again

    Here is my code

    VB Code:
    1. Private Sub Command2_Click()
    2. Dim f1 As Integer, xmlpath As String, songpath As String, mp3path As String, f2 As Integer, i As Integer, pos As Integer
    3.     Dim Artist As String, SongName As String, artname As String, fname As String, MyPath As String
    4.  
    5.     Dim mytag As Boolean
    6.    mp3path = "C:\mgamerz\my_mp3s\"
    7.    xmlpath = "C:\mgamerz\"
    8.  
    9.  
    10.      
    11.      SongName = Dir(mp3path & "\*.mp3")
    12.      fname = mp3path & SongName
    13.      
    14.             With Form4
    15.    
    16.     While Not Len(SongName) = 0
    17.        
    18. '        Artist = GetMP3Tag(fname)
    19.                 If Not i = 0 Then
    20.                     Load .Label1(i): Load .Text1(i)
    21.                     .Label1(i).Top = .Label1(i - 1).Top + 350
    22.                     .Text1(i).Top = .Text1(i - 1).Top + 350
    23.                     .Label1(i).Visible = True: .Text1(i).Visible = True
    24.                    
    25.                 End If
    26.                
    27.                 .Label1(i) = SongName
    28.                 mytag = GetMP3Tag(fname)
    29.                 .Text1(i) = RTrim(MP3Info.sArtist)
    30.                      
    31.  
    32.         SongName = Dir
    33.              fname = mp3path & SongName
    34.  
    35.         i = i + 1
    36.    
    37.     Wend
    38.                 .Height = .Text1(.Text1.Count - 1).Top + 1600
    39.                 .TAG = mp3path
    40.                 MDIForm1.Caption = "You must close this form before continuing"
    41.                 .Show
    42. '                .WindowState = 2
    43.             End With
    44.     TAG = "wait"
    45.     While TAG = "wait"
    46.     DoEvents
    47.     Wend
    48.    
    49.      
    50.    i = 1
    51.      f2 = FreeFile
    52.     Open mp3path & "mp3.txt" For Output As #f2
    53.      f1 = FreeFile
    54.      
    55.     Open xmlpath & "audiolist.xml" For Output As #f1
    56.    
    57.    
    58.     Print #f1, "<?xml version=""1.0""?>"
    59.     Print #f1, "<songs>"
    60.     SongName = Dir(mp3path & "\*.mp3")
    61.     i = 1
    62.     While Not Len(SongName) = 0
    63.        
    64.         ' if you can return the name of the artist you put the code in here
    65.  
    66.                mytag = GetMP3Tag(mp3path & SongName)
    67.              'pos = InStr(mytag, "\")
    68.              mytag = Replace(mytag, "\", "/")
    69. Do While InStr(mytag, " ")
    70.   mytag = Replace(mytag, " ", "")
    71. Loop
    72.  
    73.              Artist = RTrim(MP3Info.sArtist)
    74.              If Len(Artist) = 0 Then Artist = "UNKOWN"
    75.                  
    76.                  
    77.               MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath) + 1)) & " " & SongName
    78.        
    79.              MyPath = Replace(MyPath, "\", "/")
    80.              
    81.  
    82.            MyPath = Replace(MyPath, " ", "", 1, 1)
    83.        songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """/> "
    84.        
    85.         Print #f1, songpath
    86.         Print #f2, SongName
    87.         Sleep 100
    88.         SongName = Dir
    89.    
    90.     Wend
    91.  
    92.     Print #f1, "</songs>"
    93. Close
    94.  
    95. End Sub

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: dglienna - please help again

    This image ma help to explain what I mean
    Attached Files Attached Files

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: dglienna - please help again

    Looks like we are adding the space right here:

    VB Code:
    1. MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath) + 1)) & [B]" " &[/B] SongName

    try this to fix it.

    VB Code:
    1. MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath) + 1)) &  SongName


    let me know if it works.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    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>

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: dglienna - please help again

    I don't remember why we did this, but we put the slash at the end:
    VB Code:
    1. songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """/[B]>[/B] "

    to remove it, change to this:

    VB Code:
    1. songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """> "

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    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

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: dglienna - please help again

    This one I did in the IDE. It should be correct, just replace this line:


    VB Code:
    1. 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
  •  



Click Here to Expand Forum to Full Width