Topic: Numeric evaluation (1 of 17), Read 163 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Tuesday, February 15, 2000 04:49 PM

A couple of weeks ago a colleague of mine showed up in my office, who had been told that on my machine was some "old fashioned program" that could do miracles on files (old fashioned, of course, since it doesn't look like
M$Word). She had prepared an index for an upcoming book and detected that all page numbers above 18 had to be heightened by 1. After some hefty introspection of the manual, i put together the following lines:

repeat(all){
s("|d|s",errbreak)
markword()
gotopos(bb)
#10=numeval(suppress+advance)
if(#10 > 18) { delblock(bb,be) numins(#10+1,left+nocr) }
}

To my surprise, it worked. Now, the rumor of the miracle being spread out in the faculty, another gentleman presented me a more complicated case. His index entries have a format like this:

Frege, G. (1848--1925) 112, 114, 122--125, 136

My question is: what to do with the life-span dates? Is there a configuration command to the effect "search for digit+separator except for digit+bracket" ?

I would be grateful for suggestions how to improve the macro as well (i don't have the slightest programing background. Only V+ has enabled me to do "miracles" like that).

Fritz

 


Topic: Re: Numeric evaluation (2 of 17), Read 161 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Tuesday, February 15, 2000 11:20 PM

You should look into "Regular expressions" which is almost
like a powerful search/replace language. You can easily
specify groups of characters. For example, "[A-Za-z]" matches
any letter similar to the VEDIT pattern matching "|A", but
"[A-JL-Za-jl-z]" matches any letter expect for "k", which
would be very difficult with VEDIT pattern matching.

Similarly, "[!@#$%^&*()]" matches precisely the ten
characters between the square brackets.
Regular expressions come from the UNIX world.

It is more to learn, but then your co-workers will really
be impressed.

Ted.

 


Topic: Numeric evaluation (3 of 17), Read 159 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Wednesday, February 16, 2000 05:38 AM

Hello Fritz!

Not so easy ...

If you'll find a solution via regular expressions please let me know!

Until then a solution via macro:

repeat(all){
do {
Search("|d|s|s|d",ADVANCE+NOERR)
if (Error_Match){
return
}
Search("|!|d")
} while (Cur_Char == 41)

Save_Pos()
Search("|!|d",REVERSE+COUNT,3)
Char(1)

// ... your stuff

Restore_Pos()
}



HTH

Christian

 


Topic: Numeric evaluation (5 of 17), Read 160 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Wednesday, February 16, 2000 06:51 AM

PS:

I didn't use Mark_Word() because it doesn't do what you want if there are no spaces after the commas.

works:
Frege (1848--1925) 112, 114, 122--125, 136

doesn't work:
Frege (1848--1925) 112,114,122--125,136


Christian

 


Topic: Numeric evaluation (6 of 17), Read 160 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Wednesday, February 16, 2000 07:06 AM

Thanks a lot, Christian.
I will try hard to understand your macro this evening
(just now i'm going to teach two
bigdummies classes in latin linguistics,
so no time for funny things ...).

Fritz

 


Topic: Re: Numeric evaluation (7 of 17), Read 163 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Wednesday, February 16, 2000 11:00 AM

At 08:03 AM 2/16/00 -0500, you wrote:
>From: "Fritz Heberlein"
>(just now i'm going to teach two
>bigdummies classes in latin linguistics,

Hmmm, I never learned latin. First I learned German,
then English, then Fortran, then French, then
assembler, then C, then many other computer languages,
but never latin. Is this a new language used in
e-commerce, something like XML?

 


Topic: Re: Numeric evaluation (8 of 17), Read 169 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Wednesday, February 16, 2000 12:20 PM

> Hmmm, I never learned latin. First I learned German,
> then English, then Fortran, then French, then
> assembler, then C, then many other computer languages,
> but never latin. Is this a new language used in
> e-commerce, something like XML?

Well Ted,
Latin is the basic language of the VP+ manual.
Starting from

CONFIG[urare] to
CUR[rrens] CHAR[acter] to
CURSOR COL[umna]
till
VISUAL[iter]

everithing is Latin. That is what it makes so readable.

(for the sake of linguistic consistency, could you please delete
[delere!] those few germanic barbarisms in the next edition of the
manual?)

Fritz

Dr. Friedrich Heberlein, Akad. Direktor
Seminar f. Klassische Philologie, KU Eichstaett
D-85071 Eichstaett / Bayern
Tel. +49 8421 931544
Fax +49 93 1797
Email sla019@...
http://www..../SLF/Klassphil/home.htm

 


Topic: Numeric evaluation (16 of 17), Read 88 times
Conf: VEDIT Macro Language Support
From: Peter Rejto
Date: Thursday, February 28, 2002 03:02 PM

On 2/16/2000 5:38:00 AM, Christian Ziemski wrote:
>Hello Fritz!
>
>Not so easy ...
>
>If you'll find a solution via
>regular expressions please let
>me know!

Christian,

I wrote a macro, for a task similar to the original one of Fritz. In this macro, I use regular expressions. Therefore, I would like to know, which property of the generalized Fritz task forced you to abandon regular expressions? Actually, what I really would like to know is, whether I am missing some cases? So, after all, my macro does not work?

Here are the specifics: I would like to renumber some of my equations, which are in the latex syntax. In other words, I would like to make the following string replacements:

"eq:5.1" by "eq:5.2"
"eq:5.2" by "e1:5.3"
..., and so on; " is not part of the string.

Now, here is the macro. (It certainly looks like a simple adaptation of the original one of Fritz.)


// PR_RENUM.VDM; macro to renumber equations.
//
// parameters: Section=5; Increment=1; Begin=1; End=infinity
//
//
Begin_Of_File
Repeat(all)
{
Search("eq:5.[0-9][0-9]",regexp+errbreak)
Char(5)
#10=Num_Eval(suppress)
if(#10 > 0) {Del_Char() Del_Char() Num_Ins(#10+1,left+nocr) }
Char(5)
}
//
Begin_Of_File
Repeat(all)
{
Search("eq:5.[0-9][~0-9]",errbreak+regexp)
Char(5)
#10=Num_Eval(suppress)
if(#10 > 0) {Del_Char() Num_Ins(#10+1,left+nocr) }
}
Return

Thanks,

-peter

 


Topic: Numeric evaluation (17 of 17), Read 85 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Thursday, February 28, 2002 03:27 PM

Peter:

Of course it's possible to use regex in the search.
But it's not so easy to do all the search&replace in ONE Replace() with regular expressions to solve that task.
Theoretically it should be possible since regexp's are extremely powerful (if one is able to code them... ;-) )

That's what I meant (if I remember correctly). Hey, it's two years ago!

Christian

 


Topic: Numeric evaluation (4 of 17), Read 159 times
Conf: VEDIT Macro Language Support
From: Pauli Lindgren
Date: Wednesday, February 16, 2000 06:20 AM

How about something like this:


repeat(all){
s("|s|d",errbreak)
if(Cur_Char=='(') {
Match_Paren
} else {
char
Mark_Word
#10=numeval(suppress+advance)
if(#10 > 18) { delblock(bb,be) numins(#10+1,left+nocr) }
}
}


- Pauli

 


Topic: Numeric evaluation: thanks and a question (9 of 17), Read 162 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Wednesday, February 16, 2000 05:25 PM

Christian and Pauli:

thank you very much for your kind help! I'm sure your macros will be used quite often (BTW, I was surprised to learn that some people still make indexes manually, but i was told that, unlike TeX, Word is crash prone with index entries and cross references exceeding a certain amount).

Now for another (but related) question:
i asked my colleagues to convert their indexes to ascii. Can somebody tell me whether Vedit macros can be run on a word file immediately?

Fritz

 


Topic: Numeric evaluation: thanks and a question (10 of 17), Read 162 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Thursday, February 17, 2000 02:13 AM

Fritz,

Word documents are proprietary binary files.

IMHO there is no chance to work on them with VEDIT directly.

Of course you can modify a Word document in binary mode, but the results are not sure...

Christian

 


Topic: Numeric evaluation: thanks and a question (11 of 17), Read 163 times
Conf: VEDIT Macro Language Support
From: Pauli Lindgren
Date: Thursday, February 17, 2000 09:26 AM

The text part of Word document is plain ASCII. No need for binary mode. The file type must be set to "CR"

Vedit tends to automatically set file type for Word documents to "LF" which does not work correctly. That is why I have command

  Config(F_F_TYPE,2,LOCAL)

for .DOC files in my STARTUP.VDM.

If you run a macro, there is the danger that the binary part of the file is modified, too. That depends on what kind of search string you are using.

 


Topic: Re: Numeric evaluation: thanks and a question (13 of 17), Read 163 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Thursday, February 17, 2000 10:09 AM

At 09:24 AM 2/17/00 -0500, you wrote:
>If you run a macro, there is the danger that the binary part of the file
>is modified, too. That depends on what kind of search string you are using.

You might also want to set Config(F_OVER_MODE,2.LOCAL) to force
overstrike-only mode. That way VEDIT won't change the length of the
file and therefore won't corrupt the binary part.

Ted.

 


Topic: Re: Numeric evaluation: thanks and a question (12 of 17), Read 157 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Thursday, February 17, 2000 09:41 AM

At 05:23 PM 2/16/00 -0500, you wrote:
>i asked my colleagues to convert their indexes to ascii. Can somebody tell
>me whether Vedit macros can be run on a word file immediately?

There are no VEDIT macros that can work on Word .DOC files; the file format
is extremely complicated. I have personally not used Word precisely because
the .DOC files cannot be edited in VEDIT; therefore I have used an older
Ventura Publisher which worked with enhanced .TXT files. Ventura used
simple codes like to turn on bold, the code <$IComputer> would add
"Computer" to the index. I could do all editing in VEDIT and then do the
fancy printing with Ventura.

The VEDIT doco files use my own "meta" formatting language. One macro
converts the meta file into a Ventura .TXT file which becomes the printed
manual. Another macro converts the meta file into a .RTF file which the
Windows help compiler turns into a .HLP file.

However, now that Word 2000 can save all files as pseudo .HTML files, I am
thinking of switching from Ventura to Word. These .HTML files contain a lot
of formatting info within HTML comments, but you can get used to that; at
least the files can be editing in VEDIT.


Ted.
-------------------------------------------------------------------------
Ted Green (ted@...) Greenview Data, Inc.
Web: http://www.... PO Box 1586, Ann Arbor, MI 48106
Tel: (734) 996-1300 Fax: (734) 996-1308 VEDIT - Text/Data/Binary Editor

 


Topic: Re: Numeric evaluation: thanks and a question (14 of 17), Read 161 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Thursday, February 17, 2000 11:32 AM

> Another macro converts the meta file into a .RTF file

This brought me to the idea to try out Pauli's / Christina's index macros on
the index files saved in RTF format. Works fine: just block-mark the
text part and execute the macro. non problem to re-import it into
word. Really nice. Thanks!

Fritz

Dr. Friedrich Heberlein, Akad. Direktor
Seminar fuer Klassische Philologie
KU Eichstaett
Ostenstr. 26-28
D-85071 Eichstaett / Bayern

email: sla019@...
Tel.: +49 8421 93 1544 / 93 2544

 


Topic: Re: Numeric evaluation: thanks and a question (15 of 17), Read 167 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Thursday, February 17, 2000 12:53 PM

At 11:30 AM 2/17/00 -0500, you wrote:
>This brought me to the idea to try out Pauli's / Christina's index macros on
>the index files saved in RTF format.

Glad you thought of saving the Word files in RTF, which is also editable in
VEDIT.

Ted.