Thanks Jarmo,
No, I did not try this yet. here is my code that works well for checking for existing folders in a personal space.
There is no code included that assures a unique folder name (for simplicity's sake) but that could easily be created.
As I stated in my post: it appears that Find Folders function does not have a space key and by default runs the query in my personal JMP Live space.
I am guessing that the PageSize parameter in FindFolders can be used to page through a long list of folders (should they exist).
// open the connection to JMP Live
liveConnection = New JMP Live( Connection( ) );
// get the user name from JMP Live
user = liveConnection << Get Username;
// get the existing folders already in my Space
getFolders = liveConnection << Find Folders( Publisher( user ) );
folderlist = getFolders << As Scriptable();
// Define the folder name you want to check or create
folderName = "new_folder_name";
// Define the space key of the Space you wish to create the folder in
spaceKey = "~"; // set key to "~" for your personal space or use the space key
// Initialize a variable to store the folder ID
folderID = .;
// Check if the folder exists. If it exists, folderID will contain the ID
// if the folder does not exist, folderID will contain a missing value
For( i = 1, i <= folderlist << Get Number Of Items, i += 1,
If( folderlist[i] << Get Title == folderName,
folderID = folderlist[i] << Get ID;
Show( folderID );
Break();
)
);
// If the folder does not exist, create it. folderID will contain the folder ID.
If( Is Missing( folderID ),
newFolder = liveConnection << Create Folder(
Space( spaceKey ), // Use "~" for personal space or specify the space key
Title( folderName ),
Description( "Automatically created folder." )
);
folderID = newFolder << As Scriptable;
folderID = folderID << Get ID;
);