gephry Posted November 12, 2008 Posted November 12, 2008 I've been sending data from Filemaker to iCal but have found a problem: any field that has a ! or " in it causes an error in the Applescript to err and to stop. I'm wondering how can I escape these characters in Filemaker? Or more importantly, how do you search/replace a quote within field contents without going character by character? I've tried: Substitute( Cal::Notes; """; """ ) but that doesn't actually do what it implies.
gephry Posted November 15, 2008 Author Posted November 15, 2008 I've been passing a lot of information back and forth between applications with Applescript. Unfortunately, when fields contain stuff like double-quotes, single-quotes, German or other Greek/special characters, Applescript doesn't like it one bit; it will result in an error and won't do what it's intended to do. I remedied this problem by creating a custom script that takes all un-likable characters and either eliminating them or replacing them with friendly characters (u with ü, 3.14 instead of π, etc). This script also escapes double-quotes and single-quotes, both in ASCII and in font-style curly quotes. Substitute( Text; [ "‘"; "'" ]; // Replace beginning curly single-quote to generic ASCII ' [ "’"; "'" ]; // Replace possessive/ending curly-single quotes to generic ASCII ' [ """; """ ]; // escape ASCII double-quotes [ "“"; "“" ]; // escape first curly double-quotes first [ "”"; "”" ]; // escape second curly double-quote second [ "à"; "a" ]; // OPTION ` + a [ "è"; "e" ]; // OPTION ` + e [ "ì"; "i" ]; // OPTION ` + i [ "ò"; "o" ]; // OPTION ` + o [ "ù"; "u" ]; // OPTION ` + u [ "á"; "a" ]; // OPTION e + a [ "é"; "e" ]; // OPTION e + e [ "í"; "i" ]; // OPTION e + i [ "ó"; "o" ]; // OPTION e + o [ "ú"; "u" ]; // OPTION e + u [ "!" ; "." ]; // SHIFT 1 (don't ask me why but Applescript doesn't like exclamations points, even with as an escape char) [ "¡"; "" ]; // OPTION 1 [ "™"; "TM" ]; // OPTION 2 [ "£"; "pounds" ]; // OPTION 3 [ "¢"; "cents" ]; // OPTION 4 [ "∞"; "" ]; // OPTION 5 [ "§"; "" ]; // OPTION 6 [ "•"; "*" ]; // 8 (no 7 since that is ¶ and is a paragraph [ "ª"; "" ]; // OPTION 9 [ "º"; "" ]; // OPTION 0 [ "≠"; "<>" ]; // OPTION = [ "«"; "" ]; // OPTION+backslash [ "…"; "..." ]; // OPTION semicolon [ "æ"; "ae" ]; // OPTION quote [ "≤"; "<=" ]; // OPTION < [ "≥"; ">=" ]; // OPTION > [ "÷"; "/" ]; // OPTION ? [ "œ"; "oe" ]; // OPTION q [ "∑"; "[sum]" ]; // OPTION w [ "®"; "[Registered]" ]; // OPTION r [ "†"; "" ]; // OPTION t [ "¥"; "" ]; // OPTION y [ "ü"; "u" ]; // OPTION u + u [ "ë"; "e" ]; // OPTION u + e [ "ä"; "a" ]; // OPTION u + a [ "ï"; "i" ]; // OPTION u + i [ "ö"; "o" ]; // OPTION u + o [ "ÿ"; "y" ]; // OPTION u + y [ "â"; "a" ]; // OPTION i + a [ "ê"; "e" ]; [ "î"; "i" ]; [ "ô"; "o" ]; [ "û"; "u" ]; [ "ø"; "o" ]; // OPTION o [ "π"; "3.14" ]; // OPTION p [ "å"; "a" ]; // OPTION a [ "ß"; "ss" ]; // OPTION s [ "∂"; "" ]; // OPTION d [ "ƒ"; "[forte symbol]" ]; // OPTION f [ "©"; "[Copyright]" ]; // OPTION g [ "˙"; "'" ]; // OPTION h [ "∆"; "" ]; // OPTION j [ "˚"; "" ]; // OPTION k [ "¬"; "" ]; // OPTION l [ "Ω"; "[omega]" ]; // OPTION z [ "≈"; "[approx=]" ]; // OPTION x [ "ç"; "c" ]; // OPTION c [ "√"; "[checkmark]" ]; // OPTION v [ "∫"; "" ]; // OPTION b [ "ñ"; "n" ]; // OPTION n + n [ "õ"; "o" ]; // OPTION n + o [ "ã"; "a" ]; // OPTION n + a [ "µ"; "u" ] // OPTION m ) MakeApplescriptSafe.zip
gephry Posted November 15, 2008 Author Posted November 15, 2008 Well, since Applescript doesn't like any special characters (Greek, German ü, single-quotes, double quotes, etc) I decided to make a function to make ALL characters Applescript-friendly. My custom function escapes all types of quotes and replaces special characters with their equivalent (u vs. ü or 3.14 vs. π). The problem that I was having above escaping the double-quotes, I realized there are ASCII straight-double quotes, and font-style curly double-quotes. So my script escapes all types of quotes and fixes special characters. The custom function is posted at the link below. Hope this will help someone else in the long-run! http://fmforums.com/forum/showtopic.php?fid/130/tid/199335/pid/308902/post/last/#LAST
comment Posted November 15, 2008 Posted November 15, 2008 since Applescript doesn't like any special characters (Greek, German ü, single-quotes, double quotes, etc) Perhaps you should post your script, before jumping to conclusions.
Lee Smith Posted November 16, 2008 Posted November 16, 2008 (edited) Do not double post your question. I have merged your two Threads. Lee Edited November 16, 2008 by Guest
normanicus Posted November 16, 2008 Posted November 16, 2008 I am not claiming any expertise here but this article says that Applescript it now Unicode compatible: http://www.apple.com/applescript/features/unicode.html I searched for iCal Unicode compatibility but could find nothing though it appears there were big changes in Leopard.
gephry Posted November 16, 2008 Author Posted November 16, 2008 I do in fact run Leopard. My client runs Tiger and he was having difficulties, too. Nono, comment, I didn't jump to conclusions. I definitely took my time to figure out what was happening. I did some pretty extensive testing (on Leopard) with individual characters+Applescript and made notes of all of the characters that didn't work from Filemaker to iCal. Since I couldn't get any of the above characters in the script to work, I made the function according to my findings. Still, I'm not sure why my function was moved from Custom Function Library? It's a function I wrote that I figured should be with the other custom functions. Sorry if I was out of line...? B)
comment Posted November 16, 2008 Posted November 16, 2008 Well, all I can say is that I have seen no such limitation in Tiger.
gephry Posted November 17, 2008 Author Posted November 17, 2008 Hm, you know what?...I wonder. I am assigning a fields to a variable and then plugging the variable in the Applescript. I wonder if something is happening in the translation between variables and the Applescript.
Lee Smith Posted November 17, 2008 Posted November 17, 2008 Still, I'm not sure why my function was moved from Custom Function Library? It's a function I wrote that I figured should be with the other custom functions. Sorry if I was out of line...? I moved it because you asked a duplicate question concerning it. I can move this whole thread back to the Custom Function Topic, if that is where you prefer it. However, you are getting plenty of responses here. Lee
Recommended Posts
This topic is 5848 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