General CADD Pro Free Help Forum

Free Support for All Interested in General Cadd Pro

The New Generic CADD for Windows

 
Page 1 of 1 1
Topic Options
#6612 - 12/06/06 02:39 AM TEXT-Search&Replace.gxm
Vincent Offline
Member


Registered: 06/25/02
Posts: 505
Loc: Newcastle, Australia
GCP5 has a new macro command option in the /STR stable for text manipulation.

Here is a macro that uses this new feature to Search and Replace text on your drawing.

If everything goes well with it I'll upload it.
Note the safe pre version 5 exit.

Have fun with it.

Vincent

;>>> TEXT-Search&Replace.GXM
;>>> Search and replace text on your drawing.
;>>> Written by: Vincent Ferrara 2006
;**************************************************
;>>> Description:
;>>> Firstly, enter the text you want to find.
;>>> Secondly, enter the text you wish to replace it with.
;>>> Thirdly, select the text to process.
;>>> The search is case sensitive.
;>>> This macro only works with GCP5 and above.
;
/MSP,++,/XMD,++;
/VLC,;
AL,??,/VIN,2,$VAL,AL,++;
SY,??,/VIN,3,$VAL,SY,++;
/SYS,C,V,/VST,0,$STR;
/STR,S,$S(0),1,1,/VIN,5,$STR;
/IF,$I(5)[LT]5,/GTO,OLDVERSION;
;
/PMT,3,'[ESC] to Cancel',#;
/PMT,2,'[Case sensitive search]',#;
/PMT,1,'Enter Text to Search...> ',#;
/VST,1,~;
/IF,$DERR[EQ]-2,/GTO,EXIT;
/PMT,1,'Text to Search... [',$S(1),']',#;
/PMT,2,'Enter Text to Replace with...> ',#;
/VST,2,~;
/IF,$DERR[EQ]-2,/GTO,EXIT;
;
.SELECT;
/SEL,Select Text Lines to process ...;
/CEL,F,T,!,A,!,L,!;
/VIN,0,$VAL;
/IF,$I(0)[EQ]0,/GTO,EXIT;
/VIN,1,$I(0)+1;
/PMT,3,'[ESC] to Cancel',#;
;
.LOOP;
/IF,$DERR[EQ]-2,/GTO,EXIT;
/VIN,1,$I(1)-1;
/IF,$I(1)[EQ]0,/GTO,EXIT;
/EEX,$I(1),V,8,A,/VST,3,$STR;
/STR,R,$S(3),$S(1),$S(2);
/VST,4,$STR;
/EEX,$I(1),V,8,N,$S(4);
/GTO,LOOP;
;
.OLDVERSION;
/BEEP;
/PMT,1,'< SORRY > This macro only works with GCP5 and above ',#;
/PMT,2,'Please click on [www.generalcadd.com] and check out the new features on offer ',#;
/PMT,3,'Press any key to continue',#,/CIN;
/IF,$STR[EQ]W,/APX,http://www.generalcadd.com,!;
;
.EXIT;
/IF,$I(2)[EQ]0,AL,--;
/IF,$I(3)[EQ]0,SY,--;
/XMD,--,/MSP,--;

Top
#6613 - 12/06/06 09:22 AM Re: TEXT-Search&Replace.gxm
Tom Albright Offline
Member


Registered: 12/11/01
Posts: 833
Loc: Montana
Vincent,

Excellent macro! Very impressive!



Thank you,

Tom
_________________________
Tom

Top
#6614 - 12/06/06 02:48 PM Re: TEXT-Search&Replace.gxm
Milan Offline
Member


Registered: 12/12/01
Posts: 2240
Loc: Brisbane, Queensland, Australi...
Vincent,

The success in macro writing depends on finding a good application.

You certainly did find one! Thank you!

_________________________
Milan

Top
#6615 - 12/07/06 05:26 AM Re: TEXT-Search&Replace.gxm
Milan Offline
Member


Registered: 12/12/01
Posts: 2240
Loc: Brisbane, Queensland, Australi...
Vincent,

for example, I am replacing the words
STORM
OUTLET



with
KERB
ATTACHEMENT



Because of the two text lines above each other I run your macro twice.
_________________________
Milan

Top
#6616 - 12/07/06 10:14 AM Re: TEXT-Search&Replace.gxm
Vincent Offline
Member


Registered: 06/25/02
Posts: 505
Loc: Newcastle, Australia
Tom and Milan,

Thank you for your kind words.
This macro was the least I could do since Matt was kind enough to grant my whish for a new macro command that could handle a Text Search and Replace.

Milan, you've just exposed a limitation of /VST in that it can only capture a single line of text when entered from the keyboard.
I have a work around that might get you out of that bind. Try this version and let me know what you think.

Thanks for your comments. It's well appreciated.

Vincent

;>>> TEXT-Search&Replace.GXM
;>>> Search and replace text on your drawing.
;>>> Written by: Vincent Ferrara 2006
;**************************************************
;>>> Description:
;>>> FIrstly, enter the text you want to find.
;>>> Secondly, enter the text you wish to replace it with.
;>>> Thirdly, select the text to process.
;>>> The search is case sensitive.
;>>> This macro only works with GCP5 and above.
;
/MSP,++,/XMD,++;
/VLC,;
MO;
AL,??,/VIN,2,$VAL,AL,++;
SY,??,/VIN,3,$VAL,SY,++;
/SYS,C,V,/VST,0,$STR;
/STR,S,$S(0),1,1,/VIN,5,$STR;
/IF,$I(5)[LT]5,/GTO,OLDVERSION;
/EXT,S,1,2;
/GET,TextExplode,/VIN,6,$VAL;
/SET,TextExplode,0;

;
.SEARCH;
/PMT,3,'Press [ESC] TO CONTINUE AFTER ENTERING TEXT',#;
/PMT,2,'[Case sensitive search]',#;
/PMT,1,'Enter Text to Search...> ',#;
TL,$X(2)+100,$Y(2)+100,~;
/IF,$DERR[EQ]-2,/GTO,EXIT;
OO;
/VST,1,$STR;
.REPLACE;
/PMT,1,'Text to Search... [',$S(1),']',#;
/PMT,2,'Enter Text to Replace with...> ',#;
TL,$X(2)+100,$Y(2)+100,~;
/IF,$DERR[EQ]-2,/GTO,EXIT;
OO;
/VST,2,$STR;
;
.SELECT;
/PMT,2,'And Replacing with... [',$S(2),']',#;
/PMT,3,'[RET] to Select Text lines to process or [ESC] to Cancel',#,/CIN;
/IF,$DERR[EQ]-2,/GTO,EXIT;
/SEL,Select Text Lines to process ...;
/CEL,F,T,!,A,!,L,!;
/VIN,0,$VAL;
/IF,$I(0)[EQ]0,/GTO,EXIT;
/VIN,1,$I(0)+1;
/PMT,3,'[ESC] to Cancel',#;
;
.LOOP;
/IF,$DERR[EQ]-2,/GTO,EXIT;
/VIN,1,$I(1)-1;
/IF,$I(1)[EQ]0,/GTO,EXIT;
/EEX,$I(1),V,8,A,/VST,3,$STR;
/STR,R,$S(3),$S(1),$S(2);
/VST,4,$STR;
/EEX,$I(1),V,8,N,$S(4);
/GTO,LOOP;
;
.OLDVERSION;
/BEEP;
/PMT,1,'< SORRY > This macro only works with GCP5 and above ',#;
/PMT,2,'Please click on [www.generalcadd.com] and check out the new features on offer ',#;
/PMT,3,'Press any key to continue',#,/CIN;
/IF,$STR[EQ]W,/APX,http://www.generalcadd.com,!;
;
.EXIT;
/IF,$I(2)[EQ]0,AL,--;
/IF,$I(3)[EQ]0,SY,--;
WD,$X(1),$Y(1),$X(2),$Y(2);
/IF,$I(6)[EQ]1,/SET,TextExplode,1;
/XMD,--,/MSP,--,PU;

Top
#6617 - 12/07/06 10:57 AM Re: TEXT-Search&Replace.gxm
Tom Albright Offline
Member


Registered: 12/11/01
Posts: 833
Loc: Montana
Nice upgrade, Vincent! Thanks!!

Though I didn't know at first that I had to hit ENTER after entering text. I just hit ESC and the drawing went away.

Tom
_________________________
Tom

Top
#6618 - 12/07/06 06:20 PM Re: TEXT-Search&Replace.gxm
Vincent Offline
Member


Registered: 06/25/02
Posts: 505
Loc: Newcastle, Australia
Tom.
Your drawing disappearing was a misplaced OO (Undo);
Thanks for pointing that out.
See my edits below.

Vincent

Top
#6619 - 12/07/06 11:06 PM Re: TEXT-Search&Replace.gxm
Milan Offline
Member


Registered: 12/12/01
Posts: 2240
Loc: Brisbane, Queensland, Australi...
Vincent,

Great ! Thanks !!

Before you up-load it please change the typo in PMT: from continure to continue
_________________________
Milan

Top
#6620 - 12/07/06 11:53 PM Re: TEXT-Search&Replace.gxm
Bjorn Holmgren Moderator Offline
Member


Registered: 12/12/01
Posts: 2586
Loc: Sydney Australia
Vincent, you might want to include /GET & /SET,TextExplode as you are providing for a multi textline.
Top
#6621 - 12/08/06 12:00 AM Re: TEXT-Search&Replace.gxm
Vincent Offline
Member


Registered: 06/25/02
Posts: 505
Loc: Newcastle, Australia
Milan,

Thanks for the heads up on that. \:o
I normally run the spell check before posting but as you can see it was in the wee hours of the morning when I posted that.

I'll keep it here for a while more and if everything works out OK I'll up=load it on Monday.

Vincent

Top
#6622 - 12/08/06 02:17 AM Re: TEXT-Search&Replace.gxm
Vincent Offline
Member


Registered: 06/25/02
Posts: 505
Loc: Newcastle, Australia
Bjorn,

Thanks for that insight. I hadn't realized it was there. I guess I have some reading to do.

See my edits below.

Although this work around for multi text line support does the job, I still would prefer /STR,R to have the ability to recognize a carriage return has been used instead of a space.
I guess Matt can answer this one.

Vincent

Top
#6623 - 12/08/06 06:12 AM Re: TEXT-Search&Replace.gxm
Bjorn Holmgren Moderator Offline
Member


Registered: 12/12/01
Posts: 2586
Loc: Sydney Australia
A case for a new variable accepting a multiline string?
or ...
/VST,1,~~; ?

Top
#6624 - 12/08/06 07:13 AM Re: TEXT-Search&Replace.gxm
Milan Offline
Member


Registered: 12/12/01
Posts: 2240
Loc: Brisbane, Queensland, Australi...
Vincent,

At this stage of this development I can say your macro is consistent to how the multilines of text are entered when TL.
_________________________
Milan

Top
#6625 - 12/09/06 05:14 AM Re: TEXT-Search&Replace.gxm
Bjorn Holmgren Moderator Offline
Member


Registered: 12/12/01
Posts: 2586
Loc: Sydney Australia
Milan,

I don't get your point. The macro works with a workaround, as Vincent points out, because we don't have a way to directly input a multi line text into a string variable .

It's too late for V5 but we should look at that for V6 BETA.

Bjorn

Top
#6626 - 12/09/06 06:00 AM Re: TEXT-Search&Replace.gxm
Milan Offline
Member


Registered: 12/12/01
Posts: 2240
Loc: Brisbane, Queensland, Australi...
Bjorn,

For Search I type first line, enter, second line, enter, Esc then respectivelly for the Replace.
The same as it goes in TL.

Of course, I am not trying to obstruct an improvement in macro language, I am just congratulating to Vincent for his fine work.
_________________________
Milan

Top
#6627 - 12/09/06 06:45 AM Re: TEXT-Search&Replace.gxm
Vincent Offline
Member


Registered: 06/25/02
Posts: 505
Loc: Newcastle, Australia
Guys,

There is a simple solution which is hidden in there but not quite working.

Try this:

/VST,1,~;

Use Ctrl+Enter to enter a second line of text then press Enter to finish.

/SHOWVARS;
This will show two text lines for String 1.

TL,@,$S(1),#;
This will show a single line of text.

If Matt can fix that then the prompt would be

/PMT,1,'Enter Text to Search...> ',#;
/PMT,2,'Use Ctrl+Enter for multi line input',#;

Vincent

Top
#6628 - 12/09/06 11:49 AM Re: TEXT-Search&Replace.gxm
Matt Administrator Offline
Member


Registered: 03/28/02
Posts: 3975
Loc: Spokane, WA
Vincent,

Do you know of any app with a Search and Replace that will allow multiple lines to be replaced by multiple lines? I don't think even Word can do that.

We're trying to get GCP5 out the door, so I can't put much into this right now. Let's talk after release.

Please send the gxm to Jim so he can update the Utility Link page.

Great work Vincent!

Matt

Top
#6629 - 12/09/06 06:36 PM Re: TEXT-Search&Replace.gxm
Bjorn Holmgren Moderator Offline
Member


Registered: 12/12/01
Posts: 2586
Loc: Sydney Australia
Matt, Vincent,

$S(1) can hold a multiline text string.
It seems natural logic to look for a way to directly input that into the variable. It can now be input only indirectly with /STR commands and via TL. TL is the smart workaround as is in my view. Yes, let's talk in V6.

Bjorn

Top
#6630 - 12/09/06 08:09 PM Re: TEXT-Search&Replace.gxm
Vincent Offline
Member


Registered: 06/25/02
Posts: 505
Loc: Newcastle, Australia
Matt,

I too was surprised the MS Word didn't have that feature for Search & Replace.

Editpadlite has that feature but uses Shift+Enter for multi line entry.

I'm sure this method is the best way to go.
No need for separate commands.

I think the macro is pretty stable now.
Uploading it today.
A special thanks to Tom, Milan and Bjorn for their contribution.

Vincent

Top
#6631 - 06/05/07 06:35 PM Re: TEXT-Search&Replace.gxm
James Dowmont Offline
Member


Registered: 02/27/07
Posts: 297
Loc: Tyler, TX
I have been using this frequently, lately, and I have a question. Is it possible to call this in a macro and set it up to fill in the criteria I need each time? I realize I could save the macro file with a new name and do it that way. Just wondering if this was also possible. I have certain irritating S&R routines I do on a semi regular basis.
_________________________
James Dowmont

Top
#6632 - 06/06/07 05:01 AM Re: TEXT-Search&Replace.gxm
Vincent Offline
Member


Registered: 06/25/02
Posts: 505
Loc: Newcastle, Australia
James,

Try this variation of the macro.
You can then modify your Side Menu to suit your own Search and Replace strings.

The only downside is that it cannot handle multi-lined strings. Hopefully Matt can come to the rescue for GCP6.

Hope it works out for you.

Vincent

[Edit: Added instructions for multi-line text]

;>>> TEXT-Search&Replace-Menu.GXM
;>>> Menu driven Search and replace text on your drawing.
;>>> Written by: Vincent Ferrara 2007
;**************************************************
;>>> Description:
;>>> Variation of TEXT-Search&Replace.GXM to run off the Side Menu.
;>>> The user can then modify the Side Menu to run pre-set Seach and Replacs strings.
;>>> eg.
;>>> Screws > Fixings,/VST,1,Screws,/VST,2,Fixings,LB,TEXT-Search&Replace-Menu.GXM;
;>>> Or for text spanning multiple lines use Concatenation.
;>>> Note 1 > Note 2,/STR,C,First line,%%CR%%,Second line,%%CR%%,Third line,#,/VST,1,$STR,/STR,C,Line One,%%CR%%,Line Two,%%CR%%,Line Three,#,/VST,2,$STR,LB,TEXT-Search&Replace-Menu.gxm;

;
/MSP,++,/XMD,++;
MO;
AL,??,/VIN,2,$VAL,AL,++;
SY,??,/VIN,3,$VAL,SY,++;
;
.SELECT;
/PMT,1,'Text to Search... [',$S(1),']',#; $S(1) issued from Menu
/PMT,2,'And Replacing with... [',$S(2),']',#; $S(2) issued from Menu
/PMT,3,'[RET] to Select Text lines to process or [ESC] to Cancel',#,/CIN;
/IF,$DERR[EQ]-2,/GTO,EXIT;
/SEL,Select Text Lines to process ...;
/CEL,F,T,!,A,!,L,!;
/VIN,0,$VAL;
/IF,$I(0)[EQ]0,/GTO,EXIT;
/VIN,1,$I(0)+1;
/PMT,3,'[ESC] to Cancel',#;
;
.LOOP;
/IF,$DERR[EQ]-2,/GTO,EXIT;
/VIN,1,$I(1)-1;
/IF,$I(1)[EQ]0,/GTO,EXIT;
/EEX,$I(1),V,8,A,/VST,3,$STR;
/STR,R,$S(3),$S(1),$S(2);
/VST,4,$STR;
/EEX,$I(1),V,8,N,$S(4);
/GTO,LOOP;
;
.EXIT;
/IF,$I(2)[EQ]0,AL,--;
/IF,$I(3)[EQ]0,SY,--;
WD,$X(1),$Y(1),$X(2),$Y(2);
/XMD,--,/MSP,--,PU;

Top
#6633 - 06/06/07 09:13 AM Re: TEXT-Search&Replace.gxm
James Dowmont Offline
Member


Registered: 02/27/07
Posts: 297
Loc: Tyler, TX
Very cool, indeed. Thanks Vincent.
_________________________
James Dowmont

Top
#6634 - 06/07/07 10:50 AM Re: TEXT-Search&Replace.gxm
Vincent Offline
Member


Registered: 06/25/02
Posts: 505
Loc: Newcastle, Australia
James,

Apparently you can allocate a multi-lined string variable. You have to concatenate a carriage return %%CR%%.

For example in Milan's case (See his posting below) he can put this in his menu.

STORM OUTLET > KERB ATTACHMENT,/STR,C,STORM,%%CR%%,OUTLET,#,/VST,1,$STR,/STR,C,KERB,%%CR%%,ATTACHMENT,#,/VST,2,$STR,LB,TEXT-Search&Replace-Menu.gxm;

Vincent

Top
Page 1 of 1 1


Moderator:  Bjorn Holmgren 
Hop to:
Search
Who's Online
0 registered and 5 anonymous users online.
Newest Members
Gen, vjs.314, jhindmand28, Kenneth Reece, heleana
1460 Registered Users
Forum Stats
1460 Members
24 Forums
3127 Topics
22833 Posts

Max Online: 46 @ 09/08/07 06:17 AM
July
Su M Tu W Th F Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

Generated in 0.103 seconds in which 0.089 seconds were spent on a total of 13 queries. Zlib compression enabled in php.ini