Topic: Needs enhancement fot Num_Eval macro. (1 of 4), Read 34 times
Conf: VEDIT Macro Language Support
From: Peter Rejto
Date: Saturday, June 15, 2002 09:28 PM

Hello,

In connection with my equation renumberings I very heavily use the Num_Eval macro. As per online help, this macro evaluates the unsigned numrical expression at the edit position.

Now I would appreciate having this macro enhanced to evaluate signed numerical expressions.

I just have no idea about the possible work involved in such an enhancement. First I thought to write such a macro myself, but it looks very difficult. Is there a Vedit macro
that returns for a positive number its negative?

Thanks,

-peter.

 


Topic: Needs enhancement fot Num_Eval macro. (2 of 4), Read 32 times
Conf: VEDIT Macro Language Support
From: Peter Rejto
Date: Saturday, June 15, 2002 10:36 PM

Hello,

I did some more thinking about this enhancement question and this is what I came up with:

Vedit allows me to multiply the content of a Numeric register by a signed integer. In fact, I tried out multiplication by the number (-1) and it worked fine. So, under special circumstances it should be possible to enhace the Num_Eval macro to handle negative numbers. Since I am in the middle of renumbering my equations, I did not try to write such an enhanced macro. Here is the pseudo code:

----------
I have a bunch of equation numbers of the form;

eq:-d; d=-5,-4,-3,-2,-1

and I wish to add 10 to each of them.

Find eq:-5 with the

Search("-[0-9]", reg_exp, advance))

command. Then move the cursor to the "number 5" with the Char(1) command. Set 5 into Numeric Register, say #11, with

#11=Num_Eval .

Then multiply #11 by (-1) with

#12=(-1)#11.

Then #13=#12+10.
--------------------------

I do not know whether this can be generalized to other problems involving signed integers. Since my simple pseudo macro seems to cover my equation renumbering I shall not think about such an enhancement. At the same time I hope that experts will have a reaction to this enhancement question.

I also hope that Fritz will have another colleague whose manuscript has pagination problem with negative page numbers. So, Fritz will have to adapt his original solution.

Thanks,

-peter.

 


Topic: Re: Needs enhancement fot Num_Eval macro. (3 of 4), Read 32 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Sunday, June 16, 2002 08:41 AM

> I also hope that Fritz will have another colleague whose manuscript
> has pagination problem with negative page numbers. So, Fritz will have
> to adapt his original solution.

Peter:

I'm not sure whether i have understood your intentions, but...

1. Numeval() can handle negative values - just position the cursor on
the minus sign instead of the integer.

Then, taking up your first example,

#11=numeval()

will put "-5" into #11

2. Than you could proceed with

num_str(#11+10,11)

to increase #11 by 10 and to put the new value into TReg @11 for
further use, e.g in a replacement string.

2. AS to your search string "Search("-[0-9]", reg_exp, advance))":

a. the second ")" is superfluous
b. "advance" will produce an undesired result; the cursor must
be placed on the "-".

Have fun with your experimenting.

Fritz

 


Topic: Re: Needs enhancement fot Num_Eval macro. (4 of 4), Read 31 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Sunday, June 16, 2002 09:36 AM

At 08:41 AM 6/16/2002, you wrote:
>From: "Friedrich Heberlein"
>1. Numeval() can handle negative values - just position the cursor on
>the minus sign instead of the integer.

Fritz, thank you for answering Peter's question.

Yes, Num_Eval() evaluates any algebraic expression consisting of any of VEDIT numeric operators (which are identical to C). The result is a signed number in the range +/- 2-Billion.

Num_Eval(SUPPRESS) evaluates only simple positive numbers without any
operators.

Ted.