On 6/3/2004 6:08:19 PM, Dale Cook wrote:
> I have a macro that gets a filename from point-and-shoot. I need to
> take that filename (which is actually a full path) from the text
> register that it is stored in and alter it - specifically I need to
> change part of the path so that variants of the original file,
> created by the macro, can be stored in different directories.
>
> I don't see any way to, say, delete the first "n" characters from a
> text register. I could stuff the contents of the register into a
> buffer and edit it there, but how do I get the contents of the
> buffer back into a text register so I can use it in, say, a
> File_Save_As() command?
Get_Filename(90, "*.*")
#103=Buf_Num // remember current buffer
Buf_Switch(Buf_Free) // open temporary buffer
Reg_Ins(90) // insert path+filename
// Begin_Of_File // edit it somehow
// Del_Char(...)
//
Reg_Copy_Block(90, 0, File_Size) // copy the result back to register
Buf_Quit(OK) // close temporary buffer
Buf_Switch(#103) // switch back to original buffer
// File_Save_As("|@(90)") // do something with the modified path+filename
> Alternatively, is there anyway to truncate the result of a
> Get_Filename() using wildcards, so that only the filename and
> extension are left in the text register, without the rest of the
> path?
One possibility using the editing above:
Get_Filename(90, "*.*")
#103=Buf_Num // remember current buffer
Buf_Switch(Buf_Free) // open temporary buffer
Reg_Ins(90) // insert path+filename
Search("|{\,/}", REVERSE+ADVANCE) // search the last path devider
Reg_Copy_Block(91, Cur_Pos, File_Size) // copy filename+ext to register
Buf_Quit(OK) // close temporary buffer
Buf_Switch(#103) // switch back to original buffer
Or another possibility:
Get_Filename(90, "*.*")
#103=Buf_Num // remember current buffer
File_Open("|@(90)") // open the file temporary
Reg_Set(91, FILENAME) // get filename with extension
Buf_Quit(OK) // close it again
Buf_Switch(#103) // switch back to original buffer
Christian