RTrim/Concatenatate problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shredder249
    New Member
    • Jan 2008
    • 22

    #1

    RTrim/Concatenatate problem

    Hi,

    I have a program which extracts 30 characters from a specific point in a file and performs an rtrim function on it to remove any spaces on the right of the text. After this a concatenate function adds a folder path before the extracted text and a ".mp3" extension after the extracted text thus creating a full filepath. A working example of this process would be: extracted text = "song 1 ". Text rtrimmed = "song 1". Text concatenated = "C:\windows \" + "song 1" + ".mp3". Filepath formed = "C:\windows\son g 1.mp3".

    Problem: if the 30 character extract ends in something other then a space the whole process works fine. However if there is one space or more at the end of the extract the rtrim function has no effect on the text. Further to this, after the concatenation function the ".mp3" isn't added. I cannot understand why this happens. Help?
  • smartchap
    New Member
    • Dec 2007
    • 236

    #2
    I think it must work. But if not working may be there is a problem / bug in ur program. If u post ur code with the file from where u are extracting the text it can be checked and advised.

    Second, in place of RTrim u may use Right$() function to check the last character in the extracted text. If it is a Space then put the extracted text less one character using Left$() in a new Temp variable. Use it in a Do..Loop unless u find a character other than a Space at right most place of extracted text. After extracting the text (without any space at end of the extracted text) u may add Path & .mp3 in it.

    If any problem please post the code with file.

    Comment

    • shredder249
      New Member
      • Jan 2008
      • 22

      #3
      I tried using the right$() function and it doesn't recognise space as a space.

      I've attached the project folder but it won't let me upload any zipped mp3 files (even tiny ones ~300kb). Any mp3 file can be used as long as it has something in the title field.
      Attached Files

      Comment

      • Stewart Ross
        Recognized Expert Moderator Specialist
        • Feb 2008
        • 2545

        #4
        Hi Shredder249. Haven't tried out your solution on an mp3 file yet, but the most obvious possibility you are overlooking is that the characters concerned are not likely to be spaces at all, but simply Nul characters or the like which look as if they are spaces but which aren't. You are extracting characters from a binary file, after all, not a text file...

        If you have a look at the Ascii codes for what you are taking to be spaces check that these correspond to chr(32), the space character. If they don't, RTrim will not remove them - and invalid characters in your string will undoubtedly affect further concatenation of the file extension onto the string.

        -Stewart

        Comment

        • shredder249
          New Member
          • Jan 2008
          • 22

          #5
          Many thanks both Stewart and smartchap,

          Yeah the things I thought were spaces were ascii 0 (null i think?).

          I added a for loop so if

          asc(right(title ,1)) = 0 then
          title = left(title, len(title)-1)
          else
          exit for
          end if

          the program works perfectly now, thanks again!

          Comment

          • smartchap
            New Member
            • Dec 2007
            • 236

            #6
            That's what I meant. Actually with Right$ function u can find what character it is at the right most place and u can concatenate the string with Left$ function. Ok now the things are solved so no problem.

            Comment

            Working...