July 27, 201510 yr i'm about to pull my hair out here. i've got an applescript that works perfectly in the applscript editor, but when i try to add it to filemaker as a calculated value, i get that error. i'm not finding what quote i'm missing. any help would be greatly appreciated. this is the script editor version: set afflName to "123456" tell application "Google Chrome" delay 1 tell application "Google Chrome" to set index of window 1 where title contains "Sample Page" to 1 do shell script "open -a Google\\ Chrome" tell active tab of window 1 set t to (execute javascript "document.getElementsByTagName('html')[0].innerHTML") as text if t contains afflName then repeat while loading is true delay 0.1 end repeat set idNumber to text ((offset of afflName in t) - 7) thru ((offset of afflName in t) - 3) of t set strippedNumber to my getNumerals(idNumber) --display alert strippedNumber execute javascript "document.forms['Form1']['ddlAffiliateList'].value = '" & strippedNumber & "'" else display dialog "AFFILIATE NOT FOUND" buttons {"OK"} end if end tell end tell on getNumerals(input) set digits to "1234567890" copy input to nonNumbers repeat with thisnumber in digits set AppleScript's text item delimiters to thisnumber set nonNumbers to every text item of nonNumbers as text end repeat try repeat with thischar in nonNumbers set endTest to item 1 of nonNumbers set AppleScript's text item delimiters to endTest set input to every text item of input set nonNumbers to every text item of nonNumbers set AppleScript's text item delimiters to "" set input to input as text set nonNumbers to nonNumbers as text end repeat end try return input end getNumerals and here is the filemaker version: "set afflName to \"" & $$Affiliate & "\"" & ¶ & "" & ¶ & "tell application \"Google Chrome\"" & ¶ & "delay 1" & ¶ & "tell application \"Google Chrome\" to set index of window 1 where title contains \"Sample Page\" to 1" & ¶ & "do shell script \"open -a Google\ Chrome\"" & ¶ & "tell active tab of window 1" & ¶ & "set t to (execute javascript \"document.getElementsByTagName('html')[0].innerHTML\") as text" & ¶ & "if t contains afflName then" & ¶ & "repeat while loading is true" & ¶ & "delay 0.1" & ¶ & "end repeat" & ¶ & "set idNumber to text ((offset of afflName in t) - 7) thru ((offset of afflName in t) - 3) of t" & ¶ & "set strippedNumber to my getNumerals(idNumber)" & ¶ & "display alert strippedNumber" & ¶ & "execute javascript \"document.forms['Form1']['ddlAffiliateList'].value = '\" & strippedNumber & \"'\"" & ¶ & "else" & ¶ & "display dialog \"AFFILIATE NOT FOUND\" buttons {\"OK\"}" & ¶ & "end if" & ¶ & "end tell " & ¶ & "end tell" & ¶ & "" & ¶ & "on getNumerals(input)" & ¶ & "set digits to \"1234567890\"" & ¶ & "copy input to nonNumbers" & ¶ & "repeat with thisnumber in digits" & ¶ & "set AppleScript's text item delimiters to thisnumber" & ¶ & "set nonNumbers to every text item of nonNumbers as text" & ¶ & "end repeat" & ¶ & "try" & ¶ & "repeat with thischar in nonNumbers" & ¶ & "set endTest to item 1 of nonNumbers" & ¶ & "set AppleScript's text item delimiters to endTest" & ¶ & "set input to every text item of input" & ¶ & "set nonNumbers to every text item of nonNumbers" & ¶ & "set AppleScript's text item delimiters to \"\"" & ¶ & "set input to input as text" & ¶ & "set nonNumbers to nonNumbers as text" & ¶ & "end repeat" & ¶ & "end try" & ¶ & "return input" & ¶ & "end getNumerals" I have to think it's on the "execute javascript \"document.forms['Form1']['ddlAffiliateList'].value = '\" & strippedNumber & \"'\"" & ¶ &" line, but i've tried everything and can't seem to figure it out. please help!
July 27, 201510 yr Author ok, scratch that. it's on the line. "do shell script \"open -a Google\\ Chrome\"" & ¶ & i started a new script and just added one line at a time until it errored out and that's the one. so.....hmmmm.... ok, found it. i guess it needed 3 "\" instead of two between Google and Chrome. weird.
July 27, 201510 yr "tell application \"Google Chrome\"¶¶ delay 1¶¶ tell application \"Google Chrome\" to set index of window 1 where title contains \"Sample Page\" to 1¶¶ do shell script \"open -a Google\\\ Chrome\"¶¶ tell active tab of window 1¶¶ set t to (execute javascript \"document.getElementsByTagName('html')[0].innerHTML\") as text¶¶ if t contains afflName then¶¶ repeat while loading is true¶¶ delay 0.1¶¶ end repeat¶¶ set idNumber to text ((offset of afflName in t) - 7) thru ((offset of afflName in t) - 3) of t¶¶ set strippedNumber to my getNumerals(idNumber)¶¶ --display alert strippedNumber¶¶ execute javascript \"document.forms['Form1']['ddlAffiliateList'].value = '\" & strippedNumber & \"'\"¶¶ else¶¶ display dialog \"AFFILIATE NOT FOUND\" buttons {\"OK\"}¶¶ end if¶¶ end tell¶¶ end tell¶¶ on getNumerals(input)¶¶ set digits to \"1234567890\"¶¶ copy input to nonNumbers¶¶ repeat with thisnumber in digits¶¶ set AppleScript's text item delimiters to thisnumber¶¶ set nonNumbers to every text item of nonNumbers as text¶¶ end repeat¶¶ try¶¶ repeat with thischar in nonNumbers¶¶ set endTest to item 1 of nonNumbers¶¶ set AppleScript's text item delimiters to endTest¶¶ set input to every text item of input¶¶ set nonNumbers to every text item of nonNumbers¶¶ set AppleScript's text item delimiters to \"\"¶¶ set input to input as text¶¶ set nonNumbers to nonNumbers as text¶¶ end repeat¶¶ end try¶¶ return input¶¶ end getNumerals"
July 27, 201510 yr i'm about to pull my hair out here. Filemaker has two convenient functions that can be very helpful here: Quote() and Evaluate(). If you paste your original code into a text field, you can then use Quote ( MyField ) to escape it. For example, if the field contains: do shell script "open -a Google\\ Chrome" the result will be: "do shell script \"open -a Google\\\ Chrome\"" Conversely, you can use the Evaluate() function to unescape the text and return the original.
July 27, 201510 yr Author Filemaker has two convenient functions that can be very helpful here: Quote() and Evaluate(). If you paste your original code into a text field, you can then use Quote ( MyField ) to escape it. For example, if the field contains: do shell script "open -a Google\\ Chrome" the result will be: "do shell script \"open -a Google\\\ Chrome\"" Conversely, you can use the Evaluate() function to unescape the text and return the original. that works great, but when i do it, it comes out looking like this: "set afflName to \"123456\"¶tell application \"Google Chrome\"¶delay 1¶ tell application \"Google Chrome\" to set index of window 1 where title contains \"Sample Page\" to 1¶do shell script \"open -a Google\\\ Chrome\"¶ tell active tab of window 1¶ set t to (execute javascript \"document.getElementsByTagName('html')[0].innerHTML\") as text¶ if t contains afflName then¶ repeat while loading is true¶ delay 0.1¶ end repeat¶ set idNumber to text ((offset of afflName in t) - 7) thru ((offset of afflName in t) - 3) of t¶ set strippedNumber to my getNumerals(idNumber)¶ --display alert strippedNumber¶ execute javascript \"document.forms['Form1']['ddlAffiliateList'].value = '\" & strippedNumber & \"'\"¶ else¶ display dialog \"AFFILIATE NOT FOUND\" buttons {\"OK\"}¶ end if¶ end tell¶end tell¶on getNumerals(input)¶ set digits to \"1234567890\"¶ copy input to nonNumbers¶ repeat with thisnumber in digits¶ set AppleScript's text item delimiters to thisnumber¶ set nonNumbers to every text item of nonNumbers as text¶ end repeat¶ try¶ repeat with thischar in nonNumbers¶ set endTest to item 1 of nonNumbers¶ set AppleScript's text item delimiters to endTest¶ set input to every text item of input¶ set nonNumbers to every text item of nonNumbers¶ set AppleScript's text item delimiters to \"\"¶ set input to input as text¶ set nonNumbers to nonNumbers as text¶ end repeat¶ end try¶ return input¶end getNumerals" is there no way to have it show the new lines properly? if i had to go back and edit this later, it would be a nightmare to sift through.
July 27, 201510 yr is there no way to have it show the new lines properly? if i had to go back and edit this later, it would be a nightmare to sift through. Actually, it is possible, if you do: Substitute ( Quote ( MyField ) ; "\¶" ; "\¶¶" ) But my point is that you should not try and edit escaped code at all. Instead, unescape it using the Evaluate() function, edit it, then escape it again using the Quote() function.
Create an account or sign in to comment