need help String.SplitPath

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • GoOgLe
    Forum Member
    • Mar 2007
    • 452

    need help String.SplitPath

    i wanna show only name and extension or just name !!!!

    Code:
    myDocsFolder = Shell.GetFolder(SHF_MYDOCUMENTS);
    Folder.Create(myDocsFolder.."\\Addons");
    
    tblMenu = Application.GetMenu();
    local nNewitem = Table.Count(tblMenu)+1;
    tblMenu[nNewitem] ={};
    tblMenu[nNewitem].Text = "&Addons";
    tblMenu[nNewitem].ID = 1000;
    tblMenu[nNewitem].Checked = false;
    tblMenu[nNewitem].Enabled = true;
    tblMenu[nNewitem].SubMenu = {};
    
    local tFiles = File.Find(myDocsFolder.."\\Addons", "*.exe");
    if (tFiles) then
    for j,Path in tFiles do
    FileParts = String.SplitPath(Path);
    tFiles_File = FileParts.Filename..FileParts.Extension;
    end
    local x = 0;
    for x = 1,Table.Count(tFiles) do
    	tblMenu[nNewitem].SubMenu[x] = {};
    	tblMenu[nNewitem].SubMenu[x].Text = tFiles[x];
    	tblMenu[nNewitem].SubMenu[x].ID = 1000+x;
    	tblMenu[nNewitem].SubMenu[x].Checked = false;
    	tblMenu[nNewitem].SubMenu[x].Enabled = true;
    end
    Application.SetMenu(tblMenu);
    else
    end
  • rexzooly
    No longer a forum member
    • Jul 2007
    • 1512

    #2
    Originally posted by GoOgLe View Post
    i wanna show only name and extension or just name !!!!

    Code:
    myDocsFolder = Shell.GetFolder(SHF_MYDOCUMENTS);
    Folder.Create(myDocsFolder.."\\Addons");
    
    tblMenu = Application.GetMenu();
    local nNewitem = Table.Count(tblMenu)+1;
    tblMenu[nNewitem] ={};
    tblMenu[nNewitem].Text = "&Addons";
    tblMenu[nNewitem].ID = 1000;
    tblMenu[nNewitem].Checked = false;
    tblMenu[nNewitem].Enabled = true;
    tblMenu[nNewitem].SubMenu = {};
    
    local tFiles = File.Find(myDocsFolder.."\\Addons", "*.exe");
    if (tFiles) then
    for j,Path in tFiles do
    FileParts = String.SplitPath(Path);
    tFiles_File = FileParts.Filename..FileParts.Extension;
    end
    local x = 0;
    for x = 1,Table.Count(tFiles) do
    	tblMenu[nNewitem].SubMenu[x] = {};
    	tblMenu[nNewitem].SubMenu[x].Text = tFiles[x];
    	tblMenu[nNewitem].SubMenu[x].ID = 1000+x;
    	tblMenu[nNewitem].SubMenu[x].Checked = false;
    	tblMenu[nNewitem].SubMenu[x].Enabled = true;
    end
    Application.SetMenu(tblMenu);
    else
    end
    try the string

    here is what the help file says one it:
    Code:
    Debug.ShowWindow(true);     --Shows the debug window.
    path_parts = String.SplitPath("C:\\MyFolder1\\MyFolder2\\myfile.exe");
    Debug.Print(path_parts.Drive.."\r\n");
    Debug.Print(path_parts.Folder.."\r\n");
    Debug.Print(path_parts.Filename.."\r\n");
    Debug.Print(path_parts.Extension.."\r\n");

    Comment

    • GoOgLe
      Forum Member
      • Mar 2007
      • 452

      #3
      thanks rexzooly but i dont want to show debug window...

      Comment

      • rexzooly
        No longer a forum member
        • Jul 2007
        • 1512

        #4
        Originally posted by GoOgLe View Post
        thanks rexzooly but i dont want to show debug window...
        just take that out of the code


        ////EDITE

        path_parts = String.SplitPath("C:\\MyFolder1\\MyFolder2\\myfile .exe");

        sFilename = path_parts.Filename.path_parts.Extension

        try that

        but from what i can see you already have this on your code ???
        Last edited by rexzooly; 03-24-2008, 03:57 AM.

        Comment

        • GoOgLe
          Forum Member
          • Mar 2007
          • 452

          #5
          i tried it m8... it doesnt work !!!

          Comment

          • Esfahan
            Forum Member
            • Oct 2007
            • 233

            #6
            edit this example for yourself:
            path_parts = String.SplitPath("C:\\myfile.exe");
            name_ext=(path_parts.Filename..path_parts.Extensio n)

            Imprtant :
            1- no space in Extension word . when i paste it in here , it convert!
            2-yuo can replace a variable in ("C:\\myfile.exe");!!!!!!!
            Last edited by Esfahan; 03-24-2008, 07:29 AM.

            Comment

            • GoOgLe
              Forum Member
              • Mar 2007
              • 452

              #7
              still the same... i see the whole path !!!

              Code:
              myDocsFolder = Shell.GetFolder(SHF_MYDOCUMENTS);
              Folder.Create(myDocsFolder.."\\Addons");
              
              tblMenu = Application.GetMenu();
              local nNewitem = Table.Count(tblMenu)+1;
              tblMenu[nNewitem] ={};
              tblMenu[nNewitem].Text = "&Addons";
              tblMenu[nNewitem].ID = 1000;
              tblMenu[nNewitem].Checked = false;
              tblMenu[nNewitem].Enabled = true;
              tblMenu[nNewitem].SubMenu = {};
              
              local tFiles = File.Find(myDocsFolder.."\\Addons", "*.exe");
              if (tFiles) then
              path_parts = String.SplitPath(myDocsFolder.."\\Addons", "*.exe");
              name_ext=(path_parts.Filename..path_parts.Extension)
              local x = 0;
              for x = 1,Table.Count(tFiles) do
              	tblMenu[nNewitem].SubMenu[x] = {};
              	tblMenu[nNewitem].SubMenu[x].Text = tFiles[x];
              	tblMenu[nNewitem].SubMenu[x].ID = 1000+x;
              	tblMenu[nNewitem].SubMenu[x].Checked = false;
              	tblMenu[nNewitem].SubMenu[x].Enabled = true;
              end
              
              Application.SetMenu(tblMenu);
              
              else
              end

              Comment

              • RizlaUK
                Indigo Rose Customer
                • May 2006
                • 5552

                #8
                RTFM RTFM RTFM RTFM

                its showing the full path coz you are telling it to

                change:
                Code:
                	tblMenu[nNewitem].SubMenu[x].Text = tFiles[x];

                to:
                Code:
                	tblMenu[nNewitem].SubMenu[x].Text = path_parts.Filename;
                also your split function needs to be inside the for loop
                Embrace change in your life, you never know, it could all work out for the best

                Comment

                • GoOgLe
                  Forum Member
                  • Mar 2007
                  • 452

                  #9
                  now i have 2 Addons item in the menu instead of exe files....

                  Code:
                  myDocsFolder = Shell.GetFolder(SHF_MYDOCUMENTS);
                  Folder.Create(myDocsFolder.."\\Addons");
                  
                  tblMenu = Application.GetMenu();
                  local nNewitem = Table.Count(tblMenu)+1;
                  tblMenu[nNewitem] ={};
                  tblMenu[nNewitem].Text = "&Addons";
                  tblMenu[nNewitem].ID = 1000;
                  tblMenu[nNewitem].Checked = false;
                  tblMenu[nNewitem].Enabled = true;
                  tblMenu[nNewitem].SubMenu = {};
                  
                  local tFiles = File.Find(myDocsFolder.."\\Addons", "*.exe");
                  if (tFiles) then
                  path_parts = String.SplitPath(myDocsFolder.."\\Addons", "*.exe");
                  name_ext=(path_parts.Filename..path_parts.Extension)
                  local x = 0;
                  for x = 1,Table.Count(tFiles) do
                  	tblMenu[nNewitem].SubMenu[x] = {};
                  	tblMenu[nNewitem].SubMenu[x].Text = path_parts.Filename;
                  	tblMenu[nNewitem].SubMenu[x].ID = 1000+x;
                  	tblMenu[nNewitem].SubMenu[x].Checked = false;
                  	tblMenu[nNewitem].SubMenu[x].Enabled = true;
                  end
                  
                  Application.SetMenu(tblMenu);
                  
                  else
                  end
                  Last edited by GoOgLe; 03-24-2008, 09:56 AM.

                  Comment

                  Working...
                  X