Author Topic: StrReplace  (Read 15869 times)

pncdaspropagandas

  • Contributor
  • Active Member
  • *****
  • Posts: 93
    • View Profile
StrReplace
« on: February 02, 2017, 18:46:49 »
In a MultiScript when I run

$python_script_path = StrReplace($python_script_path, '"', 'x');
it runs fine

but if I run
$python_script_path = StrReplace($python_script_path, '"', '^"');
it reports an error to Log Window

further, If I create a var with '^"' and use it like
$python_script_path = StrReplace($python_script_path, '"', $aux);
it runs fine also

I think there's something wrong there

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4409
    • View Profile
    • Multi Commander
Re: StrReplace
« Reply #1 on: February 02, 2017, 19:23:53 »
I have not check it yet
But I think you need to escape special character like "
 StrReplace($python_script_path, '"', "^\"");

And you need to use double quotes..  single quotes are used for paths where you do not want it to escape characters..

http://multicommander.com/docs/multiscript/languagesyntax#escseq
« Last Edit: February 02, 2017, 19:25:57 by Mathias (Author) »

pncdaspropagandas

  • Contributor
  • Active Member
  • *****
  • Posts: 93
    • View Profile
Re: StrReplace
« Reply #2 on: February 02, 2017, 19:53:01 »
I tried to use
$python_script_path = StrReplace($python_script_path, "\"", "^\"");

but the Log Window reports:
2017-02-02 16:55:30.623 Script engine error - Line : 18, Error : -1 => Code : "$python_script_path = StrReplace($python_script_path, "\"", "^\"")"

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4409
    • View Profile
    • Multi Commander
Re: StrReplace
« Reply #3 on: February 02, 2017, 21:16:03 »
But it worked if you defined it to a variable? Then probably the parser gets confused with all the "
You can try to encapsulated the constant string in parentheses since then they are evaluated first.
Or just use variables.



pncdaspropagandas

  • Contributor
  • Active Member
  • *****
  • Posts: 93
    • View Profile
Re: StrReplace
« Reply #4 on: February 03, 2017, 10:56:27 »
Yes, it worked when I defined to a variable.
I'm using this way.

Thanks!

Sharoun

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: StrReplace
« Reply #5 on: February 05, 2017, 21:00:12 »
I have not check it yet
But I think you need to escape special character like "
 StrReplace($python_script_path, '"', "^\"");

And you need to use double quotes..  newbielink:http://adeleweightloss.com/ [nonactive] single quotes are used for paths where you do not want it to escape characters..

newbielink:http://multicommander.com/docs/multiscript/languagesyntax#escseq [nonactive]
I'm using this way.
« Last Edit: February 14, 2017, 17:32:53 by Sharoun »