Storing Script Snippets - Follow-up with Enhancement
Storing Script Snippets - Follow-up with Enhancement
- Subject: Storing Script Snippets - Follow-up with Enhancement
- From: Rob Jorgensen <email@hidden>
- Date: Wed, 11 Apr 2001 23:22:53 -0400
Howdy :-)
For all of you who recently contacted me regarding the FileMaker Pro
database for storing script snippets, here are a couple of scripts to
enhance things a bit if you use Scripter and/or Script Debugger.
When run from within the requested FileMaker Pro database, these
scripts will write the text from the "Script Code" field (cell) to a
text file on the desktop. The scripts will set the file's creator
code to that of the respective editors and then open the file in the
related editor. Script Debugger will attempt to compile the text.
Scripter isn't scriptable (I hate to say that), so the attempt to
compile is absent. I use both editors, and have attached these
scripts to buttons, which works out quite nicely. :-)
These scripts are based on a similar script which takes selected text
from a Eudora message and sends it to Script Debugger in the same
fashion. If you are interested in that script, it's named "Eudora to
Script Debugger" and it can be found in the ScriptTools category at
<
http://macscripter.net/script-builder.t>.
Note: << and >> have been used as substitutes for the guillemets in
the Script Debugger script below to avoid ALSMS (Apple List Server
Mangling Syndrome).
-- Begin script for Scripter users --
tell application "FileMaker Pro"
set theText to cell "Script Code"
end tell
set thePath to (path to desktop) as text
set theName to thePath & "Script from FMP"
if application "Finder"'s (exists item theName) then
set x to 1
repeat
beep
set newName to theName & "." & x
if not application "Finder"'s (exists item newName) then exit repeat
set x to x + 1
end repeat
set theName to newName
end if
tell application "Finder"
set outFile to open for access theName with write permission
write theText to outFile
close access outFile
end tell
tell application "Finder"
try
set creator type of file theName to "MEme"
open file theName using application file id "MEme"
on error
try
open file theName using application file id "MEme"
end try
end try
end tell
-- End script for Scripter users --
-- Begin script for Script Debugger users --
tell application "FileMaker Pro"
set theText to cell "Script Code"
end tell
set thePath to (path to desktop) as text
set theName to thePath & "Script from FMP"
if application "Finder"'s (exists item theName) then
set x to 1
repeat
beep
set newName to theName & "." & x
if not application "Finder"'s (exists item newName) then exit repeat
set x to x + 1
end repeat
set theName to newName
end if
tell application "Finder"
set outFile to open for access theName with write permission
write theText to outFile
close access outFile
end tell
tell application "Finder"
try
set creator type of file theName to "asDB"
open file theName using application file id "asDB"
on error
try
open file theName using application file id "asDB"
end try
end try
end tell
tell application "Script Debugger"
<<event asDBCOMP>> front window
end tell
-- End script for Script Debugger users --
I hope you find them useful. :-)
--
Later,
Rob Jorgensen
Ohio, USA