How to control where the answer file/folder dialog starts
This is a very simple lessons that explains how to make the 'answer file' and 'answer folder' dialogs start at a specific location of your computer.
Start by creating a new stack and:
1) Drag on a new button
2) Bring up the script editor for the button
3) Put in the following script
on mouseUp answer file "Select a file" end mouseUp
Switch to Run mode, click on the button and see where the dialog has taken you. In my case, the last time I loaded the the file dialog it was in the 'Downloads' folder. If you now navigate anywhere on your drive, close the dialog, and press the button again you will notice that it loads in the same folder as when you closed the dialog last.
We need to use the 'with' syntax which is detailed in the Documentation. By specifying '/users/ben/Desktop' I am telling the dialog to open at that folder. I can still choose to go anywhere but each time I click my button I will be presented with my 'Desktop' folder as my start point.
on mouseUp answer file "Select a file" with "/users/ben/Desktop" end mouseUp
You can of course set this in script allowing you to dynamically alter the place a user starts from.
on mouseUp local tStartDirectory put "/users/ben/Desktop" into tStartDirectory answer file "Select a file" with tStartDirectory end mouseUp
Of course, this is hard coded to my own computer. If I want to write a dialog that accesses a users desktop folder without knowing their username, I would use the SpecialFolderPath syntax, which you can learn about in the LiveCode Dictionary:
on mouseUp local tStartDirectory set the defaultFolder to specialFolderPath("desktop") put the defaultFolder into tStartDirectory answer file "Select a file" with tStartDirectory end mouseUp