Multi Commander > Script

Trying to write pretty simple scripts is turning out to be very exasperating!!!

<< < (3/3)

ajax:
Making some progress but still hitting some snags.  Your suggestion about NOT using TagValues in multiscript is something I'm attempting to do.  Now that, I think, I've found the low level functions that do what I need I thought it would be good to change.  I believe this is also going to help with my desire to run scripts on multiple selections.  However I've experienced an anomaly that I cannot explain.

Following is a couple of lines of code that do NOT work -

@var $linkpath = GetTargetPath();
MC.Utils.CreateLink ASADMIN LNKTYPE=1 LNKTRG={$filepath} LNKSRC={$linkpath}\{$linkname}
 
However, if I change to the following it does work -

@var $linkpath = GetTargetPath();
MC.Utils.CreateLink ASADMIN LNKTYPE=1 LNKTRG={$filepath} LNKSRC=${targetpath}\{$linkname}   

Another curious point that is revealed in the debugger is that the value returned by GetTargetPath() and ${targetpath} are the same and both are strings that end with the backslash ('\') character.  However, if I remove the backslash ('\') character shown in the argument to LNKSRC that separates the 2 parts of the fully qualified path then it FAILS to work.  I would expect that after the variable substitution has occurred this would result in the double backslash ('\\') which I'd think does NOT belong there.

Mathias (Author):
Windows will ignore double slashes
But you should put " around each path, because if there are space in the path it will cut out when parsing the parameters for the custom command
Also you can build the complete path first into a variable before sending it. then you will see the difference of the complete path

Not sure why it fails. It works here., might be because of some other reason.

ajax:
OK!  Following is slight change per your suggestion which DOES work -

@var $linkpath = GetTargetPath();
@var $link = $linkpath + $linkname;
MC.Utils.CreateLink ASADMIN LNKTYPE=1 LNKTRG={$filepath} LNKSRC={$link}

which while good still leaves me a bit perplexed when it comes to why.

Above was done for purpose of testing limited change but I have also added the quotes you suggested and that seems to be no problem.  So, per your point is good.

Very grateful for your help.  Well done!

Mathias (Author):

--- Quote from: ajax on July 08, 2018, 18:45:27 ---OK!  Following is slight change per your suggestion which DOES work -

@var $linkpath = GetTargetPath();
@var $link = $linkpath + $linkname;
MC.Utils.CreateLink ASADMIN LNKTYPE=1 LNKTRG={$filepath} LNKSRC={$link}

which while good still leaves me a bit perplexed when it comes to why.

Above was done for purpose of testing limited change but I have also added the quotes you suggested and that seems to be no problem.  So, per your point is good.

Very grateful for your help.  Well done!

--- End quote ---

Tip
If you not really sure if you have the slash that separate the folder and name there or not..  you can use the "path append" operator ^

--- Code: ---//instead of
@var $link = $linkpath + $linkname;
//you can use
@var $link = $linkpath ^ $linkname;
--- End code ---

^ Will check if any of the side have a \ or /  if not, then it will add a \

ajax:
Good to know.  Will do!

I also discovered that another technique that works is the following:

MC.Utils.CreateLink ASADMIN LNKTYPE=1 LNKTRG="{$filepath}" LNKSRC="{$linkpath^$linkname}"

Again.  Thanks for helping.  Multi Commander is very impressive!

Navigation

[0] Message Index

[*] Previous page

Go to full version