Create a file something.e or something and add the following code. Use the load module command on the macro menu to load it. If you call it from the command line or a menu it will display a message on the command line telling you what options you can use. If you call it from the command line with
gcode_round n
it will prompt you for the number of decimal places.
If you call it with gcode_round x, it will stop prompting you to confirm each change.
If you call it with gcode_round p it will start prompting you again.
If you bind a key to gcode_round, and use that key to execute it, it will use whatever options you last set.
The call to search searches for the first sequence of digits and decimal point on the current line starting at the current cursor position. In the call to the search function, the 'R' option means use slickedit regular expressions and the '<' means leave the cursor at the start. The $ means don't search past the end of the line. You can see slickedit regular expressions in the help in case you need to change the search - e.g. to look for the '=' before the number.
Graeme
#include "slick.sh"
#pragma option(strictsemicolons,on)
#pragma option(strict,on)
#pragma option(autodecl,off)
#pragma option(strictparens,on)
static int gcode_round_places = 2;
static boolean gcode_round_prompt = true;
_command void gcode_round(_str options = '')
{
if ((last_index('','w') && options == '') || pos(options,'h'))
{
message('Option n to select dec. places; p to prompt; x to not prompt');
return;
}
if (pos(options,'n')) {
_str x1 = prompt('','Enter number of places ',gcode_round_places);
if (isinteger(x1)) {
gcode_round_places = (int)x1;
}
}
if (pos(options,'p'))
gcode_round_prompt = true;
if (pos(options,'x'))
gcode_round_prompt = false;
if (search('[0-9\.]#|$','<R?') == 0)
{
_str tx = get_match_text();
if (length(tx) > 1) {
replace(tx,round(tx,gcode_round_places), gcode_round_prompt?'':'*');
}
}
}