rstaveley wrote:Can you invoke a script from a macro?
No, this is not possible.
However, I think I get the task correct coded with a macro. Here is the macro code for copying it into the edit macro dialog. You should disable both macro properties for this macro.
This macro worked for me with UE v16.00.0.1025 with configuration setting
Allow positioning beyond line end (Configuration - Editor Display - Cursor/Caret) not enabled. The macro modifies the second line if the cursor is currently on the first line of the file. So don't execute the macro on the first line of a file.
InsertMode
ColumnModeOff
HexOff
IfCharIs 13
Key UP ARROW
IfCharIs 13
Key DOWN ARROW
ExitMacro
EndIf
StartSelect
Key RIGHT ARROW
Clipboard 9
Copy
EndSelect
Key DOWN ARROW
Paste
ClearClipboard
Clipboard 0
ExitMacro
EndIf
IfCharIs 10
Key UP ARROW
IfCharIs 10
Key DOWN ARROW
ExitMacro
EndIf
StartSelect
Key RIGHT ARROW
Clipboard 9
Copy
EndSelect
Key DOWN ARROW
Paste
ClearClipboard
Clipboard 0
ExitMacro
EndIf
IfEof
Key UP ARROW
IfCharIs 13
Key DOWN ARROW
ExitMacro
EndIf
IfCharIs 10
Key DOWN ARROW
ExitMacro
EndIf
StartSelect
Key RIGHT ARROW
Clipboard 9
Copy
EndSelect
Key DOWN ARROW
Paste
ClearClipboard
Clipboard 0
ExitMacro
EndIf
Key UP ARROW
IfCharIs 13
Key DOWN ARROW
ExitMacro
EndIf
IfCharIs 10
Key DOWN ARROW
ExitMacro
EndIf
StartSelect
Key RIGHT ARROW
Clipboard 9
Copy
EndSelect
Key DOWN ARROW
Key LEFT ARROW
Paste
ClearClipboard
Clipboard 0
Here is the macro code as UEM (UltraEdit Macro) with comments for a better understanding. See
Macro examples and reference for beginners and experts how to work with macro code in *.uem files.
- Code: Select all
InsertMode
ColumnModeOff
HexOff
// Is the cursor at end of the current line terminated with
// a carriage return - DOS files or not converted MAC files?
IfCharIs 13
// Move cursor up to line above. If the cursor is now at end of this
// line, nothing can be copied and therefore the cursor is just moved
// back to previous position.
Key UP ARROW
IfCharIs 13
Key DOWN ARROW
ExitMacro
EndIf
// Otherwise select the character, copy it to clipboard, move cursor
// down to original line which is automatically placed again at end
// of that line and simply paste there the copied character.
StartSelect
Key RIGHT ARROW
Clipboard 9
Copy
EndSelect
Key DOWN ARROW
Paste
ClearClipboard
Clipboard 0
ExitMacro
EndIf
// Is the cursor at end of the current line terminated with
// a line feed - not converted UNIX files? Yes, same code as
// above with the only difference to check for a line feed.
IfCharIs 10
Key UP ARROW
IfCharIs 10
Key DOWN ARROW
ExitMacro
EndIf
StartSelect
Key RIGHT ARROW
Clipboard 9
Copy
EndSelect
Key DOWN ARROW
Paste
ClearClipboard
Clipboard 0
ExitMacro
EndIf
// Is the cursor at end of the file, use the same code as above with
// the only difference to check additionally for a carriage return.
IfEof
Key UP ARROW
IfCharIs 13
Key DOWN ARROW
ExitMacro
EndIf
IfCharIs 10
Key DOWN ARROW
ExitMacro
EndIf
StartSelect
Key RIGHT ARROW
Clipboard 9
Copy
EndSelect
Key DOWN ARROW
Paste
ClearClipboard
Clipboard 0
ExitMacro
EndIf
// The cursor is not at end of the current line or end of file.
// Move cursor up to line above. If the cursor is now at end of this
// line, nothing can be copied and therefore the cursor is just moved
// back to previous position.
Key UP ARROW
IfCharIs 13
Key DOWN ARROW
ExitMacro
EndIf
IfCharIs 10
Key DOWN ARROW
ExitMacro
EndIf
// Otherwise select the character, copy it to clipboard and move cursor
// down to original line. Because of selecting the character in the line
// above the cursor is now one position right the original position. So
// the cursor must be set left before the copied character can be inserted.
// This is the important difference in behavior in comparison to the code
// above when cursor is at end of a line or end of the file.
StartSelect
Key RIGHT ARROW
Clipboard 9
Copy
EndSelect
Key DOWN ARROW
Key LEFT ARROW
Paste
ClearClipboard
Clipboard 0