Topic: Function to save under another name... (1 of 2), Read 19 times
Conf: VEDIT Macro Language Support
From: jay hightman
Date: Thursday, January 22, 2004 01:25 PM

I was wanting to write a function that each time it was called would save a file under a new name. To keep things simple the starting file name would be something like *.htm. When the function is called it would be saved as *.hta, the next *.htb, *.htc ext. The idea would be to start at a and go to z. I haven't programmed in this macro language before so I am not sure how to define static variables or to convert numeric values (a = ASCII 97) to actual characters. Or even how to do string concatenations. i.e. FILE_ONLY + LEFT$(FILE_EXT, 3) + CHR$(97) = test.hta if this were BASIC. Future enhancements might be for it to automatically start at the right place a file such as *.htc would be named *.htd next. Another might be have the extension be aa, ab, ac to zz for example. Any help would be appreciated.

J!

 


Topic: Function to save under another name... (2 of 2), Read 17 times
Conf: VEDIT Macro Language Support
From: Ian Binnie
Date: Friday, January 23, 2004 01:29 AM

On 1/22/2004 1:25:12 PM, jay hightman wrote:
>I was wanting to write a
>function that each time it was
>called would save a file under
>a new name.

The following macro will "increment" the last character of extension & save file
This is for demo only - NO error checking
Text register 30 has the new pathname on exit.

#104=Buf_Num // Current Edit Buffer
Reg_Set(30,PATH_ONLY) // path of current file
Reg_Set(30,"\",APPEND)
Reg_Set(30,FILE_ONLY,APPEND) // Name of current file
Reg_Set(30,".",APPEND)
Reg_Set(31,EXT_ONLY) // Output File
Buf_Switch(Buf_Free(EXTRA))
Buf_Empty(OK)
Reg_Ins(31)
#105=cc(-1) // numeric value of last character
Del_Char(-1)
Ins_Char(#105+1)
Reg_Copy_Block(30,BOB_Pos,EOB_Pos,APPEND) // New extension
Buf_Quit(OK)
Buf_Switch(#104)
File_Save_As("|@(30)") // Open "output" file