Topic: buffer control problem (1 of 4), Read 27 times, 3 File Attachments
Conf: VEDIT Macro Language Support
From: Steve Rawling
Date: Wednesday, January 09, 2008 01:59 AM

I have written the attached macro "SR-macro" intending it to primarily executed in its own instance of vedit using a command line prompt

c:\vedit\vpw -s2 -x SR-macro.vdm SR-data.asc

The macro reformats the data file "SR-data.asc" and saved it to "SR-data.rde" then closes VEDIT.

I use macros in this way a lot.

However, this time I am aiming to allow the same macro to also be started from an instance of VEDIT already opened and which the "SR-data.asc" file is in any buffer and the macro loaded using the default menu item, Misc..Load/Execute Macro.

If I open VEDIT, load "SR-data.asc" into Buffer 1 I can successfully run the macro. The reformatted data is saved and VEDIT is closed.

However if I have some other file is buffer 1 and have "SR-data.asc" loaded into buffer 2 , then run the macro, the reformatted data is successfully written to disk but when VEDIT tries to close it asks me "Do I want to save "SR-data.asc" but I have already saved the buffer to a new name and followed that command with BQ(OK) which should prevent this prompt from occuring.

Also, if I have VEDIT open with Buffer 1 containing some other data and I run the command line

c:\vedit\vpw -x SR-macro.vdm SR-data.asc

then the "SR-data.asc" file is loaded into buffer 2 and the macro stops.


Can anyone explain to me what I am doing wrong

Steve Rawling

 
macro buffer problem macro
  the input file read by the macro
  the output file written by the macro

 


Topic: buffer control problem (2 of 4), Read 25 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Wednesday, January 09, 2008 06:02 AM

On 1/9/2008 1:59:09 AM, Steve Rawling wrote:
>I have written the attached macro "SR-macro" intending it
>to primarily executed in its own instance of vedit using a
>command line prompt
> [...]
>However if I have some other file is buffer 1 and have
>"SR-data.asc" loaded into buffer 2 , then run the macro,
>the reformatted data is successfully written to disk
>but when VEDIT tries to close it asks me "Do I want to save
>"SR-data.asc" but I have already saved the buffer to a
>new name and followed that command with BQ(OK) which
>should prevent this prompt from occuring.
> [...]
>Can anyone explain to me what
>I am doing wrong

Steve:

First I wouldn't rely on Buf_Previous() for switching buffers. Better take care by yourself!

I rewrote some lines of your macro a bit to show:


// INPUT FILE'S EXTENSION IS CHANGED TO RDE AND "filename.rde' SAVED IN T REG 99

#103=Buf_Num // remember current buffer number
Out_Reg(103) // use one of the temporary registers
Name_Write(EXTRA+NOCR+NOMSG)
Out_Reg(CLEAR)
Buf_Switch(Buf_Free(EXTRA)) // use one of the extra buffers
Reg_Ins(103)
Search(".",REVERSE+ADVANCE) // advance past the found "."
Del_Line(1)
Ins_Text("rde")
Begin_Of_File
Reg_Copy_Block(103, Cur_Pos, EOL_Pos)
Buf_Quit(OK)
Buf_Switch(#103) // don't rely on Buf_Previous but take control by yourself

// THE FINISHED CONVERTED DATA IS COPIED TO THE CLIPBOARD AND THEN SAVED AS "filename.rde"

Clip_Copy_Block(0, File_Size)
File_Save_As(@103, OK+NOMSG)
Buf_Quit(OK)

goto end


But I didn't test it.


Christian

 


Topic: buffer control problem (3 of 4), Read 20 times, 1 File Attachment
Conf: VEDIT Macro Language Support
From: Steve Rawling
Date: Thursday, January 17, 2008 06:16 PM

Thanks Christian for once again showing me the real way to write and present macros

Your elimination of use of buffer previous solved the problem when the input file was in one of multiple opened buffers and the macro called from the vedit menu.

Strangely when I run it from the command line without the S2 instance switch, the macro still stops at top of the imput file with nothing changed.

ie

C:\VEDIT\VPW -x ASCtoRDE-chris.VDM [INPUT file]

I'll have another look at it next week and report back.

Thanks again for your help

Steve

 
Christian's corrected Macro

 


Topic: Re: buffer control problem (4 of 4), Read 21 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Saturday, January 26, 2008 02:48 AM

On 18.01.2008 00:18 vedit-macro-language Listmanager wrote:
> From: Steve Rawling
>
> Strangely when I run it from the command line without the S2 instance switch,
> the macro still stops at top of the imput file with nothing changed.
>
> ie
>
> C:\VEDIT\VPW -x ASCtoRDE-chris.VDM [INPUT file]

Steve,

I tried it with several instance switches here. It always worked fine.
The example input file is converted to the expected output.

No idea what is going wrong on your side.

To pin down the problem I would suggest creating a little macro with only

Begin_Of_File
Ins_Text("Example")

and execute that one instead of your conversion macro, with an empty
test input file.
Try that with different -s switches and have a look whether the text is
inserted.

Perhaps somehow macros aren't executed at all due to some misconfiguration?


Christian