Re: Name Conflicts
Re: Name Conflicts
- Subject: Re: Name Conflicts
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 12 Jun 2003 10:03:55 -0700
On 6/12/03 7:02 AM, "Steve Cunningham" <email@hidden> wrote:
>
I'm sure I must be missing something simple about "tell me" here but I
>
keep running into the problem where a name used by an osax conflicts with
>
a name used in an application.
>
>
Here is an example using the osax "24U Appearance OSAX" and FileMaker Pro
>
where I am trying to create a progress bar:
>
>
set aBar to create progress indicator with properties {maximum:10}
>
>
tell application "FileMaker Pro"
>
tell me
>
set aBar to create progress indicator with properties {maximum:10}
>
end tell
>
set aBar to my (create progress indicator with properties {maximum:10})
>
set aBar to create progress indicator with properties {maximum:10}
>
end tell
>
>
the "set aBar" outside of the FileMaker Pro tell works but all of the
>
three forms within the tell fail with the diagnostic
>
>
"expected ',' or '}' but found ':'"
>
>
apparently because "maximum" is a Filemaker Keyword.
>
>
I also tried:
>
>
set aBar to create progress indicator with properties {|maximum|:10}
>
>
That gets past the complier, but the osax doesn't recognize "|maximum|"
>
as "maximum".
>
>
I thought what was supposed to happen is that the "tell me" or "my" was
>
supposed to pass the "create" to the parent script instead of FileMaker
>
which would then pass it to the osax.
>
>
Can someone "tell me" what is going on and how to handle this situation
>
in general?
Yes. When there's a name conflict between an osax and an application, the
application wins. Even with a 'tell me' stuck on. (And if the application
has taken over a built-in AppleScript term, such as 'file', the application
wins here too.)
So use a handler (subroutine), which is totally outside the application
context. Try this (untested):
-------------------
global aBar
tell application "FileMaker Pro"
my CreateProgressBar()
-- other stuff
end tell
to CreateProgressBar()
set aBar to create progress indicator with properties {maximum:10}
end CreateProgressBar
--------------------
Or you could return aBar instead of making it global:
----------------------
tell application "FileMaker Pro"
set aBar to my CreateProgressBar()
-- other stuff
end tell
to CreateProgressBar()
set aBar to create progress indicator with properties {maximum:10}
return aBar
end CreateProgressBar
----------------------
Frankly, you should make the progress bar before you tell FMP anything, if
you can. Also use a handler to increment the progress bar . Here's a simple
example:
global aBar
set aBar to create progress indicator with properties {maximum:10}
tell application "FileMaker Pro"
set topMessage to "A top message that doesn't change for now"
repeat with i from 1 to 10
--do stuff
my UpdateProgressBar(i, 10)
end repeat
end tell
on UpdateProgressBar(i, n)
if n 0 then
try
update progress indicator progressBar maximum n current value i
without indeterminate
end try
end if
return
end UpdateProgressBar
---------------------------------
Here's a more interesting example that will display the current increment
with a bottom message that shows the current increment number and the name
of the item being incremented. If the application is returning Unicode or
styled text as 'theName' you need to convert that to plain text first so I
include that too. with an extra handler
--------------------------------------
property currentTotal : 0
global aBar
set aBar to create progress indicator with properties {maximum:10}
tell application "FileMaker Pro"
set topMessage to "A top message that doesn't change"
set n to (count someList) -- or 10
repeat with i from 1 to n
--do stuff
set theName to "[name of current item]"
my UpdateProgressBar(i, n, topMessage, theName)
set currentTotal to currentTotal + 1
end repeat
end tell
close progress indicator aBar
to UpdateProgressBar(i, n, topMessage, theName, currentTotal)
local bottomMessage
if n 0 then
set bottomMessage to (((currentTotal + 1) as string) & ". " & my
AsText(theName))
try
update progress indicator progressBar maximum n current value i
top message topMessage bottom message bottomMessage without indeterminate
end try
end if
return
end UpdateProgressBar
on AsText(str) -- Arthur Knapp's
--corece Unicode or other text to styled string to plain text
try
return (((str as string) as record)'s +class ktxt;)
end try
return str -- if plain text to begin with
end AsText
--------------------------
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.