Prepare your riot guns guys !
I hope my previous post was not too dry ...
To correct this eventuality, I hope you'll be pleased with this illustration.
You will now be allowed to shoot at me for the reason you prefer : this code is faulty, misconstructed, puzzling for newbees, makes easy things harder, or whatever you'll find !
code:
;Trying To Create A Folder If Necessary
$FolderNameToCheck = "C:\ScriptTest"
$Result = -1
If Exist($FolderNameToCheck)
If GetFileAttr($FolderNameToCheck) & 16
$Result = 1
Else
$Result = -2
EndIf
Else
MD $FolderNameToCheck
$CommandError = @Error
$CommandSError = @SError
If $CommandError = 0
$Result = 0
Else
$Result = -3
$CommandError = CStr($CommandError)
EndIf
EndIf
Select
Case $Result = 0
? "Folder " + $FolderNameToCheck + " Successfully Created"
Case $Result = 1
? "Folder " + $FolderNameToCheck + " Already Exists"
Case $Result = -2
? "Can't create Folder " + $FolderNameToCheck
? "Duplicated File/Folder Name"
Case $Result = -3
? "An Error Has Occured During " + $FolderNameToCheck + " Folder Creation"
? "[" + $CommandSError + "] " + $CommandSError
Case 1
? "UnExpected Result"
EndSelect
If $Result >= 0
? "Ok, We Can Go On"
Else
? "Something Has Happend, We Have To Check "
EndIf
That was my attempt to prevent unexpected errors in my own scripts.
I'm sure you'll find easier, safer or more pertinent ways and I'd be glad to hear from you ...