Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

re: st: BBEdit/Text Wrangler Coloring II


From   David Airey <[email protected]>
To   [email protected]
Subject   re: st: BBEdit/Text Wrangler Coloring II
Date   Tue, 13 Jan 2004 09:26:25 -0600

These work! The syntax coloring will need improving, as expected, but it gets most things correct.

The text editor FAQ needs updating to include Ben's scripts, which work better than what is currently posted. Here are Ben's AppleScripts to do a file and do a selection from within BBEdit (or TextWrangler).


---do file---

tell application "BBEdit"
save text window 1
set frontfile to file of window 1
end tell

tell application "Finder" to set filename to frontfile as alias

tell application "StataSE"
activate
open filename
end tell

---do selection---

on run
tell application "BBEdit"
set thecontents to the selection in window 1 as string
set theOriginalFile to file of document 1
if thecontents is "" then
display dialog "please select text"
return
end if
end tell

set thecontents to thecontents & return & "erase temp.do" & return & "exit"
set tempFile to my ComputeTempFileName(theOriginalFile)
my write_to_file(thecontents, tempFile, false)
set filename to tempFile as alias

tell application "StataSE"
activate
open filename
end tell
end run

on ComputeTempFileName(originalFile)
tell application "Finder"
set c to container of originalFile
set t to (c as string) & "temp.do"
end tell
return t
end ComputeTempFileName

on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as text
set the open_target_file to �
open for access file target_file with write permission
if append_data is false then �
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file


*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index