Hello.
Tonight I wanted to make something like god old xcopy script for fast backing up my C drive files and folders to make it easy to restore later.
I've started with string handling functions and got some problems:
1. In example to
PathGetParts function see, that should get a drive, a path and a file/folder name in the array. But I get the path with drive in the Path cell somehow. Here's what I do:
@var $leftselection = GetSourceFocusPath();
@var $pathparts = PathGetParts($leftselection);
//$pathparts[1] shows me "C:\Users\...\and so on", in user manual it looks like "Users\...\and so on"
Where is a mistake?
2. On some part I want to concatenate some strings. I write obvious thing:
@var $targetpath = $rightdir + "\" + $leftdrive + "\" +$leftrelpath;
//all vars are strings
, but I get no result. If I use
@var $targetpath = $rightdir + "\" + $leftdrive;
$targetpath = $targetpath + "\" +$leftrelpath;
, it works fine. Should it work like this?
3. Finally, I've managed to kill MC with my crazy code (it is not correct to make what I want, but its syntax is ok and should work fine):
@var $leftdir = GetSourcePath();
MessageBox("leftdir", $leftdir, 0);
@var $leftselection = GetSourceFocusPath();
MessageBox("leftselection", $leftselection, 0);
@var $pathparts = PathGetParts($leftselection);
@var $rightdir = StrTrimRight(GetTargetPath(), "\");
MessageBox("rightdir", $rightdir, 0);
@var $leftdrive = StrTrimRight($pathparts[0], ":\");
MessageBox("leftdrive", $leftdrive, 0);
MessageBox("pathparts[0]", $pathparts[0], 0);
MessageBox("pathparts[1]", $pathparts[1], 0);
MessageBox("pathparts[2]", $pathparts[2], 0);
@var $leftrelpath = StrTrimRight($pathparts[1], "\");
MessageBox("leftrelpath", $leftrelpath, 0);
@var $targetpath = $rightdir + "\" + $leftdrive;
$targetpath = $targetpath + "\" +$leftrelpath;
MessageBox("targetpath", $targetpath, 0);
CopyFile($targetpath + "\*", $leftselection, "");
The CopyFile command causes crash after I press Cancel. The target path is wrong, but anyway, I cancel the operation so MC shouldn't crash.
That's all for now, see you later