Topic: Re-initializing registers (1 of 3), Read 15 times
Conf: Hints, tips, shortcuts
From: Daniel Bliss
Date: Thursday, May 17, 2007 11:53 PM

This is probably a stupid question, but I can't avoid posting it out of curiosity.

When I rerun a macro without exiting Vedit, can I reset register values in a better way than what is below? My current practice seems to leave certain registers in their previous state, because results can be unpredictable unless I exit VEDIT and re-launch and re-run macro.

Let's say I want to rerun a macro that I'm debugging. My current practice is to hit Ctrl-Break 3x & Ctrl-C 3x to stop a macro after running. Then I'll Close All windows. Without exiting, I'll reload & execute the macro a second time. The second run may run OK or it may not.

The beginning of the macro includes the following to re-initialize registers with user-assigned values.
(Using T-reg:10-17, 95-99; N-reg:#2-#13,#17-#18,#95-#99)
I also pop the registers just in case something is left on the stack.

for (#13=10;#13==17;#13++) {if (Reg_Size(#13)>0) {Reg_Empty(#13)}}
for (#13=95;#13==99;#13++) {if (Reg_Size(#13)>0) {Reg_Empty(#13)}}
do {Reg_Pop(0,0)} while ((Reg_Pop)>0)
do {Num_Pop(0,0)} while ((Num_Pop)>0)
#2=#3=#4=#5=#6=#7=#8=0
#9=#10=#11=#12=#13=#17=#18=0
#95=#96=#97=#98=#99=0

I guess Vedit is a mixture of C and Assembly, as it supports some indirection and functions like '#13++' in the macro language.
Thanks,
Dan Bliss

 


Topic: Re-initializing registers (2 of 3), Read 14 times
Conf: Hints, tips, shortcuts
From: Pauli Lindgren
Date: Monday, May 21, 2007 09:26 AM

On 5/17/2007 11:53:26 PM, Daniel Bliss wrote:

>When I rerun a macro without exiting Vedit,
>can I reset register values in a better way than what is
>below? My current practice seems to leave certain
>registers in their previous state, because results can be
>unpredictable unless I exit VEDIT and re-launch and re-run
>macro.

I don't know what could be the problem if the results are unpredictable. If you empty a register, it should be empty after that.


> for (#13=10;#13==17;#13++) {if (Reg_Size(#13)>0){Reg_Empty(#13)}}

I think the 'if' is not needed here. You can empty a text register even if it is already empty. So the following should be enough:

for (#13=10;#13==17;#13++) { Reg_Empty(#13) }


> #2=#3=#4=#5=#6=#7=#8=0
> #9=#10=#11=#12=#13=#17=#18=0
> #95=#96=#97=#98=#99=0

You can empty all the numeric registers with one loop, for example:

for (#0=10; #0<100; #0++) {
#@0 = 0
}

--
Pauli

 


Topic: Re: Re-initializing registers (3 of 3), Read 15 times
Conf: Hints, tips, shortcuts
From: Ted Green
Date: Monday, May 21, 2007 10:55 AM

At 09:29 AM 5/21/2007, you wrote:
>You can empty all the numeric registers with one loop, for example:
>
>for (#0=10; #0<100; #0++) {
> #@0 = 0
>}

I will add to the suggest list a simple command to empty a range of numberic or text registers.

Ted.