Jump to content

Recommended Posts

Posted (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,

Groumphy

Edit : 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

_GUICtrlCreateInputWithLimit

11.06.05 - Deleted (_alias.au3):

_FilePrint

_DateHeure

_FindStringInTextfile

11.06.05 - Added (_globalfunction.au3 [New file !]):

_FilePrint

_DateHeure

_FindStringInTextfile

_Monitor

_Fade

_alias.au3

_globalfunctions.au3

Edited by Groumphy

----------------------GroumphyMore information about me [Fr]

Posted

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.

Posted

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]

Posted

Ummm.... are you guys smoking crack? Do none of you see the obvious solution:

Func _Ren($iOldFile, $iNewFile)
    Return FileMove($iOldFile, $iNewFile)
EndFunc
Posted

@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.

Posted

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]

Posted (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 by Groumphy

----------------------GroumphyMore information about me [Fr]

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...