topten

Duplicate functions remover (rename)

3 posts in this topic

Sometimes we have such situations when udfs have duplicate functions. If you have 1 or 2 duplicates, it is still ok to handle. But if you have a long list of them? Once I had to spend almost one hour dealing with this. You have to run the script, then you get a message "Duplicate Function...." Then you open that udf and you deicde what to do with that.

 

My solution is quite simple. I rename them. Simply rename Function Somefunction() to Function Somefunction2() Or as you like it

Here is the udf, you may use it and modify as you like

Usage:

1.Compile it and run

2. Choose the file which would be modified (which has duplicate functions)

3. Run the script which you are testing from Scite

4. When you see the message: Duplicate function.... Press F2- the function will be renamed

#cs
Duplicate functions remover (rename) by Topten
#ce
#AutoIt3Wrapper_Run_AU3Check=n
 HotKeySet("{F2}", "capture")
 #RequireAdmin
 #include <File.au3>
$sFileOpenDialog = FileOpenDialog("Choose file", @WindowsDir & "\", "AutoIt(*.au3)"); Choose the file which will be modified



while 1()





    wend


func capture()
$sText = WinGetText("[ACTIVE]")
$infoarray = StringRegExp($sText, '(?s)Duplicate function name.*(Func.*?)\(', 3)
$iRetval = _ReplaceStringInFile($sFileOpenDialog, $infoarray[0], $infoarray[0]&"2")
EndFunc

Enjoy :)

Share this post


Link to post
Share on other sites



Your While loop needs a sleep inside it? Your While loop is also written wrong and will cause an error as soon as you run it BTW. There is no function 1() in your script.

Why are you getting the text from a window if you're opening a file in the beginning of the script? What is supposed to be in this window that you need the text from, and what window is it supposed to be?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Never had an error with while 1()  end... Perhaps I used wrong syntax before, correct me if I am wrong

While wend doesnt need sleep, otherwise the hotkey may not run the function, what do you think?

I am opening the file for editing- this is a file of some .au3 which may have duplicates and it is included in your testing script

I am getting the scite text from the testing script in case if it has duplicate fun error. These are 2 different files

 

 

 

 

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