How to save the active file with new extension?

Help with writing and playing macros

How to save the active file with new extension?

Postby g3ppb » Wed Aug 23, 2006 3:56 pm

I have a macro below that edits the active file (abc.txt) but then I cannot save it with a new extension (abc.maa), keeping the same format.

CopyFilePath - this is useful only if I can change the file extension to .maa - is there a way to do this?
If so, then maybe I can use...... SaveAs "^c"

Any help appreciated.


InsertMode
ColumnModeOff
HexOff
UnixReOff
TrimTrailingSpaces
....
other editing commands
....
SaveAs "F:\Ham\MMANA\abc.maa" where abc is the active filename
User avatar
g3ppb
Newbie
 
Posts: 2
Joined: Tue Aug 22, 2006 11:00 pm

Re: How to save the active file with new extension?

Postby Mofi » Thu Aug 24, 2006 5:50 am

Add the following lines at the end of your macro:

InsertMode
Clipboard 9
CopyFilePath
Top
Paste
Find Up Select "."
Delete
".maa"
SelectToTop
Cut
SaveAs "^c"
ClearClipboard
Clipboard 0
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4066
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: How to save the active file with new extension?

Postby g3ppb » Thu Aug 24, 2006 11:28 am

Thank you Mofi! Yes, that works of course, but it is a huge kludge!

Perhaps one day Ian Mead may add the variables for active filename and extension...that would make many macros much shorter!
User avatar
g3ppb
Newbie
 
Posts: 2
Joined: Tue Aug 22, 2006 11:00 pm

Re: How to save the active file with new extension?

Postby Mofi » Thu Aug 24, 2006 1:16 pm

Also possible is to define a template which inserts the not modified parts of the filename with an other extension. Templates can be also executed from within a macro. See help of UltraEdit about templates and there special codes for filename handling. But you still have to cut the new filename inserted by the template to the clipboard before you can use it in the SaveAs or Open dialog.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4066
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Macros

cron