Multi Commander > Script

Need more documentation when creating/testing user defined commands

<< < (2/2)

ajax:
Actually the documentation is quite impressive.  Of course that's coming from someone with only a few days of using it.  My question had to do with error codes.  It's hard to imagine that they aren't listed (written down) somewhere/somehow.

Anyway, I went a little further and decided that MultiScripts could be good and my most immediate objective would need some such capability.  Therefore, I developed a fairly simple script, documentation very helpful, and using the Multi Script Debugger, which is nice, had some good success doing the basic debugging.  The basic purpose of the script is to tailor the arguments to be used to call a custom command.  Everything seems to be correct according to the debugger.

Is it possible that the custom commands are NOT supposed to do anything when invoked by the debugger?  That would explain the apparent result I'm getting.

The code follows (absent any attempt at handling the mentioned parameter).  It works as intended until the last line which invokes the MC.Utils.CreateLink custom command, which does nothing that I can recognize other than add a variable named $__CMDRESULT that appears to be an empty string.

--- Code: ---// Script to create a hard link (HL) to the source file (left panel selection),
// the link is placed in the target folder (right panel selection),
// the name of the link is the same as the source file name except for the addition of a suffix
// used to indicate that this directory entry is a hard link.  The suffix which can be specified
// by passing a parameter to this script which defaults to "L1" when the script is called without
// using a parameter.  This suffix is placed just before the file name extension, which must
// exist, and is preceded by a Period (".") as a separator character.

@var $suffix = "L1";
@var $filepath = GetTagValue("${sourcefocuspath}");
@var $filename = GetTagValue("${sourcefocusname}");
@var $linkdir = GetTagValue("${targetpath}");
@var $linkname = StrSub($filename, 0, StrRFind($filename, "."));
@var $linkext = StrTrimLeft($filename, $linkname);
$linkname += ".";
$linkname += $suffix;

// Full path to link being created
@var $target = $linkdir + $linkname + $linkext;
// Arguments for createlink command to be executed
@var $cmdargs = "ASADMIN LNKTYPE=1 LNKTRG=" + $filepath;
$cmdargs += " LNKSRC=" + $target;

//@var $result = MessageBox("MC.Utils.Createlink", $cmdargs, 0);
MC.Utils.Createlink {$cmdargs};

--- End code ---

Mathias (Author):
Only MultiScript support error handling. CustomCommand do not have much of error handling since they are more like Fire and Forget commands that are sent from the UI Layer. (They are like in if press the UI button for the command but specific some default parameters)
MultiScript functions are more core, and are not sent from the UI layer. and there is more control over these.  these are more low level.
But MultiScritp can call CustomCommands.. but they are fire and forget.. and if the CC is starting something that is handled in the background, the script will continue without waiting.


CreateLink  ( http://multicommander.com/docs/customcommands_list#mc.utils.createlink )
If you have space in file names you might need to put " around them.

MC.Utils.Createlink ASADMIN LINKTYPE=1 LNKTRG="{$filepath}" LNKSRC="{$target}"


ajax:
I assume that when you say "space in file name" you are talking about a blank character such as in "My Documents".  Because of this kind of problem I make a particular point of NOT using the blank character when naming files.  I substituted the following line both with and without quotes with NO difference in result.

MC.Utils.CreateLink ASADMIN LINKTYPE=1 LNKTRG={$filepath} LNKSRC={$target}

I also tried the following line all by itself in the Multi Debugger and it works as expected.

MC.Utils.CreateLink ASADMIN LNKTYPE=1 LNKTRG=${sourcefocuspath} LNKSRC=${targetpath}\${sourcefocusname}

which, I think, answers my question about whether or not custom commands function normally when using the Multi Debugger.

Because of what you describe as "Fire and Forget" I'd probably much prefer to use lower level functions but have not been able to identify, using documentation, one to use for creating a hard link.

Is it possible that such a function exists only missing from documentation?

Mathias (Author):
It is blank space in the entire path.  But it should not be a problem.. Just make sure you got " around the it like in my example


Running it in the debugger will not give you anything since they are not MultiScript function..  they are CustomCommand.. (Multiscript can execute CustomCommand..  but there is no extra info that is can show about them)

Fire and forget is when you fire a command and then the program continues. without knowing what happens or when it is finished. It just fire it off without waiting for it to complete

Navigation

[0] Message Index

[*] Previous page

Go to full version