4d / docs

Products Documentation
Creative Commons Attribution 4.0 International
6 stars 20 forks source link

Folder Class ".create()" Example 2 Incorrect. #340

Open Angel-Vazquez opened 4 months ago

Angel-Vazquez commented 4 months ago

When invoking .create(), the boolean return false if the folder already exists.

image

Therefore, example 2 is incorrect and should be re-written to ensure the status of function .exists before the "Impossible" alert gets called.

Proposed Change

$newFolder:=Folder("/PACKAGE/Archives2019/January")
$wasCreated:=$newFolder.create()

Case of

 : ($wasCreated)
     ALERT("The "+$newFolder.name+" folder was created.")

 : ($newFolder.exists)
     ALERT("The "+$newFolder.name+" folder was previously created.")

Else
     ALERT("Impossible to create a "+$newFolder.name+" folder.")

End case

Existing Example Code

$newFolder:=Folder("/PACKAGE/Archives2019/January")
If($newFolder.create())
 ALERT("The "+$newFolder.name+" folder was created.")
Else
 ALERT("Impossible to create a "+$newFolder.name+" folder.")
End if

https://github.com/4d/docs/blob/main/docs/API/FolderClass.md#create