Multi Commander > Script
Trying to write pretty simple scripts is turning out to be very exasperating!!!
Mathias (Author):
--- Quote from: ajax on July 05, 2018, 21:40:38 ---In my case the Alias Manager screen lists the name I assigned to the multiscript on the left and a value of @d037fc176448408cb5c744d5bc62ae33 on the right. That value is what is displayed as the "Unique ID" in the upper right corner of the script editor for the script I want to invoke.
The script works fine in Multicript Debugger but it looks to me as if you cannot test the parameter passing in the debugger. If that is possible I could use some help figuring out how to do that. I'm not even able to invoke it without a parameter from the command line.
--- End quote ---
If you look at one of the example script that are there after install . "Google Search" there is an alias for this command to.. so when you type "g <text>" in the command line field.. the script is run. and the script picks up the arguments sent to the script before sending everything to the browser.
If you show the code and descibe what you are trying to do. I think it would be easier to say what you should do
ajax:
It looks like the problem invoking the multiscript using an alias was attributed to a coding error. In that, the script probably did execute but when nothing appeared to happen this was not apparent. However now that I can confirm that it is invoked I'm having trouble picking up the value entered for a parameter.
As requested the script follows:
--- Code: ---@var $suffix = GetTagValue("${param:0}");
@var $message = "Request to Create a Hard Link (Alias)";
$message += "\nParam0=" + $suffix;
if(StrLen($suffix) <= 0)
{
$suffix = "L1";
}
else if (StrLen($suffix) > 5)
{
$suffix = "L9";
}
@var $filename = GetTagValue("${sourcefocusname}");
@var $linkname = StrSub($filename, 0, StrRFind($filename, "."));
@var $linkext = StrTrimLeft($filename, $linkname);
$linkname += "." + $suffix + $linkext;
@var $linkpath = GetTagValue("${targetpath}");
$message += "\nLinkPath=" + $linkpath;
$message += "\nLinkName=" + $linkname;
@var $tofile = GetTagValue("${sourcefocuspath}");
$message += "\nToFile=" + $tofile;
@var $result = MessageBox("Alias Make", $message, 1);
if($result == 1)
{
MC.Utils.CreateLink ASADMIN LNKTYPE=1 LNKTRG=${sourcefocuspath} LNKSRC=${targetpath}\{$linkname}
}
--- End code ---
As you can see I'm assuming the parameter value is string (type of data). Because I'm uncertain about this I tried using some of the functions described http://multicommander.com/docs/multiscript/corefunctions but this produced an error in the debugger saying that no such function existed.
Right now it looks like my only problem is how to find the value entered as a parameter on the command line.
Mathias (Author):
Look at the "Google Search" example.. it picks up the parameters with some variables that gets auto created
$argcount and $arg[] array
The TagValue are not really used with MultiScript unless you have to. They are really created for other bat scripts and customcommands..
ajax:
OK, I think I see what you mean. However, this experience again demonstrates the need/desire to be able to test scripts that use this capability with the debugger. When I code what is shown in your post and would have thought is correct for an array type variable (i.e., $arg[]) nothing happens which I've come to recognize as meaning there is error in the script. When I looked closer I noticed that the "Google Search" example that you referenced actually codes it instead as "$arg()" which I found perplexing but went ahead and tried anyway. That worked but then when I invoke the script form the command line but without an argument it fails. Is there a suggested method for writing a script that can figure out whether or not arguments have been specified on the invoking command? Might there be an explanation for the alternative syntax used on the $arg variable?
Mathias (Author):
The debugger will log out if there are any error that the engine does not understand.
and you run the script in the debugger and it wil run line by line. and you can see all variable that the script engine has in the watch window.
MultiScript are low level. and CustomCommand the the other are high level command, they are used for different things. CustomCommand is like pressing a command in the UI. (but with preset options) with MultiScript you can access the core function at a more core level. MultiScritp is not connect to the UI in the same way
No you need to fake parameters while you debug. 99% of script do not actually use parameters.. they act on items in the file list. The get selected items and so on. and do things with that.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version