Inserting statements after a certian statement in programs

General questions about using WildEdit

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

moombaroo
Posts: 8
Joined: Tue Feb 16, 2010 10:58 pm

Inserting statements after a certian statement in programs

Post by moombaroo »

I have a difficult programming language (ActionScript) that I am trying to deal with that as very limited debugging tools. I would link to use WildEdit to add TRACE statments at the start of every method. Below is an example.


HistoryPopupDM.prototype.getAuditData = function() {
return this.auditList;
}

HistoryPopupDM.prototype.getActivityData = function() {
return this.activityList;
}

HistoryPopupDM.prototype.$zeroPad = function(num) {
if (num < 10) {
return "0" + num;
}

return num;
}

After every method definition statement (ones with = function { ), I would like to insert a statement like this:

if (this.TRACE_ON) trace("In xxxxxxxxxxxxxxx");

Where xxxxxxxxxxxxxxx is the name preceeding the = (equals sign). In this example it would be "HistoryPopupDM.prototype.getAuditData", "HistoryPopupDM.prototype.getActivityData" and "HistoryPopupDM.prototype.$zeroPad".

IF possible I would like the
if (this.TRACE_ON) trace("In xxxxxxxxxxxxxxx");
statement on a separate like.

Can anyone give me some suggestions how I might achive this in WildEdit? 8)
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find what:
^(.*) = function\(.*\{

Replace with:
$0
if (this.TRACE_ON) trace("In $1");


[X] Regular expression
[X] Replacement format

Options
[X] '.' does not match a newline character

Literal line break characters: [as appropriate for your files]
moombaroo
Posts: 8
Joined: Tue Feb 16, 2010 10:58 pm

Post by moombaroo »

Thanks for the quick response.

[X] Regular expression
[X] Replacement format

Options
[X] '.' does not match a newline character


The above specification you include in your response area confusing to me?
I clicked "Regular expression" but I do not see the "Replacement format" or "'.' does not match a newline character " checkboxes. I do find a "'.' matches a newline character" and I am leaving that unchecked.

Also when I run it, the replacements are showing $o and $1 an not resolving as arguments as it looks like you intended.

Thanks in advance.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You are using WildEdit, aren't you? Which version?
moombaroo
Posts: 8
Joined: Tue Feb 16, 2010 10:58 pm

Post by moombaroo »

oops..... Yeah WildEdit.......... Version 2.0 Evaluation Copy
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

In my copy of WildEdit, version 2, Replacement format is immediately below Regular expression on the Replace tab, and '.' does not match any line break characters (the wording I used earlier must be from an older version) is the third item below Common regular expression options on the Options tab. Literal line break characters is at the bottom of the Options tab.
moombaroo
Posts: 8
Joined: Tue Feb 16, 2010 10:58 pm

Post by moombaroo »

Are you using the licenced copy or trial copy? Maybe the features are different. I was kina trying to evaluate the product with this example.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

There are no differences in the options. I have no idea why what you are seeing is different from what I am seeing.

Keith - Do you know what the problem is here?
moombaroo
Posts: 8
Joined: Tue Feb 16, 2010 10:58 pm

Post by moombaroo »

wow, Replacement format, .' does not match any line break characters are not there as you discribe. Literal line break characters is though.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

I have the licensed version of WildEdit 2.0

Does not have the options described by ben_josephs.

On the Replace tab there is an unchecked box labeled: "."matches end of line characters.

On the second tab, "Options", there is a check box for Replacement Format with three radio optiones:Perl/Extended/Simple

Under Common Regular Exptessions, there are only two options, neither of them match the "third option" that is referenced.
Hope this was helpful.............good luck,
Bob
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Oh, I see what has happened. ON XP SP2 I installed WildEdit version 2 over version 1. The installer told me it had installed version 2, and the program told me that it was version 2. But it wasn't.

So I removed WildEdit altogether and installed it afresh. That gave me an incomplete and unusable version. So I installed it again, and now I have a version of WildEdit that looks like yours.

I'm sorry for the confusion.

Keith - there's something wrong with the WildEdit 2 installer.

Use these settings:
Replace tab:
[ ] Literal replacement [i.e., not selected]

Options tab:
Regular expression syntax:
(X) Perl/ECMAScript or
(X) POSIX extended

Replacement format syntax:
(X) Perl or
(X) Extended
moombaroo
Posts: 8
Joined: Tue Feb 16, 2010 10:58 pm

Post by moombaroo »

Cool ben_josephs, it llooks like you got somthing out of helping me.

Now back to my problem. 2 things.

1) I think I had a typo in my original post. I left out the parathasees in my request. The example has it, but not my request. Now the
parathasees can be empty or have something in them. So I shorted you Search for to ^(.*) = function and the find works. But I am not sure that is best.

2) The replace is literally replacing as show below.

$0
if (this.TRACE_ON) trace("In $1");() {
return this.auditList;
}

$0
if (this.TRACE_ON) trace("In $1");() {
return this.activityList;
}

$0
if (this.TRACE_ON) trace("In $1");(num) {
if (num < 10) {
return "0" + num;
}

return num;
}

Part of th problem looks like its because I shortened the Search for. The other part is the $0 and $1. I am guessing the we would expect that these are Replace with Expression Arguments. $0 should resolve to the whole original line found and $1 should resolve to everything on the line found up to the space. Seem like a good idea, but maybe I don't have a option set that would resolve them.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

There was no need to change the search expression I suggested.
Did you use the options I suggested?
moombaroo
Posts: 8
Joined: Tue Feb 16, 2010 10:58 pm

Post by moombaroo »

Yes, I used these options

Replace tab:
[ ] Literal replacement [i.e., not selected]

Options tab:
Regular expression syntax:
(X) Perl/ECMAScript or
( ) POSIX extended

Replacement format syntax:
(X) Perl or
( ) Extended
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Did you click Apply? Please check.
Post Reply