Thanks, the following is working for command line invocation. I'm not sure how to determine if the function was called from invocation or macro call. The following will work correctly from SE cli or Invocation call but calling from another command as the parse_current_line_for_event command below does causes the parameters to be overwritten when the args are parsed. How do you tell if it was invoked from cli or called directly to determine if args needs to be parsed? arg() returns 2 for both instances but the function call version parses both parameters as a single argument.
Also, I'm trying to figure out how to search a line for tags using a regex. Anyone have experience or somewhere to point me to for somewhat simple examples?
Thanks in advance!
static boolean user_macro_debug_enabled = false;
_command void open_project_file(_str file_name='', _str line_number='') name_info(PROJECT_FILE_ARG','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
// Invoke SE with 'vs.exe "-#open_project_file file_name line_number"'
// Call from SE cli with 'open_project_file file_name line_number'
if ( user_macro_debug_enabled ) {
say("Passed parameters - file_name: "file_name" - line_number: "line_number);
}
if (arg() > 0) {
parse arg(1) with file_name line_number;
if ( user_macro_debug_enabled ) {
say("Parsed " :+ arg() :+ " arguments - file_name: "file_name" - line_number: "line_number);
}
}
if (project_file_match(file_name, true) != '') {
// Make SE the focus program.
mdisetfocus();
// Push a bookmark to easily go back.
push_bookmark();
edit_file_in_project(file_name);
_str message_string = "Navigated to "file_name;
// Validate a line number if supplied.
if ((line_number != '') && isinteger(line_number)) {
goto_line(line_number);
first_non_blank();
message_string :+= ":"line_number;
}
message(message_string". Bookmark pushed.");
} else {
message("Invalid project file or no project loaded");
}
}
_command void parse_current_line_for_event() name_info(',')
{
// Get 2 taged expression from current line using perl regex "(?i)^.*\|\s(\S*)\s*:(\d*).*$". First tagged is file_name second
// taged is line number.
/* Links to example code found so far...
_str trace_line_str = '';
get_line(trace_line_str);
_str search_regex = "(?i)^.*\|\s(\S*)\s*:(\d*).*$";
regex_search();
//trace_line_str.regex_search()
*/
//int returned_value = trace_line_str.search(search_regex,"IL",);
//message("Found name: "trace_line_str" Returned Value: "returned_value);
open_project_file("test_file.h", 34);
}