animation_master Posted September 13, 2006 Posted September 13, 2006 This is apparently a big bug in the implementation of "Native AppleScript" in ScriptMaker. Consider this short loop that accepts a list of files in a folder. (The third command is a FMP 8.5 dialog that displays the value of MyGlobalField.) repeat with currentFile in fileList tell application "FileMaker Pro Advanced" display dialog "currentFile is " & POSIX path of (currentFile as string) set cell "MyGlobalField" to POSIX path of (currentFile as string) do script "Display Dialog" end tell end repeat When this is run as an external script, it works perfectly. However, when it is run as a native AppleScript (inside FileMaker), it misbehaves. (1) I see the first dialog (“currentFile is filexx”) 10 times, then I see the second dialog (FileMaker “Value of MyGlobalField is”) 10 times. In other words, AppleScript appears to be looping through this routine twice! Once to perform the first line 10 times, then again to perform the third line 10 times! (2) The "set cell" step inserts a static path DIFFERENT FROM the one displayed by the first dialog over and over. Anyone know a workaround for this?
Søren Dyhr Posted September 14, 2006 Posted September 14, 2006 First thing I noticed was the use tell application "Filemaker" Which should be removed, including the end tell when they're embedded. Next thing to be aware of is that the correct way to address a filemaker script should go entire way thru objects: do script FileMaker script "Display Dialog" Or you do it this way: tell window 1 of application "FileMaker Pro" do script "Display Dialog" end tell ...what could happen is that you have an applescript somewhere stored as a file called "Display Dialog" I havn't tested anything yet, but I guess that this straigtens some of your problems. --sd
animation_master Posted September 24, 2006 Author Posted September 24, 2006 (edited) I believe that is not my problem. The script requires the user to select a folder, then it loops through the files in that folder. FileMaker cannot do that, so it must rely on an AppleScript to perform the choosing of the folder, and to perform the looping. The problem is this: You must enclose the FileMaker loop inside a “Tell Finder” loop. tell application "Finder" set selectedFolder to choose folder with prompt ¬ "Choose the CLIP folder to be processed." set fileList to (every file of entire contents of selectedFolder) repeat with currentFile in fileList tell application “FileMaker Pro” do [some things with the file] end tell end repeat end tell The script returns an error immediately after tell application “FileMaker Pro” I have tried (1) removing the enclosing “tell application ‘Filemaker Pro’” (2) using “tell window 1 of application ‘FileMaker Pro’” Neither works. I believe the rule is: An AppleScript embedded in a FileMaker script, may not address FileMaker inside a Finder tell. Edited September 24, 2006 by Guest
Fenton Posted September 24, 2006 Posted September 24, 2006 The reason your 2nd example doesn't work is that you forgot to coerce the file path to text; it's still a Finder reference. You could also end the Finder block as soon as it sets the file list into a variable. You could then just start with repeat, with no explicit tell "FileMaker", as it's implicit. For example: tell application "Finder" set selectedFolder to choose folder with prompt ¬ "Choose the CLIP folder to be processed." set fileList to (every file of entire contents of selectedFolder) end tell activate -- needed to display dialog, otherwise not repeat with currentFile in fileList set fileTxt to currentFile as Unicode text display dialog fileTxt giving up after 1 end repeat
Recommended Posts
This topic is 6633 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