(no subject)
(no subject)
- Subject: (no subject)
- From: "Richard L. Zijdeman" <email@hidden>
- Date: Sun, 28 Jun 2009 14:38:18 +0200
Dear all,
!Background: Stata is a statistical package with an editor through which you can run commands. However TextWrangler is of course a much more advanced editor and therefore I would like to use that.
!Problem: I would like to copy a text selection from one program (TextWrangler) to the next (Stata) (and run it). However if the selection is made somewhere halfway a line, the whole line of text should be copied (thus from beginning to end). Therefore I used the command:
select line (startLine of selection)
, but when I select multiple lines only the first line of the selection is selected.
!What I have done: To solve this I would like to make a selection from the first full line (startLine) to the last full line (endLine) of the selection: ++ tell application "TextWrangler" tell text window 1 set alpha to line (startLine) set omega to line (endLine) select line (alpha thru omega) end tell 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 some text" return end if end tell ++
However, I get the following error message: Can't make startline of text window 1 into type startline. I am not a programmer, basically this is the first script I have written in anything. I would appreciate any comments, including those on what kind of mistake I make.
Cheers,
Richard
!full code:
tell application "TextWrangler" tell text window 1 set alpha to line (startLine) set omega to line (endLine) #select line (startLine of selection) select line (alpha thru omega) end tell 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 some 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) tell application "Finder" to set filename to tempFile as alias
tell application "StataSE" activate open filename end tell
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) tell application "Finder" 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 tell end write_to_file |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden