Pete Posted September 16, 2018 Posted September 16, 2018 Hi all, I am an amateur FM user with trying to achieve something fairly simple. I have a DB of clients. When I add a new client, I want to create a folder on my Mac named with the client's ID number. I have Scriptmaster, I have registered the create folder function, which now shows up in my list of functions. My problem is how to write the script to create the folder? Which script command would I use to deploy the function? Or am I missing something important? thanks in advance Pete
john renfrew Posted September 16, 2018 Posted September 16, 2018 set a variable in a script with the calculation - TheFunction( $params...) remember that this needs to be proper O/S paths
Pete Posted September 16, 2018 Author Posted September 16, 2018 Thanks. I tried that but got a syntax error - see pic
David Wikström Posted September 17, 2018 Posted September 17, 2018 When you use literal text, you need to enclose it in quotes. So something along the lines of: CreateFolder ("/Macintosh HD/Users/pete/Tresors/P Medicolegal/Reports/" & $Folder ) Assuming that $Folder is the variable where you store the folder name.
Pete Posted September 17, 2018 Author Posted September 17, 2018 Thanks so much. That has got rid of the syntax error. However the script seem to do anything, no error message. Is the 'set variable' command enough? Or does it need anything else. According to Scriptmaster it will return 1 or 0 depending on whether the folder already exists (it doesn't). see pic. P script.tiff sorry, attached now as jpeg
Pete Posted September 17, 2018 Author Posted September 17, 2018 (edited) Update: the function has returned zero, which means it thinks the folder already exists Edited September 17, 2018 by Pete
David Wikström Posted September 17, 2018 Posted September 17, 2018 Your parameter is missing a slash before Macintosh HD. If you're using FileMaker 17, you don't actually need a plugin to create a folder. You can use Export Records with a found set of 0 records and Create Directories on. If you set the export to export to a file called say "dummy.txt", a folder will be created but no actual file, since there are no records to export. Use Set Error Capture [On] at the beginning of the script to avoid error messages.
Pete Posted September 17, 2018 Author Posted September 17, 2018 Thanks. I changed it to "/Macintosh HD...", but it returned an error. Then I used "filemac:/Macintosh HD...." and it returned 1, which means it was successfully created. But still no folder (anywhere on the hard drive). I'm using FMP 12 Advanced. It might be time to upgrade...
john renfrew Posted September 18, 2018 Posted September 18, 2018 this won't work with a path that starts filemac: It needs to be an O/S system path, and while I know its not that helpful, works here (although I might have tweaked my version of the function a bit)
Pete Posted September 18, 2018 Author Posted September 18, 2018 Hooray! it works. Thank you so much So what I did is ctrl-option-click the parent folder to get the path. Turns out that starting the path name with "/users..." did the trick, i.e. leaving off the "/Macintosh HD" part.
Recommended Posts
This topic is 2314 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now