Sign in to follow this  
Followers 0
GaryFrost

GuiCtrlEdit Find and Replace UDF

18 posts in this topic

#1 ·  Posted (edited)

Put this together real quick, maybe someone will find it usefull.

Edit: Added functionality to work with external edit controls (Only tested with notepad)

Edit: a DUH on my part, forgot to decrement the occurance counter if string is replaced

Added: TestFind2.au3 example for external edit control

Removed Attatchments: Submitted for beta UDFs to be added to GuiEdit Management on 2/22/06

Gary

http://www.autoitscript.com/fileman/users/gafrost/GuiCtrlEditFind.JPG

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites



Sorry that i ask , but this is very simple :S if you wanna make this you spent 5 min time in it and you are done


-jaenster

Share this post


Link to post
Share on other sites

Sorry that i ask , but this is very simple :S if you wanna make this you spent 5 min time in it and you are done

Where is the question in that statement?


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Tightened up the search some, and added a message box if not found

Also added status bar for # of replacements made.

See 1st post for source and test file


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

that look nice Gary...

I will definately use that

thanks

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

oh wow :o. ill also Use this script. Thanks.


[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites

Added functionality to work with external edit controls (Only tested with notepad)

Example script updated also, tests autoit gui and notepad edit

Enjoy.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

@gafrost: Nice job.

I noticed only a weird behavior, sometimes replacing, for example, "test" with "au3", the replace doesn't replace in order (line by line).

Anyways, thanks.

Share this post


Link to post
Share on other sites

In _GuiCtrlEditFind.au3 file in the beta examples, the $b_replace parameter in the call is to the right of two optional parameters and is assigned as False. As a result you can never pass it a True to do a replace. I have attached a modified file with $b_replace moved to the 3rd parameter. Please see the lines commented with "***" to see other changes. I added _GUICtrlEditScroll($h_edit, $SB_SCROLLCARET) after both the search and replace functions in order to bring the cursor into view. As a cosmetic thing, I made the Find popup 200 pixels high so that the Close button is not partially chopped off.

There is still a bug that I am looking into. When you do a find and replace, it doesn't always go to the next find string. Kind of jumps around and skips a few instances.

Suggestions, not bugs: You might consider adding a Wrap/NoWrap box. You won't always want to wrap around and it would also be nice to know when you are done! Suggest putting this function in the GUIEdit.au3 include file.

WFC

GuiCtrlEditFind.au3

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

In _GuiCtrlEditFind.au3 file in the beta examples, the $b_replace parameter in the call is to the right of two optional parameters and is assigned as False. As a result you can never pass it a True to do a replace. I have attached a modified file with $b_replace moved to the 3rd parameter. Please see the lines commented with "***" to see other changes. I added _GUICtrlEditScroll($h_edit, $SB_SCROLLCARET) after both the search and replace functions in order to bring the cursor into view. As a cosmetic thing, I made the Find popup 200 pixels high so that the Close button is not partially chopped off.

There is still a bug that I am looking into. When you do a find and replace, it doesn't always go to the next find string. Kind of jumps around and skips a few instances.

Suggestions, not bugs: You might consider adding a Wrap/NoWrap box. You won't always want to wrap around and it would also be nice to know when you are done! Suggest putting this function in the GUIEdit.au3 include file.

WFC

1st your posting a bug report to a scripts and scraps udf, i forgot to upload an updated example script to match the udf

2nd there is a bug in the udf, but far as i can tell it's my bug

this should not have been posted in bug reports, but a reply added to that thread.

See the thread in scripts and scraps, fixed

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

@gafrost: Nice job.

I noticed only a weird behavior, sometimes replacing, for example, "test" with "au3", the replace doesn't replace in order (line by line).

Anyways, thanks.

Fixed see first post for scripts

a DUH on my part, forgot to decrement the occurance counter if string is replaced


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

wrong bug report merge as suggested by gafrost

Share this post


Link to post
Share on other sites

Great! This is nice... I was wondering if their are any UDF's for searching and replacing a string inside of a file...?

Share this post


Link to post
Share on other sites

Great! This is nice... I was wondering if their are any UDF's for searching and replacing a string inside of a file...?

Thanks, I'm still re-fining this one.

try http://www.autoitscript.com/forum/index.php?showtopic=21797


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

1st your posting a bug report to a scripts and scraps udf, i forgot to upload an updated example script to match the udf

2nd there is a bug in the udf, but far as i can tell it's my bug

this should not have been posted in bug reports, but a reply added to that thread.

See the thread in scripts and scraps, fixed

Sorry Gary. I got it out of Examples folder and thought it was a part of AutoIt, but I remember now that I got it after asking about something like this and you were the one who pointed me to it.

It seems to me that it would be a good UDF to add to the Includes. I added it in my program and left the _GUICtrlEditScroll's I had added to my "fix" file in the script I uploaded because I aways want the highlighted text to appear in the edit window. Now if it is put in the includes I will have to change the function name in my program so I can keep the one I am now using.

The replace is indeed fixed. It works fine now. Thanks.

\/\/FC

Share this post


Link to post
Share on other sites

Sorry Gary. I got it out of Examples folder and thought it was a part of AutoIt, but I remember now that I got it after asking about something like this and you were the one who pointed me to it.

It seems to me that it would be a good UDF to add to the Includes. I added it in my program and left the _GUICtrlEditScroll's I had added to my "fix" file in the script I uploaded because I aways want the highlighted text to appear in the edit window. Now if it is put in the includes I will have to change the function name in my program so I can keep the one I am now using.

The replace is indeed fixed. It works fine now. Thanks.

\/\/FC

Removed Attatchments: Submitted for beta UDFs to be added to GuiEdit Management on 2/22/06 (9am)

Already had.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Removed Attatchments: Submitted for beta UDFs to be added to GuiEdit Management on 2/22/06 (9am)

Already had.

Great! Have you noticed that it sometimes misses a click on search? Click again and it will do it.

Try testing with a file larger than the edit. If it finds a string after the part that is displayed, it doesn't scroll to it so that you can see it. I like to see what I have searched for. :o

Any chance of a wrap option?

WFC

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Great! Have you noticed that it sometimes misses a click on search? Click again and it will do it.

Should be fixed

Try testing with a file larger than the edit. If it finds a string after the part that is displayed, it doesn't scroll to it so that you can see it. I like to see what I have searched for. :o

Auto Scrolls selected text into view

Any chance of a wrap option?

If exact match is not turned on it auto wraps, other wise you'll get a message box stating it has reached the end of the document, just hit the find again and it will start from the beginning.

Gary

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0