Multi Commander > Script

Debugger in 4.3 hangs MC on error

(1/4) > >>

Ulfhednar:
I know the debugger is very #beta# right now but thought I'd mention this -

MC 4.3 1691
Playing with the debugger I found it now crashes MC if it encounters a 'serious' syntax error.
Previously hitting 'stop' button & seeing the debugging stopped msg was enough to detach the debugger.
The stop button now stays 'lit' & the debugger must be shut down with X.  MC window hangs with 'not responding' white-out & needs to be closed via X & following crash dialog.

I decided to play with this question to reawaken my script knowledge - http://forum.multicommander.com/forum/index.php/topic,1184.0.html
Adding a folder with date works OK.
Adding time to date creates a crash or a folder called $date. (Obviously I have not given the variables correctly  ::))
 
Adding the time variable seems a potential problem as HH:MM:SS obviously can't be used for a name/path, (:'s), but with or without : I find in calling the FormatTime function I will see the hour but MM for minutes....?  My fault?  [See pic]

It would be interesting to know if a folder name using multiple variables is possible, & how far I am off!  ;)

Using the following

--- Code: ---@var $now = GetTime();
@var $date = FormatDate( "dd-MM-yyyy", $now );
@var $nowLocal = FormatTime( "HHMM", $now);
@var $folder;
@var $FolderBaseName = GetSourcePath();
@var $arr = {"$date", "$nowLocal"};


{
 $folder = $FolderBaseName ^ $arr;
 MC.Filesystem.Makedir PATH="{$folder}"
 }
--- End code ---

Gives \$date  :o
(Debug screen attached)

Mathias (Author):
Strange. It does not crash for me..


You know.. You do not need the extra { }


--- Code: ---$folder = $FolderBaseName ^ $arr;
--- End code ---
Not sure what you think that would do.. $arr is an array, so you append that to a string only the first element is added.

But you do not need the array at all.. just write
$folder = $FolderBaseName ^ $date + " " + $nowLocal;

Also

--- Code: ---@var $nowLocal = FormatTime( "HHMM", $now);
--- End code ---
the format is wrong..  minutes is lower case. "mm"

So you can write it like this.


--- Code: ---@var $now = GetTime();
@var $date = FormatDate( "dd-MM-yyyy" , $now );
@var $time = FormatTime( "HHmm", $now);
@var $folder;
@var $FolderBaseName = GetSourcePath();

 $folder = $FolderBaseName ^ $date + " " +$time;
 MC.Filesystem.Makedir PATH="{$folder}"

--- End code ---

Ulfhednar:
Thanks very much Mathias. 
I recall now you saying something about { } before, I can see the benefits of not needing them all the time. 

I hadn't been able to give the multiple $vars to the  $folder = $FolderBaseName ^ instruction without it crashing MC so
I had begun thinking perhaps multiple variables needed an array in this case - because they made a string....   ??? 

I also wondered how I might define a folder name based on things like filenames, root folder etc not just date & time.  I was wondering about something like this

--- Code: ---@var $arr = PathGetParts( $src_path );
--- End code ---
but instead transposing filename to a new folder & adding date & time.  As the debugger kept hanging I didn't get very far.

The element I definitely didn't think to use was +   ::)  :o
Now you have given me more info I can return to this idea & see if I an make it work.  :)

I intend to keep playing about with MS when time allows as it is a great time saver for simple frequent tasks.
But I imagine by the time I figure it out you will have upgraded it all!  ;D

Mathias (Author):

--- Quote from: Ulfhednar on June 01, 2014, 12:43:13 ---I also wondered how I might define a folder name based on things like filenames, root folder etc not just date & time.  I was wondering about something like this

--- Code: ---@var $arr = PathGetParts( $src_path );
--- End code ---
but instead transposing filename to a new folder & adding date & time.  As the debugger kept hanging I didn't get very far.

--- End quote ---
You can use PathGetParts to get an array with all the parts of the file paths split up.

But then you need to tell what part you want to use
like

--- Code: ---@var $path = "C:\\MyFolder\\MyFiles.txt";
@var $arr = PathGetParts( $path );

@var $drive = $arr[0];
@var $path = $arr[1];
@var $filename = $arr[2];

--- End code ---
$drive = "C:\"
$path = "C:\MyFolder\"
$filename = "MyFiles.txt"


If you only want the last Name part of a path you can use PathGetNamePart

--- Code: ---@var $path = "C:\\MyFolder\\MyFiles.txt";
@var $filename = PathGetNamePart( $path );
--- End code ---
$filename = "MyFiles.txt"

Or if you only want the path..  (Like remove the last path entry from the path)

--- Code: ---@var $path = "C:\\MyFolder\\MyFiles.txt";
@var $pathPart = PathGetPathPart( $path );
--- End code ---
$pathPart = "C:\MyFolder\"

Ulfhednar:
Thanks mathias thats great  :)

I now managed to modify my initial idea quite easily -

--- Code: ---@var $now = GetTime();
@var $date = FormatDate( "dd-MM-yyyy" , $now );
@var $time = FormatTime( "HHmm", $now);
@var $folder;
@var $FolderBaseName = GetTargetPath();
@var $filename = GetSourceFocusName();


 $folder = $FolderBaseName ^ $filename + " " + $date + " " +$time +"Hrs";
 MC.Filesystem.Makedir PATH="{$folder}"
--- End code ---

Giving me a folder in the target window with the source file selection & a time-stamp as its' name.
e.g.:- \mynewfolder.txt 01-06-2014 1700hrs

The folder name obviously includes the .ext so I am going to try the array approach to trim that from the name.
Wondering about opening the new folder in the target pane, I haven't found a 'Goto' type command yet. (To shift the focus to the newly created folder in the target pane).

Will post back my result.

Navigation

[0] Message Index

[#] Next page

Go to full version