Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 7 of 7

Thread: String Trimming

  1. #1
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014

    String Trimming

    After finding all my folders using the code below:

    result = Folder.Find("AutoPlay\\Plugins", "*", false, nil);
    for index,folder in result do
    folders = ListBox.AddItem("plugs list", folder, folder);
    end

    (Thanks Corey)

    The information is placed into a ListBox as follows:

    AutoPlay\Plugins\ Folder 1
    AutoPlay\Plugins\ Folder 2
    AutoPlay\Plugins\ Folder 3

    I would like to show ONLY the name of the folder it’s self, like this:

    Folder 1
    Folder 2
    Folder 3

    So… I thought using a String.Replace would do the trick but… Again I’m not getting the right combinations. I tried this:

    result = Folder.Find("AutoPlay\\Plugins", "*", false, nil);
    for index,folder in result do
    result = String.Replace("AutoPlay/Plugs/", "AutoPlay", "", false);
    ListBox.AddItem("plugs list", folder, folder);
    end

    But it didn’t work. Perhaps using the variable “result”…
    result = String.Replace("result", "AutoPlay", "", false); NOPE!

    What the heqq is the magic combo? I looked through the help files but I didn’t quite get what I was looking for or didn’t understand perhaps the obvious.

  2. #2
    Join Date
    May 2003
    Posts
    130
    I didn't feel like completely recreating the situation, because of the length of time it would take, but possibly you can try something like this:

    Code:
    pathsplit = String.SplitPath("AutoPlay\\Plugins\\Folder1");
    totalchars = String.Length(pathsplit[2]);
    trimposition = String.ReverseFind(pathsplit[2], "\\\", false);
    trimthis = totalchars - trimposition;
    finaloutput = String.TrimLeft(pathsplit[2], trimthis);
    -- finaloutput should be Folder1

    there's most likely a hundred syntax errors in that, I was just doing a quicky job on it so you can get the jist of the method I'm trying to describe.

    Hope this helps a little.

    -Adam

  3. #3
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014
    Thx element78-
    LOL there MUST be an easier way! I seem to remember Tigg having done this before.

  4. #4
    Join Date
    May 2003
    Posts
    130
    lol, you're probably right. But that's just the first thing that came to mind

  5. #5
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014
    Does anyone know of an easier way?

  6. #6
    Join Date
    Nov 2003
    Location
    Salzburg / Austria
    Posts
    312
    Hi,

    I'm working with string replacement and it works for me

    PHP Code:
    _Searchdir=_SourceFolder.."\\Autoplay\\Plugins";
    FolderList Folder.Find(_Searchdir.."\\""*"falsenil);
    for 
    j in FolderList do
      
    FolderNameString.Replace(FolderList[j], _Searchdir.."\\"""false);
        --
    add the item to the listboxwith the name visible and path as data
      ListBox
    .AddItem("ListBox1"FolderName,FolderList[j]);
    end 

    hope it helps

    Stefan
    Attached Files

  7. #7
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014
    Thx Stefan!
    Looks like it's longer then I had hoped, oh well, kick-in and screaming the whole way! LOL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts