Nearly impossible with a macro. Rounding down is not a problem. Rounding up is horrible for a number like 9999999.98 > 10000000.0
I suggest to do that with 2 macros. The first one finds the numbers with at least 2 digits and round it down which is pretty easy. The second one is called by the first one when a round up is required.
Macro "Find Numbers"InsertMode
ColumnModeOff
HexOff
UnixReOff
Find RegExp "[0-9]+.[0-9][0-9]"
IfFound
Key LEFT ARROW
IfCharIs "01234"
Find RegExp "[0-9]+"
Replace ""
Else
Find RegExp "[0-9]+"
Replace ""
PlayMacro 1 "RoundUp"
EndIf
EndIf
The second macro is a variant of my universal "CountUp" macro posted at
counter ? It ignores the decimal point when moving the cursor left and evaluating the character.
Macro "RoundUp"InsertMode
"|"
Key LEFT ARROW
Key LEFT ARROW
OverStrikeMode
Loop
IfCharIs "0"
"1"
ExitLoop
EndIf
IfCharIs "1"
"2"
ExitLoop
EndIf
IfCharIs "2"
"3"
ExitLoop
EndIf
IfCharIs "3"
"4"
ExitLoop
EndIf
IfCharIs "4"
"5"
ExitLoop
EndIf
IfCharIs "5"
"6"
ExitLoop
EndIf
IfCharIs "6"
"7"
ExitLoop
EndIf
IfCharIs "7"
"8"
ExitLoop
EndIf
IfCharIs "8"
"9"
ExitLoop
EndIf
IfCharIs "9"
"0"
Key LEFT ARROW
IfColNum 1
InsertMode
"1"
ExitLoop
EndIf
Key LEFT ARROW
IfCharIs "."
Key LEFT ARROW
EndIf
IfCharIs "0123456789"
Else
Key RIGHT ARROW
InsertMode
"1"
ExitLoop
EndIf
EndIf
EndLoop
InsertMode
Find "|"
Replace ""
The macro property
Continue if a Find with Replace not found or
Continue if search string not found should be checked for both macros.
Add UnixReOn or PerlReOn (v12+ of UE) at the end of the first macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.
Important: You have to create first the macro "RoundUp"! The macro name is case-sensitive in the PlayMacro command and the macro must already exist!