SlickEdit Community
SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started by: hensh on March 20, 2020, 11:06:43 AM
-
The Slick-C code below will not run. However, if Typora.exe is in my PATH, the commented line below works. Why can't Slick-C find 'C:\Program Files\Typora\Typora.exe'? I've tried numerous variations. What am I missing?
#include "slick.sh"
_command void runtypora() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
if (_no_child_windows()) {
_message_box("No buffer is open");
return;
}
if (_isno_name(p_DocumentName) || p_buf_name == '') {
_message_box("No buffer is open");
return;
}
save();
//shell('Typora ' p_buf_name, 'QA');
shell('C:\Program Files\Typora\Typora.exe ' p_buf_name,'QA');
}
-
Try putting double quotes around C:\Program Files\Typora\Typora.exe since there are space in it.
If you had this in a variable you could use _maybe_quote_filename() around it. You still could, but since you have a constant, it's easy enough to just quote.
-
This was the first thing I tried.
shell("C:\Program Files\Typora\Typora.exe " p_buf_name,'QA');
The macro does not compile and I get a message stating that there is an illegal character with a blinking cursor appearing between the colon and the backslash.
-
Try this:
shell(_maybe_quote_filename('C:\Program Files\Typora\Typora.exe')' 'p_buf_name,'QA');
-
Worked like charm. Thank you. Any idea why your suggestion was necessary?
-
Because I answered you before I had coffee ;)
In Slick-C, like in C++, \ escapes certain characters in a double quoted string. For example, "\t" is a tab character. "\P" is invalid.
Using single quoted strings gets around this. However, when you have a filename with spaces like that, you still need to double quote them most of the time.
-
;D
thanks