Author Topic: Workaround with errors  (Read 17929 times)

avantuser1114

  • Active Member
  • ***
  • Posts: 121
    • View Profile
Workaround with errors
« on: March 26, 2013, 07:45:38 »
      I made a workaround that lets me navigate as if there's a 'Computer' virtual folder. That is, I can go from Drive C to other Drives and vice versa using only the four arrow keys;left arrow key for going up (going to the parent) and right arrow key for going down(going to the focused subfolder).I'm comfortable with using just these four for navigation.
     What I did is I made folders named 'Local Disk (C)', 'Local Disk (D)'...etc in my Drive (E). I named others as 'Removable Disk (H)' and so on for external storage devices, then I made two user defined commands that do the going up and going down functions and assigned the previously mentioned keys to them. The 'go up' UDC checks if the current path is a root("C:\", "D:\"..etc). If it is, it goes to Drive (E) where the folders 'Local Disk (C)'...etc are..if not, it just simply goes to the parent of the current folder. The 'go down' UDC checks if the name of the folder in focus is the same with the folders I made in Drive (E). If it happens to be the same with one of them, it goes to the drive that corresponds to the name of the folder (that is, it goes to "C:\" if the folder's name is "Local Disk (C)"). If they aren't the same, it just opens the current focused folder. Obviously, this only works with the hotkeys I used. Using 'Enter' or the mouse will not yield the same result.
     Unfortunately, there are some issues that I'm experiencing with the scripts I made. They're not that significant but if there are ways to avoid
them then I'll gladly try..so I want the scripts checked and any helpful idea and/or suggestion is welcome...
   BTW, these scripts also feature calculation of subfolders' sizes of the destination folder...
   I don't know why but I thought that to include '\' in a string you should write "\\". In my case, when I wrote "C:\\" to mean C:\, it didn't work
    the result was C:\\. So I just used "C:\" for C:\..the scripts are as follows..
     
Note: The comments in the scripts aren't included in the actual code
      I'm using Commander Style Look and Feel so entering a folder won't select anything and calculate folder sizes will work with all the
      folders in the current path.

Go Up:
Code: [Select]
    //Stop current background process
    MC.RunUserCmd ID=1f0dd40bcbe544ae882ee46bf77c115b;
   
    @var $path = GetSourcePath();
    @var $roots[] = {"C:\", "D:\", "E:\", "F:\", "G:\", "H:\", "I:\", "J:\", "K:\", "L:\"};
    @var $isroot = 0;
    @var $i;
    for ($i = 0; $i < 10; $i++)
    {   
        @var $str = $roots[$i];
                                         
        if (StrIsEqual($path, $str))
        {   
            $isroot = 1;
            break;     
        }
    }                                                     
    //if current path is a root, then go to "E:\"
    if ($isroot == 1)
    {
        MC.Explorer.Goto SOURCE="E:\";
    }
    //else go to the parent folder
    else
    {   
        //Go to parent folder
        MC.RunCmd ID=ExplorerPanel.41052;
    }   
    //Refresh
    MC.RunCmd ID=ExplorerPanel.41060;
    //Calculate folders' sizes
    MC.RunCmd ID=ExplorerPanel.51010;
                                                                 
Go Down:   
    //Stop current background process
    MC.RunUserCmd ID=1f0dd40bcbe544ae882ee46bf77c115b;
   
    @var $folder = GetSourceFocusPath();
    @var $links[] = {"E:\Local Disk (C)", "E:\Local Disk (D)", "E:\Local Disk (E)", "E:\Local Disk (F)", "E:\Local DVD RW Drive (G)", "E:\Removable Disk (H)", "E:\Removable Disk (I)", "E:\Removable Disk (J)", "E:\Removable Disk (K)", "E:\Removable Disk (L)"};
    @var $roots[] = {"C:\", "D:\", "E:\", "F:\", "G:\", "H:\", "I:\", "J:\", "K:\", "L:\"};
    @var $i;                         
   
    for ($i = 0; $i < 10; $i++)
    {
        @var $str = $links[$i];
       
        //if folder's name is Local Disk (C)...etc.., set $folder to corresponding root (C:\ for Local Disk (C), D:\ for Local Disk (D)..etc)
        if (StrIsEqual($folder, $str))
        {
            $folder = $roots[$i];
            break;
        }
    }                               
    //Open path $folder
    MC.Explorer.Goto SOURCE={$folder}
    //Refresh
    MC.RunCmd ID=ExplorerPanel.41060;
    //Calculate Folders' Sizes
    MC.RunCmd ID=ExplorerPanel.51010
   
Issues:

    1) Some icons aren't properly displayed except after refresh or going back to the containing folder.
       Using the mouse, this problem doesn't exist. I thought it was because of the 'Refresh' so I removed it and tried.
       The result was the same so it isn't the culprit.
    2) If the same paths are displayed on the left and right panels, if you'll go down then go up (or go up then go down)
        the target panel will be refreshed but the sizes being displayed in the source panel won't be displayed (most of the
        time, and I believe this is because of the Refresh command. It affects not only the source panel but also the target).
        They'll only be displayed after you go up or go down again..I'm using refresh because if I won't, previous sizes of the
        folders will be displayed until the current calculate folders size process completes. I want to see the size column being
        populated in action and while calculation is in progress I prefer to see blank on the size column rather than the previously
        calculated size.
    3) Just a clarification, copy, move and delete functions aren't background processes right?I tried copying and navigating but the
       copying process didn't stop so I assume that they aren't background processes. If so, then I'll need to remove the 'stop background
       processes part' since I only intended to stop the background process made by visiting the previous folder so as to avoid performance
        issues.
    4) 'Remember selected files/folders when changing path' doesn't work except for root directories. Upon entering a directory I've previously
        visited, the focus goes to the top. It doesn't goes back to the focused file/folder before.         

avantuser1114

  • Active Member
  • ***
  • Posts: 121
    • View Profile
Re: Workaround with errors
« Reply #1 on: March 27, 2013, 00:50:59 »
-It seems that the cause of problem with the display of icons is the calculation of sizes..there isn't enough time to process the icons since MC   needs to immediately calculate the sizes..after removing it, the icons were properly displayed..'sleep' command seems to be helpful here..I added Sleep(5) before the command for calculation of sizes and it produced a better result(just kind of acceptable but not very good)..

-As for 'Remember selected files/folders when changing path' problem, it seems that it is because of the refresh command..both refresh(flush cache and the other one) seem to remove the selected files/folders from MC's 'memory' so the focus doesn't go to where it's supposed to be..