Confusing variable with quotes problem from FileMaker

I have a color picker script in FileMaker I use to choose color using Apple’s color picker. The problem I’m having is getting the current color into the color panel using the following:

Tell Application "FileMaker Pro Advanced"
__Tell database "ArtSMARTY"
____set myCurrentColor to cellValue of cell "color_rgb16" of table "Inventory"
__End Tell
End Tell

Choose color default color myCurrentColor

This gives me an -1700 error and it says something like “{65353,0,0}” is invalid.

I know it’s a problem with the quotes because I’ve tried testing with an arbitrary color value excluding quotes and it worked. Does anyone know how to solve this? I obviously need to use something else to extract the variable from a fileMaker database.

Model: Macbook intel core duo (black with 2 gigs RAM)
AppleScript: current?
Browser: Firefox
Operating System: Mac OS X (10.5)


if you get a string from the cell (not a list with three numeric variables), try this:

tell application "FileMaker Pro Advanced"
	tell database "ArtSMARTY"
		set myCurrentColor to cellValue of cell "color_rgb16" of table "Inventory"
	end tell
end tell

set {TID, text item delimiters} to {text item delimiters, ","}
set myCurrentColor to text items of text 2 thru -2 of myCurrentColor
set text item delimiters to TID

choose color default color myCurrentColor

I’m sorry that doesn’t seem to work. The problem I’m having is getting the value returned from the database to escape the quotes. The FileMaker cell will return something like “{65300, 0, 0}” but I’m needing it to be changed to {65300, 0, 0} in order for Applescript to use it as a 16 bit color. I’ve tried using the cell variable without quotes but that doesn’t work either.

I have everything in this color picker solution working except being able to bring up the last picked color. I created a custom FileMaker function to parse the 16 bit colors into their 8 bit equivalents. I’ll post it all up here as soon as I figure out how to get the previous color to input into Apple’s color picker. It’s using FileMaker 8.5 Advanced and I’m showing a color swatch by changing the font color of a dingbat using the custom 16bit - 8bit function. Obviously my strengths lie more in FileMaker than Applescript.

Actually I think I know what to do…I’m going to use a calculated applescript…DUH! I feel like an idiot. I’ll post it all here once its finished. I’m so stupid.

OK I got it. Here is the calulated script I ended up with:

"set myColor to choose color default color {" & Inventory::color_rgb16 & "}¶
set colorstring to my getstring(myColor)¶
on getstring(theColor)¶
	set cs to \"\"¶
	repeat with c from 1 to 3¶
		set cs to cs & (item c of theColor) as string¶
		if c < 3 then¶
			set cs to cs & \",\"¶
		end if¶
	end repeat¶
	return cs¶
end getstring¶
tell application \"FileMaker Pro Advanced\"¶
	tell database \"ArtSMARTY\"¶
		set cellValue of cell \"z_glob_color\" of table \"Inventory\" to colorstring¶
		do script \"Inventory_Parse_Color\"¶
	end tell¶
end tell"

I created a custom filemaker function to change the 16bit color value to 8bit:


RChan = Round (
Left (
Color16bit ;
(Position (Color16bit; “,”; 1; 1) - 1)
) * .99609375 / 256

GChan = Round (
Middle (
Color16bit ;
Position (Color16bit; “,” ; 1; 1) +1;
(Position (Color16bit; “,” ; 1; 2) - Position (Color16bit; “,” ; 1; 1) - 1)
) * .99609375 / 256

BChan = Round (
Right (
Length (Color16bit) - Position (Color16bit; “,” ; 1; 2)
) * .99609375 / 256
Case (
ColorChanRGB = “R”; RChan;
ColorChanRGB = “G”; GChan;
ColorChanRGB = “B”; BChan;

Formula use: RGB16to8 ( color_rgb16 ; “R” ); RGB16to8 ( color_rgb16 ; “G” ); RGB16to8 ( color_rgb16 ; “B” )

I created a calculation field called “display_color” that looks like this:
TextColor ( “$$$$$$$” ; RGB ( RGB16to8 ( color_rgb16 ; “R” ); RGB16to8 ( color_rgb16 ; “G” ); RGB16to8 ( color_rgb16 ; “B” ) ) )

I then used a dingbat font to display the color as a swatch. In the parse script, it simply takes the value from the global field “z_glob_color” and sets it as “color_rgb16” for that record followed by a window refresh. This wouldn’t be as difficult if I was using FileMaker 9.0 because I could use conditional formatting, but I’m not going to spend $300 to upgrade from 8.5 to 9.0 for a couple of new features I would actually use. In the color picker script, if the value for “color_rgb16” is blank (no auto-entry values), then I call a native applescript that is basically the same as the one above without the default color selection.