Groumphy Posted June 5, 2005 Posted June 5, 2005 (edited) Hello,By traversing the forums, I noted that certain questions often returned.For example: to rename a file, to start a file, etc.I joined together here the various solutions given : creating of alias.I hope that that will be able to help certain person to understand the operation of the function seeks (search).Obviously the names, attributes etc are changeable. If you have other ideas, do not hesitate with me to send them by private message.Do not hesitate to correct me if faults were made. 've nice day,GroumphyEdit : I edited the post. I removed the code and I posted a new version of _ alias.au3... Yours sincerely, G.Edit : 11.06.05 - Added (_alias.au3):_FileFindText_MSDosName_EraseContentOfTxtFile_MonitorOff_MonitorOn_Mount_MountDel_GUICtrlCreateInputWithLimit11.06.05 - Deleted (_alias.au3):_FilePrint_DateHeure_FindStringInTextfile11.06.05 - Added (_globalfunction.au3 [New file !]):_FilePrint_DateHeure_FindStringInTextfile_Monitor_Fade_alias.au3_globalfunctions.au3 Edited June 11, 2005 by Groumphy ----------------------GroumphyMore information about me [Fr]
MHz Posted June 5, 2005 Posted June 5, 2005 Very nice collection, Groumphy. The 1st covers the change with the Start command, has caused some headaches to some. On the functions with Return 1 or 0. You may need to be specify a return 1 for success. Returns do need to be explicit now, with the introduction of the new beta's. Example: If FileMove() becomes true, then it will return 1 (true) ; Rename a file ; Author : Groumphy ; Alias of FileMove() Func _Rename($iPath, $iOldName, $iNewName) ; success : 1 ; failure : 0 If FileMove($iPath & "\" & $iOldName, $iPath & "\" & $iNewName) Then Return 1 EndFunc; ==> _Rename("C:", "OldFichier.mp3", "NewFichier.mp3") This now will return 1, which means true (success). So now you can use it as such: If _Rename(...) Then ; Do something if true Else ; Do something if false, meaning that the function returned 0 EndIf Thanks for sharing.
Groumphy Posted June 5, 2005 Author Posted June 5, 2005 Ok, I correct the functions with return of 1 or 0 according to the conditional stucture which you gave. ----------------------GroumphyMore information about me [Fr]
Groumphy Posted June 5, 2005 Author Posted June 5, 2005 Best is to make like this : Func _Ren($iOldFile, $iNewFile) ; succes : 1 ; failure : 0 If FileMove($iOldFile, $iNewFile) Then Return 1 Else Return 0 EndIf EndFunc; ==> _Ren("C:\OldFile.mp3", "C:\NewFile.mp3") Or like this: Func _Ren($iOldFile, $iNewFile) ; succes : 1 ; failure : 0 If FileMove($iOldFile, $iNewFile) Then Return 1 EndFunc; ==> _Ren("C:\OldFile.mp3", "C:\NewFile.mp3") Or to define the @ERROR ? If @ERROR Then Return 0 ?? ----------------------GroumphyMore information about me [Fr]
Valik Posted June 5, 2005 Posted June 5, 2005 Ummm.... are you guys smoking crack? Do none of you see the obvious solution: Func _Ren($iOldFile, $iNewFile) Return FileMove($iOldFile, $iNewFile) EndFunc
Groumphy Posted June 5, 2005 Author Posted June 5, 2005 Ok, for each function which has a result (Return) I would make as you indicate it... Afflicted my ignorance ; I thus modify the file _ ALIAS.AU3 as indicated ! ----------------------GroumphyMore information about me [Fr]
MHz Posted June 5, 2005 Posted June 5, 2005 @Groumphy Valik's concept is the most direct, so yes. Whether you use return on it's own(false). return 0 (false), Return 1 (true) or as Valik has shown, Return func(). The return func() is shorter and more to the point. The func() returns 0 or 1, so it is the same. Feel like a dog chasing my tail after typing that. But I do not touch the light stuff, Valik. Let see what you come up with, Groumphy.
Groumphy Posted June 5, 2005 Author Posted June 5, 2005 Best for me is than that likes has all in all the fields. Personally I prefer to use the method If Function() Then Return X Else Return Y EndIf But if a developer says that it is better like that, I adopt too. Aillor I already very changed and I hope more to change (Now that it is in order)... Tomorrow I reposte the changed file. I would put it regularly up to date. ----------------------GroumphyMore information about me [Fr]
Groumphy Posted June 7, 2005 Author Posted June 7, 2005 (edited) "A promise is a promise".The corrections have summers made according to councils' of Valik. Edit : I edited the post. I removed the code and I posted a new version of _ alias.au3... Yours sincerely, G. [see on the top] Edited June 11, 2005 by Groumphy ----------------------GroumphyMore information about me [Fr]
Groumphy Posted June 11, 2005 Author Posted June 11, 2005 Updated : 11.06.05 ----------------------GroumphyMore information about me [Fr]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now