Hi all,
I've written a command that performs an AppleScript to look up the selected text in a FileMaker database. I have the command Output set to "Replace Selected Text". It's all working well, except that the result that's replacing my selection is always being followed by a newline--which is definitely not being added by my AppleScript or FileMaker.
Any ideas on how to get rid of the added newline?
On Apr 12, 2007, at 2:08 AM, Tim Mansour wrote:
Hi all,
I've written a command that performs an AppleScript to look up the selected text in a FileMaker database. I have the command Output set to "Replace Selected Text". It's all working well, except that the result that's replacing my selection is always being followed by a newline--which is definitely not being added by my AppleScript or FileMaker.
Any ideas on how to get rid of the added newline?
Well we would need to see some part of the command to be able to help. Assuming it's written in the shell, I would guess you are using "echo" to print the results. Then you would want to have "echo -n" instead. Echo automatically adds a newline at the end.
-- Tim Mansour tim@neologica.com.au
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On 12/04/2007, at 10:32 pm, Charilaos Skiadas wrote:
Well we would need to see some part of the command to be able to help. Assuming it's written in the shell, I would guess you are using "echo" to print the results. Then you would want to have "echo -n" instead. Echo automatically adds a newline at the end.
Yes, I should have supplied the script first ... this is what I'm doing:
osascript <<-APPLESCRIPT set title to "vanishing" if title is not "" then tell application "FileMaker Pro Advanced" if not (exists window "HTitles") then open alias "HD:HTitles.fp7" set cell "_Search" of layout "Titles" to title do script "Search For Title" set href to cell "_Search" of layout "Titles" set img to cell "_thumb" of layout "Titles" end tell if href is not "" then set title to img & href end if return title APPLESCRIPT
I'm not sure what I can change in the above to ensure there's no newline returned to TextMate?
On 4/12/07, Tim Mansour tim@neologica.com.au wrote:
I'm not sure what I can change in the above to ensure there's no newline returned to TextMate?
Ugly, but ought to work:
echo -n "$(osascript <<-APPLESCRIPT set title to "vanishing" if title is not "" then tell application "FileMaker Pro Advanced" if not (exists window "HTitles") then open alias "HD: HTitles.fp7" set cell "_Search" of layout "Titles" to title do script "Search For Title" set href to cell "_Search" of layout "Titles" set img to cell "_thumb" of layout "Titles" end tell if href is not "" then set title to img & href end if return title APPLESCRIPT)"
Robin
On Apr 12, 2007, at 9:56 AM, Robin Houston wrote:
On 4/12/07, Tim Mansour tim@neologica.com.au wrote: I'm not sure what I can change in the above to ensure there's no newline returned to TextMate?
Ugly, but ought to work:
echo -n "$(osascript <<-APPLESCRIPT set title to "vanishing" if title is not "" then tell application "FileMaker Pro Advanced" if not (exists window "HTitles") then open alias "HD:HTitles.fp7" set cell "_Search" of layout "Titles" to title do script "Search For Title" set href to cell "_Search" of layout "Titles" set img to cell "_thumb" of layout "Titles" end tell if href is not "" then set title to img & href end if return title APPLESCRIPT)"
Hm, somehow my reply only went to Tim, probably because he had added me to the To field. Anyway, here's what I said, which is I think why Robin's method won't quite work:
Ah the problem is that osascript adds this newline, and there is no way to tell it not to. You'll have to rewrite things a bit so that you capture what osascript returns in a variable, and then trim the newline, before printing it via "echo -n".
So you need to also trim the newline osascript added, in addition to telling echo not to print one of its own. At least I think so.
Robin
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On 4/12/07, Charilaos Skiadas skiadas@hanover.edu wrote:
Anyway, here's what I said, which is I think why Robin's method won't quite work:
I guess you haven't tried it then, because it actually works fine!
The point is that $(command) strips the newline: for example
foo=$(echo hello)
puts the string "hello" (without a newline) into $foo.
Robin
On Apr 12, 2007, at 10:15 AM, Robin Houston wrote:
On 4/12/07, Charilaos Skiadas skiadas@hanover.edu wrote: Anyway, here's what I said, which is I think why Robin's method won't quite work:
I guess you haven't tried it then, because it actually works fine!
No I hadn't tried it ;)
The point is that $(command) strips the newline: for example
foo=$(echo hello)
puts the string "hello" (without a newline) into $foo.
Interesting. `...` seems to have the same behavior. In fact, hard as I tried I did not manage to get echo to read a newline at all ;).
Robin
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On 12/04/2007, at 11:56 pm, Robin Houston wrote:
Ugly, but ought to work:
echo -n "$(osascript <<-APPLESCRIPT set title to "vanishing" if title is not "" then tell application "FileMaker Pro Advanced" if not (exists window "HTitles") then open alias "HD:HTitles.fp7" set cell "_Search" of layout "Titles" to title do script "Search For Title" set href to cell "_Search" of layout "Titles" set img to cell "_thumb" of layout "Titles" end tell if href is not "" then set title to img & href end if return title APPLESCRIPT)"
A very belated thanks Robin--that did indeed work.