can't start other Editor

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

can't start other Editor

Postby CADdy » Thu Aug 05, 2021 8:18 am

Hi all,

when I call the editor to change the loaded G-code, I would like to start Notepad++. I have created the macro M20000.txt with the following content for this purpose:

Code: Select all
// call Notepad++
string gcpath = exec.Getgcodefilename();
System.Diagnostics.Process.Start("C:\Program Files\Notepad++\notepad++.exe",gcpath).WaitForExit();
exec.Loadfile(gcpath);


The call works, however the macro makes an error:

Code: Select all
UCCNC macro compiler error log file
--------------------------------------
Last error dated: 8/4/2021 7:55:53 PM
In macro: M20000
--------------------------------------
CS1009 | in line: 14 | error text: Nicht erkannte Escapesequenz.
CS1009 | in line: 14 | error text: Nicht erkannte Escapesequenz.
--------------------------------------

(In M20000.txt is no line 14 !)

The code snippet is from an old thread by Dan911 » Sun Sep 16, 2018 9:39 am: Things to make the Gcode editor better !
can someone help me out? The version of UCCNC is 1.2113

Peter
CADdy
 
Posts: 148
Joined: Sun Sep 17, 2017 2:26 pm

Re: can't start other Editor

Postby dezsoe » Thu Aug 05, 2021 9:51 am

You need a "@" to disable the escapes sequences in the string:

Code: Select all
    // call Notepad++
    string gcpath = exec.Getgcodefilename();
    System.Diagnostics.Process.Start(@"C:\Program Files\Notepad++\notepad++.exe",gcpath).WaitForExit();
    exec.Loadfile(gcpath);

Or you have to double the "\" characters:

Code: Select all
    // call Notepad++
    string gcpath = exec.Getgcodefilename();
    System.Diagnostics.Process.Start("C:\\Program Files\\Notepad++\\notepad++.exe",gcpath).WaitForExit();
    exec.Loadfile(gcpath);

The other problem is if you have a space in the filename then you may have problems, so you have to quote the file name:

Code: Select all
    // call Notepad++
    string gcpath = exec.Getgcodefilename();
    System.Diagnostics.Process.Start(@"C:\Program Files\Notepad++\notepad++.exe", "\"" + gcpath + "\"").WaitForExit();
    exec.Loadfile(gcpath);
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: can't start other Editor

Postby CADdy » Thu Aug 05, 2021 12:03 pm

:oops: Basic principles of programming. I need to learn the ropes.
Thanks dezsoe for the hint.

Peter
CADdy
 
Posts: 148
Joined: Sun Sep 17, 2017 2:26 pm


Return to Macros

Who is online

Users browsing this forum: No registered users and 6 guests