Jump to content

Set Cell Bug


This topic is 6395 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...

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 by Guest
Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 6395 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.