Maybe someone can help me, I think a have a typical beginner problem with a global that gets its value from filemaker.
I script like this to read from a text-field in filemaker:
global var_DateitypNeu, dat_Pfad_Ablage
tell application "FileMaker Pro"
set var_DateitypNeu to cell "var_DateitypNeu" of current record
end tell
and get back i.e. a value like “JPEG”. Now I´d like to use this string later in the script to save a file as a JPEG-File:
tell application "GraphicConverter"
tell window 1
save in dat_Pfad_Ablage as var_DateitypNeu
end tell
end tell
dat_Pfad_Ablage is a valid Path, but I get back an error, that data cannot be converted. I´ve tried a senseless thing like this:
if var_DateitypNeu = "JPEG" then
set var_DateitypNeu to "JPEG"
end if
And … Wow… now the filesaving with Graphic Converter works. Maybe someone can explain me the right way?
Yes, in this case, most likely when you read the cell and recieve the first “JPEG,” it is considered by AppleScript (AS) as a value, or property, but not a string, which you need when you save the file later on. I can’t test it, because I don’t have filemaker, but try making the variable into a string when you first read it, like this:
global var_DateitypNeu, dat_Pfad_Ablage
tell application "FileMaker Pro"
set var_DateitypNeu to cell "var_DateitypNeu" of current record as unicode text--This should force AS to set your variable to a string instead of a property or value.
end tell
Actually, it looks to me as if GraphicConverter handles file types as plain text - but not as Unicode or styled text. My guess is that the value returned by FileMaker Pro is Unicode text - hence the error.
While this is untested here, you could try replacing the line:
set var_DateitypNeu to cell "var_DateitypNeu" of current record
… with something like:
set {text:var_DateitypNeu} to (cell "var_DateitypNeu" of current record) as string
thanks a lot for your help, now me script works. Kai was right, GraphicConverter wants to get a plain-text-string instead of the unicode-text I get from Filemaker.