Jump to content

DirCreate Return values


Recommended Posts

Good day,

I very much enjoy Autoit. However, I do find the Helpfile rather confusing at times.

For example. DirCreate...am I not able to employ the return values of DirCreate "on its own" - without the need for "FileExists"...as the Helpfile example displays?

DirCreate("C\Me")
Local $Result = ""
    If $Result = 1 Then ; Success??
        MsgBox($MB_SYSTEMMODAL, "", "The .edl folder was created successfully!")
    Else ; Failure??
        MsgBox($MB_SYSTEMMODAL, "", "The .edl folder was not created successfully!")
    EndIf

 

Edited by mr-es335
Link to comment
Share on other sites

Good day,

I did...finally ...come across this little tid-bit:

$error = DirCreate("C:\Folder1")
MsgBox(0,'$error',$error)

Source: [Iod3n]

As long as the destination can be written to, then the error will return "1"! Correct"?

Following, is my updated example:

Local $error = DirCreate("C:\Folder1")
    If $error = 0 Then
        MsgBox(0, "NOTICE!", "Folder was not created", $error)
    Else
        MsgBox(0, "NOTICE!", "Folder was created", $error)
    EndIf

Question: May I ask, in the first example, the $error value is displayed...but not in the second example...why?

Link to comment
Share on other sites

  • Moderators

mr-es335,

In your first script, where do you store the return value from the DirCreate function? How can you check it when you have no idea what it is? All you are checking is the value of the $result variable - which you have just set to "" and so makes any checking completely pointless.

In the second set of scripts you are storing the return value, but I would question your use of $error as the variable name as it would appear to me to be the exact reverse of that and better named $iSuccess! And as to why the return value is not shown in the latter of the 2 scripts - perhaps you should look carefully at how many parameters are you passing to the MsgBox functions?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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