Thread: Working with Applescript
-
07-29-2010 12:18 PM #1Guest Member
- Join Date
- Oct 2006
- Posts
- 43
- Location:
- Tampa, FL
- FM Version
- FMP 9 Pro
- Skill Level
- Intermediate
- OS
- Mac
- Rep Power
- 0
Working with Applescript
I would like to use Applescript within a FMP script that creates a folder on my HD using a variable or calculated result from FMP for the name of the folder.
Additionally, the location of the folder to be created is not always the same.
For example, when I use FMP and generate a new record, I want the script to create a folder in a location for that client. The client's folders are all unique.
I know that variables from FMP mean nothing to an Applescript (and vice-versa). So, is this even possible?
-
07-29-2010 02:26 PM #2FileMaker Forum Subscriber
- Join Date
- Aug 2007
- Posts
- 31
- Location:
- United States
- FM Version
- Filemaker 3, 4, 6, 8.5, 10, 11 & Go
- Skill Level
- Intermediate
- OS
- Mac
- Rep Power
- 0
Re: Working with Applescript
You can use a global field to draw out information. There are quite a few examples on the internet for this task. I know very little about applescript, but was able to do similar tasks in pretty short order after a minimal amount of research time.
-
07-29-2010 02:36 PM #3FileMaker Tutor
- Join Date
- Mar 2004
- Posts
- 5,018
- Location:
- NL
- FM Version
- 9 adv
- Skill Level
- Pro
- OS
- Mac
- Rep Power
- 104
Re: Working with Applescript
A handler for setting a field in Filemaker could be this (assuming the field is in a utility table with one record; your filemaker record is committed; the current table / layout is the utility table)
the other way round works as wellCode:------dec property thefolderpath:string --more properties ------main ----- more code ----- blah blah my UserPickFolder () -----more code -------handlers on UserPickFolder() tell application "Finder" set thefolderpath to choose folder with prompt "choose folder" end tell tell application "FileMaker Pro Advanced" to tell current table set cell 1 of field "folderpath" to (thefolderpath as Unicode text) end tell end UserPickFolder
actually when you embed applescript ("native") in a filemaker script, it's better to useCode:tell application "filemaker pro advanced" to tell current table set thefilepath to the cellValue of cell 1 of field "ASFilepath" as Unicode text end tell
that way you avoid version confusion (pro and advanced users) (thanks Alan ;-) )Code:tell me to tell current table .... end tell
Stick to what you don't know.
-------
-
07-29-2010 02:53 PM #4FileMaker Tutor
- Join Date
- Mar 2004
- Posts
- 5,018
- Location:
- NL
- FM Version
- 9 adv
- Skill Level
- Pro
- OS
- Mac
- Rep Power
- 104
Re: Working with Applescript
and to answer your question... creating a folder on a predefined location...
Code:tell me to tell current table -- me is application "filemaker pro" or "filemaker pro advanced" set thefolderpath to the cellValue of cell 1 of field "folderpath" as Unicode text --this is the path to the locatioen where the folder must be created set thefoldername to the cellValue of cell 1 of field "foldername" as Unicode text --this is the name of the folder to be created end tell tell application "Finder" if not (exists (thefolderpath & ":" & thefoldername)) then try make new folder at thefolderpath as alias with properties {name:thefoldername} on error display dialog "failed creating folder" return end try end if end tellStick to what you don't know.
-------
-
08-09-2010 11:40 AM #5Guest Member
- Join Date
- Oct 2006
- Posts
- 43
- Location:
- Tampa, FL
- FM Version
- FMP 9 Pro
- Skill Level
- Intermediate
- OS
- Mac
- Rep Power
- 0
Re: Working with Applescript
Thanks guys!!!
-
08-09-2010 12:43 PM #6FileMaker Mentor
- Join Date
- Aug 2006
- Posts
- 8,128
- Location:
- New York (Manhattan) USA
- FM Version
- 10, 9, 8.5, 8, 7, 6, 5.5., 5, 4.1, 4, 3, 2.1, 1, II; & Nashoba 4, Plus, and the Original
- Skill Level
- Developer
- OS
- Windows & Mac
- Rep Power
- 158
Re: Working with Applescript
You can also use AppleScript to perform a shell script, by the way. ("Shell script" = "what you would type on the Terminal's command line").
do shell script "mkdir "& YourTable::FolderPath
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads - The answer to your question may be in one of these posts!
-
Running AppleScript from FMS 9
By preet in forum FileMaker Pro Server and NetworkingReplies: 7Last Post: 03-24-2009, 01:41 PM -
AppleScript Question
By Mr. Bungle in forum ScriptMaker and ScriptingReplies: 0Last Post: 09-10-2007, 10:21 AM -
FMP AppleScript Question
By jsosa73 in forum FileMaker Pro 8.0Replies: 1Last Post: 09-19-2006, 08:38 PM -
AppleScript
By cp in forum FileMaker Pro Versions 5 & 6Replies: 2Last Post: 03-25-2002, 04:53 PM -
AppleScript
By cp in forum FileMaker Pro Server and NetworkingReplies: 0Last Post: 03-21-2002, 11:27 AM

























































Reply With Quote

Bookmarks