PDA

View Full Version : I would like to search for the character 1 but not for 11. Even better not for 1.n.



rejto12
May 21st, 2015, 11:32 PM
Hello,

I would like to search for the character 1 but not for 11. Even better not for 1.n,
where n is any of the integers, 1,2,3,4,5,6,0.


Thanks,

-peter

Scott Lambert
May 22nd, 2015, 10:08 AM
Hi Peter,

I think the attached find1.vdm will do what you want.

Scott

rejto
May 22nd, 2015, 04:52 PM
Thanks Scott,

I have tried and I have some problems with your find1.vdm maro.

Here are the details:
It did find and highlight the numbers 3.13. However, it did not find the number 3.1.

-peter

Scott Lambert
May 23rd, 2015, 10:09 AM
Hi Peter,

I am unable to replicate your problem. I have a buffer with the following:

2

11

1

1.6

1.9

3.1

4.15

5.31

When I execute the macro, it stops on all the 1 except the 11 and the 1.6.

Scott

rejto12
May 27th, 2015, 03:42 AM
Hi Peter,

I am unable to replicate your problem. I have a buffer with the following:

2

11

1

1.6

1.9

3.1

4.15

5.31

When I execute the macro, it stops on all the 1 except the 11 and the 1.6.

Scott



Thanks Scott,

I could replicate your experiment.

However, if i Use it on my .texfile it also stops at.

\eqref{eq:A.18}


Do you have a reaction ?

-peter

Scott Lambert
May 27th, 2015, 10:22 AM
Hi Peter,

If you refer to your original message in this thread, there is no reason why it should not stop at \eqref{eq:A.18}.

According to what you gave me, the macro should stop on all 1 except if it is an 11 or a 1 followed by .1, .2, .3, .4, .5, .6, or .0

So, the macro is doing what you said it should by stopping at \eqref{eq:A.18}.

Scott

rejto12
May 27th, 2015, 09:08 PM
Thanks Scott,

So, I shall extend your macro to include the numbers 7,8,9, in addition to the numbers
1,2,3,4,5, 6.


Thanks again,

-peter

rejto12
June 28th, 2015, 07:06 PM
Scott,

I am back to your macro, find1.vdm.

Now, I would like to search for the string alpha , but not the string \alpha.

In other words, I would like to replace the character 1 by the string alpha and the
set of "negation elements" by the set consisting of the string \alpha.

I have tried and could not do it. I have a hunch that I am missing something simple.
This is that I did,


// find()_but().vdm

repeat(all) {
search("alpha",noerr)
if(return_value==0) {
end_of_file()
break
}
char(-1)
match("|{\}")
if(match_item>0) {
continue
} else {
char(-1)
break
}
}

Thanks as always,

-peter

rejto12
June 28th, 2015, 08:15 PM
Scott,

I did a little bit more thinking about my problem.

I think that this problem might be easier than your find1.vdm, inasmuch as the
"negation set" consists of a single character. So, I was playing around with the Vedit Cur_Char( ) command. I came up with somethings that hangs. I have a hunch that I might be close to a solution. Here it is anyway:

// find()_but().vdm
// Rejto adaptation of Scott's find1.vdm; 2015-06-28.


repeat(all) {
search("alpha",noerr)
if(return_value==0) {
end_of_file()
break
}
char(-1)
#11=Cur_Char()
if(#11==92) {
continue
} else {
char(5)
break
}
}


// Note the flow control command Syntax from the Vedit On_Line_help.

if (c) {
commands-1
}
else {
commands-2
}

Scott Lambert
June 29th, 2015, 09:52 AM
Hi Peter,

I tried to make your second version of the macro work, but no luck. Debugging other people's code is not my talent. I seem to have to write the original code to make it work.

Which I have done so, and have attached findalpha.vdm which should do what you want.

Scott

rejto12
June 29th, 2015, 11:59 AM
Hi Peter,

I tried to make your second version of the macro work, but no luck. Debugging other people's code is not my talent. I seem to have to write the original code to make it work.

Which I have done so, and have attached findalpha.vdm which should do what you want.

Scott

Thanks Scott,

I have tried your macro, FindAlpha.vdm and had an issue.

Specifically, it stopped at the first string of \alpha and then moved the cursor forward one position. That is to say, it stopped at the "a" character of the string
\alpha.

Looking forward to hearing your reactions.

Thanks as always.

-peter

Scott Lambert
June 29th, 2015, 02:53 PM
Hi Peter,

Sorry, I have my slashes mixed up. I was testing for /alpha and not \alpha.

on line 10 of macro, change:

match("/",noerr)

To:

match("\",noerr)

And everything should work.

Sorry about that.

Scott

rejto12
June 30th, 2015, 01:48 AM
Hi Peter,

Sorry, I have my slashes mixed up. I was testing for /alpha and not \alpha.

on line 10 of macro, change:

match("/",noerr)

To:

match("\",noerr)

And everything should work.

Sorry about that.

Scott

Scott,

your amended macro works like a charm. In fact I have replaced \alpha by \beta
and that worked too.

Thanks again,

-peter

rejto12
November 12th, 2018, 08:04 PM
Hi Peter,

I tried to make your second version of the macro work, but no luck. Debugging other people's code is not my talent. I seem to have to write the original code to make it work.

Which I have done so, and have attached findalpha.vdm which should do what you want.

Scott

Hi Scott, and fellow Vedit Users.

Your macro works like a charm. Here are the details:

I am using your macro to find typos in my latex/tex manuscipts. One of the simplest possible typos in such manuscripts is to forget the backslash chracter, " \ ", in front of the command alpha.
Now in a long manuscript it is nearly impossible to find such a typo. That is to say, it is nearly impossible to find such a typo by hand. That is how your macro comes to the rescue. Specifically, FinAlpha.vdm cand find such a tpo in seconds.

It is my understnding that latex/tex took over the backslash character from the C/C++ pogramming language. So, I think that that the FindAlpha.vdm macro ought to be better known.


-peter