Topic: Unwanted iteration of search_block() (1 of 5), Read 21 times, 1 File Attachment
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Friday, March 26, 2004 11:06 AM

I have a problem with the macro printed here below.
It counts / extracts values from a database, sorts them into tabular cells and calculates the sum for every row. It has 10 search commands, which accordingly should result in a tabular row of 10 cells.

However, the 10th cell is doubled so that there are 11 cells. Nonetheless, the calculated sum is correct.

Any idea?

I have appended a sample of the data, case somebody is willing to have a look on it. IF prompted, search for Code "BN" or "LN", resp.

Thanks,

Fritz

---------------------------------------------------

// subordfrq.vdm Date: 26-03-2004 Time: 16:46:43
// Extracts subordination codes out of *.lfl files
// and calculates frequencies.


BOF()
margin_right(150)

#1=0 // counter for frequency
#2=0 // counter for totals


#80=BufNum // Data file

// Open Result file

#62=File_Check("c:\query\results\subord.txt") // Check if file already open
if(#62 > 0) { Buf_Switch(#62) }
else { fileopen("c:\query\results\subord.txt") }

// Prompt for subordination codes, e.g., "BN"

Get_input(10,"subordination code: ",NOCR)
EOF()
BOL()
RI(10) // insert subordination code in 1th cell
#4=Cur_Line
insindent(8)
#5=CurCol

// Goto Data File

BufSwitch(#80)

//Indicative

#1=sb("5|f11|f|f|f|f|@(10)",0,file_size,noerr+begin+all+COLSET,44,53)
#2+=#1 Call("EXEC")

#1=sb("5|f12|f|f|f|f|@(10)",0,file_size,noerr+begin+all+COLSET,44,53)
#2+=#1 Call("EXEC")

#1=sb("5|f13|f|f|f|f|@(10)",0,file_size,noerr+begin+all+COLSET,44,53)
#2+=#1 Call("EXEC")

#1=sb("5|f14|f|f|f|f|@(10)",0,file_size,noerr+begin+all+COLSET,44,53)
#2+=#1 Call("EXEC")

#1=sb("5|f15|f|f|f|f|@(10)",0,file_size,noerr+begin+all+COLSET,44,53)
#2+=#1 Call("EXEC")

#1=sb("5|f16|f|f|f|f|@(10)",0,file_size,noerr+begin+all+COLSET,44,53)
#2+=#1 Call("EXEC")


//Subjunctive

#1=sb("5|f31|f|f|f|f|@(10)",0,file_size,noerr+begin+all+COLSET,44,53)
#2+=#1 Call("EXEC")

#1=sb("5|f32|f|f|f|f|@(10)",0,file_size,noerr+begin+all+COLSET,44,53)
#2+=#1 Call("EXEC")

#1=sb("5|f34|f|f|f|f|@(10)",0,file_size,noerr+begin+all+COLSET,44,53)
#2+=#1 Call("EXEC")

#1=sb("5|f35|f|f|f|f|@(10)",0,file_size,noerr+begin+all+COLSET,44,53)
#2+=#1 Call("EXEC")

// add sum at end of table row

bufswitch(#62)
GotoLine(#4)
GotoCol(#5)
ins_indent(#5+8)
ins_text("&")
num_ins(#2,FILL+NOCR)
ins_text("\\")
insnewline()
alert()


:EXEC:
Bufswitch(#62) // goto result file
Gotoline(#4)
GotoCol(#5)
instext("&")
numins(#1,left+nocr) // insert frequency of subordination code
ins_indent(#5+8)
#5=CurCol
Bufswitch(#80)
return()

 
SAMPLE.LFL (23KB)

 


Topic: Re: Unwanted iteration of search_block() (2 of 5), Read 21 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Friday, March 26, 2004 01:24 PM

Fritz:

you wrote:

>I have a problem with the macro printed here below.
>However, the 10th cell is doubled so that there are 11 cells.
>
>Any idea?


ins_text("\\")
insnewline()
alert()

// here is a "return" missing!
// so the EXEC subroutine is called one more (11th) time
//

:EXEC:
Bufswitch(#62) // goto result file


Christian

 


Topic: Re: Unwanted iteration of search_block() (3 of 5), Read 22 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Friday, March 26, 2004 01:38 PM

Thank you Christian!

Apparently, i didn't understand the function of the return() command
properly. The manual (ch.3. says "returns to any parent macro ...".
But there isn't a parent macro here, is it?

Thanks again,

Fritz

 


Topic: Re: Unwanted iteration of search_block() (4 of 5), Read 23 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Friday, March 26, 2004 04:36 PM

Fritz:

On Fri, 26 Mar 2004 13:38:00 -0500, Fritz Heberlein wrote:

>Apparently, i didn't understand the function of the return() command
>properly. The manual (ch.3. says "returns to any parent macro ...".
>But there isn't a parent macro here, is it?

No parent *macro*, indeed.
But return() returns to any parent "instance".

The online help says:
"Return(n) Stops the current macro and returns to any parent
(calling) macro, the "COMMAND:" prompt or Visual Mode."

It the usual way to end a macro.
If the last executed line of a macro is at end-of-file you can omit
the return command, at least unless you want to set a return-value to
be evaluated in the calling instance.

Hope that helps a bit.

Christian

 


Topic: Re: Unwanted iteration of search_block() (5 of 5), Read 19 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Saturday, March 27, 2004 06:13 AM

Thanks for the explanation, Christian. This is one of a couple of
points about which the manual might be a bit more explicit.
Some hint in the "Introduction to programming" section would be
helpful, something like "it is always a good idea to end your macro
with one of the break-out commands described on p. 64, even if that
is non mandatory for simple macros". The case we are discussing here
would be a good illustration :)

Thanks and regards,

Fritz