On Tue, 25 May 2004 11:38:00 -0400, Bill Dedman wrote:
>In the macro, how would I find a string and then insert it elsewhere in the
>document?
>
>Such as, I'd like to look for the text between "XXX" and "YYY." These markers
>appear only once in the document, in the middle. Capture that text between
>those markers.
>
>Then, higher in the document, make that text the title of the HTML document, by
>inserting it between "title>" and "</title"
The Automatic-Webboard-Answering-Machine would say:
You already described it in "pseudo code"!
An implementation in VDM could be like this:
Begin_Of_File
Search("XXX|MYYY", NOERR) // search source
// (any text delimited by XXX and YYY)
if ( ! Error_Match ) { // if no error (XXX...YYY pair found)
Char(3) // move forward; past XXX
Block_Begin(Cur_Pos) // remember this position (mark block)
Search("YYY") // move to YYY (beginning of)
Block_End(Cur_Pos) // set end of block here
Reg_Copy_Block(103, Block_Begin, Block_End) // save that block to a register
Block_Begin(CLEAR) // clear block markers
Begin_Of_File // jump to begin of file
Search("title></title", NOERR) // search target
if ( ! Error_Match ) { // if found
Char(6) // move inside target (past "title>")
Reg_Ins(103) // insert saved text here
}
}
You can see: It's often straight-forward to do a macro in VEDIT.
That's exactly one of the powers of VEDIT!
Regards
TAWAM ;-)