Topic: replacing certain chars in certain fields (1 of 5), Read 183 times
Conf: Search and Replace
From: Deleted User
Date: Monday, September 20, 1999 03:46 PM

I built a little macro to find and replace return characters in a certain field from a tab delimited text file exported from access. It replaces the return with a formatting character, and once the file is brought into Director it is converted back. Since some of our data is copy/pasted into access from Word we end up with some bad returns in other fields, so replacing all returns can cause problems.

Since I am a novice programmer, I figure I am probably not doing this as elegantly as possible, and I thought perhaps someone might suggest how I can clean this up a bit.

while (At_EOF == 0) {

Search("|009",COUNT,24)
Search("|009",ADVANCE)

While (Cur_Char != 9) {
if (Cur_Char == 13) {
Replace ("|013","|202",NOERR)
Replace ("|010","",NOERR)
}

Char(1)

}

Line(1)

}

 


Topic: replacing certain chars in certain fields (2 of 5), Read 201 times
Conf: Search and Replace
From: Christian Ziemski
Date: Monday, September 20, 1999 04:41 PM


Hi Mark,

I would code it like that:
(from head to keyboard, not tested!)


Begin_Of_File

while (! At_EOF) { // while not At End_Of_File

Search("|009",ADVANCE+COUNT,25) // the beginning of the field
Block_Begin(Cur_Pos) // remember that position
Search("|009") // just after the end of that field
Block_End(Cur_Pos)

Replace_Block("|013|010","|202",BB, BE, ALL+NOERR) // do it here

Line(1)
}




Christian

 


Topic: replacing certain chars in certain fields (3 of 5), Read 199 times
Conf: Search and Replace
From: Deleted User
Date: Tuesday, September 21, 1999 02:40 PM

Thanks Christian, I bow to your godliness. :)

Only had to make two small changes. One to the count (24), and had to add a Goto_Pos(BB) before doing the replace. That one stupefied me for a bit.

Vedit is Fun Fun Fun!!!

 


Topic: replacing certain chars in certain fields (4 of 5), Read 208 times
Conf: Search and Replace
From: Christian Ziemski
Date: Tuesday, September 21, 1999 04:59 PM


Hi Mark,

I interpreted your

Search("|009",COUNT,24) Search("|009",ADVANCE)

to be the same as COUNT 25... Interpreting code isn't good. Reading is better.
You are right, it's 24 only. Next time I will read more carefully.
(It's often time to go to bed when I'm reading/answering the WebBoard (11p.m. or so.))

The same with your correctly added "Goto_Pos(BB)".


But it would be really too easy if the answer would be complete in the first step... ;-)
(hmmm, my english isn't good enough to explain.)


> Vedit is Fun Fun Fun!!!

Agreed! Absolutely! I can't live without VEDIT anymore.


Christian

 


Topic: Re: replacing certain chars in certain fields (5 of 5), Read 220 times
Conf: Search and Replace
From: Ted Green
Date: Tuesday, September 21, 1999 06:36 PM

At 05:00 PM 9/21/99 -0400, you wrote:
> > Vedit is Fun Fun Fun!!!
>Agreed! Absolutely! I can't live without VEDIT anymore.

It's nice to read that some customers are are enjoying the macro
language so much. :-)
And thank you Christian for answering so many questions here.