Multi Commander > Script

Passing arguments to MC.Run

(1/2) > >>

espkk:
Trying to use this script:

--- Code: ---function GetArgs()
{
  @var $args = "";
  @var $n;
  for( $n = 1; $n < $argcount; $n = $n + 1 )
  {
       $args = $args + " ";
       $args = $args + $arg($n);
  }
  return $args;
}
@var $s = GetTagValue("${mcinstallpath}") + "\\..\\";
$s = $s + $arg(0);
$s = $s + "\\";
$s = $s + $arg(0);
$s = $s + ".exe";
@var $args = GetArgs();
MC.Run CMD="{$s}" ARG="{$args}"
--- End code ---
The problem is the script trims double quotemarks splitting "a complex argument" into 3 arguments:


--- Code: ---run test "a complex argument"
--- End code ---

--- Quote ---argc = 4
C:\mc\..\test\test.exe
a
complex
argument
--- End quote ---
So I can't send filepath with spaces
how to solve this problem?

Mathias (Author):
I'm not sure what you are trying to do..  How to you run the command, What do you want the script to do ?

Jungle:
EsperoDrake
What about

--- Code: ---return "\"" + $args + "\"";
--- End code ---
or

--- Code: ---@var $args = "\"" + GetArgs() + "\"";
--- End code ---

espkk:

--- Quote from: Mathias (Author) on April 13, 2016, 14:23:06 ---I'm not sure what you are trying to do..  How to you run the command, What do you want the script to do ?

--- End quote ---
The script should run specified app with specified arguments throw alias
The first argument is the application name which is stored in folder with the same name
I want to pass path to file with spaces which must be a single argument in double quotes

--- Quote from: Jungle on April 13, 2016, 15:30:08 ---EsperoDrake
What about

--- Code: ---return "\"" + $args + "\"";
--- End code ---
or

--- Code: ---@var $args = "\"" + GetArgs() + "\"";
--- End code ---

--- End quote ---
I think this would work, but I also need to pass other arguments after (or before) filepath
So, filepath must be quoted while other arguments should pass as is
Currently, MC command line deletes all double quotes ignoring \"(turns it to \, AFAIU)

Mathias (Author):
I can't understand the script.  So I can test it. you have to give me a description on how it should be run and what should be send as parameters.

For example  when you build the $s (path to the program to run.)  you include $arg(0) twice ? is that correct. 

When you send arg to a space on the command line field you need to quote them if they have space.   [ MyScript "C:\MyFolder Ha Space\My File.Txt" -D -C ]

Navigation

[0] Message Index

[#] Next page

Go to full version