Jump to content

Recommended Posts

Posted

Good day,

In the following two examples, which of the two would be preferred and why? Any clarification would be greatly appreciated!

; -----------------------------------------------
; Example #A
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Uninstall_App()

Func Uninstall_App()
    Local $src_folder = "C:\App"
    ; -----------------
    If FileExists($src_folder) Then
        If DirRemove($src_folder, 1) = False Then Shutdown(0) ; Direct use of command
        ; -----------------
        MsgBox(4096, "Result", "Folder Deleted Successfully")
    Else
        MsgBox(4096, "Result", "Folder does not exist")
    EndIf
EndFunc   ;==>Uninstall_App
; -----------------------------------------------
; -----------------------------------------------
; Example #B
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Uninstall_App()

unc Uninstall_App()
    Local $src_folder = "C:\App"
    ; -----------------
    If FileExists($src_folder) Then
        Local $bDirRemove = DirRemove($src_folder, 1) ; Use of a variable
            If $bDirRemove = False Then Shutdown(0)
    ; -----------------
    MsgBox(4096, "Result", "Folder Deleted Successfully")
    Else
        MsgBox(4096, "Result", "Folder does not exist")
    EndIf
EndFunc   ;==>Uninstall_App
; -----------------------------------------------

So, my questions then are:

Q1: "A or B?"
R1:

Q2: "Why?"
R2:

Thank you all for your time....appreciated!

Posted
12 minutes ago, paw said:

Only capture the result in a variable if you need it

my edit if you missed it, an example would be if you want to log the outcome or use it further down in the code

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
×
×
  • Create New...