I have the following appleScript that works fine from the Script Editor, but
FMP10 rejects it. The script is based mostly on one that I found by Jon at
MacScripter. First the script...
----------
*
property search_and_replace_strings : {{"
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
LOCK TABLES `blm_active` WRITE;
/*!40000 ALTER TABLE `blm_active` DISABLE KEYS */;
INSERT INTO `blm_active` VALUES (", ""}, {"'", ""}, {"),(", "
"}, {");
/*!40000 ALTER TABLE `blm_active` ENABLE KEYS */;
UNLOCK TABLES;
/*!40101 SET sql_mo...@old_sql_mode */;
/*!40014 SET foreign_key_chec...@old_foreign_key_checks */;
/*!40014 SET unique_chec...@old_unique_checks */;
/*!40101 SET character_set_clie...@old_character_set_client */;
/*!40101 SET character_set_resul...@old_character_set_results */;
/*!40101 SET collation_connecti...@old_collation_connection */;
/*!40111 SET sql_not...@old_sql_notes */;
", "
"}}
set the_file to (((path to desktop) as string) & "Academic
League:ovmsal_storage:blm_active.txt") as alias
set the_text to (read the_file)
repeat with i in search_and_replace_strings
set the_text to my snr(the_text, i's item 1, i's item 2)
end repeat
my write_to_file(the_file, the_text, false)
beep 2
display dialog "Finished!" buttons {"OK"} default button 1 with icon 1 giving
up after 5
on snr(the_string, search_string, replace_string)
tell (a reference to my text item delimiters)
set {old_tid, contents} to {contents, search_string}
set {the_string, contents} to {the_string's text items, replace_string}
set {the_string, contents} to {the_string as Unicode text, old_tid}
end tell
return the_string
end snr
on write_to_file(the_file, the_data, with_appending)
set the_file to the_file as Unicode text
try
set f to open for access file the_file with write permission
if not with_appending then set eof of f to 0
write the_data to f starting at eof as (class of the_data)
close access f
return true
on error the_error
try
close access file the_file
end try
return the_error
end try
end write_to_file
*
----------
The problem is that FMP gives an error message for the line
*set* the_text *to* (*read* the_file)
and says Expected "," but found Indentifer. and highlights the_file.
Removing the parentheses results in an error message that says ...
Expected end of line, etc. but found identifer.
How can I modify this script line to get FMP to accept it?
Thanks,
Charlie