benr_mc at cogapp.com
Mon Dec 20 05:04:44 CST 2004
on 20/12/04 5:42 am, Dar Scott wrote
>> q("C:\Ba\Ba.exe") && q("-E") && q("%1")
> format("c:\\Ba\\Ba.exe \"-E\" \"&1\" ")
(thanks for correcting!)
> q() wins.
It's the glory of Transcript - so many ways to skin cats. I like q too, but
it depends on what you're doing.
quote & "C:\Ba\Ba.exe" & quote && quote & "-E" & quote && quote & "%1" \
... is the most typing - but the most straightforward to read.
q("C:\Ba\Ba.exe") && q("-E") && q("%1")
Least typing; but to read it you have to know what q does, and to write it
you have to also write/make available q.
format("\"c:\\Ba\\Ba.exe\" \"-E\" \"&1\" ")
Less typing (but a bit less readable) than the first; more typing that the
second, but uses 'pure' Transcript. As I mentioned, becomes more attractive
if you also need to insert things like return; as you pointed out, has the
disadvantage that you need to escape any backslashes.
Personally I most often use backtick (don't know if this will come out in
email), and then do a replace:
get "`C:\Ba\Ba.exe` `-E` `%1`"
replace "`" with quote in it
Which I find is the least typing and most readable.
But it depends on lots of things - if there's just one quote, and you're
using the value immediately in an expression, you might as well add it
explicitly as in the first example. If there's loads of quotes, and you're
putting it into a variable anyway, then the fourth approach (backtick and
separate replace) feels right to me. If you've got 'q' already defined, and
it's for your own use so you'll immediately know what it means, then q is
good too. Lots of quotes and returns, no backslashes? Format might look
attractive. Horses for courses - Transcript gives us lots of choices.
Ben Rubinstein | Email: benr_mc at cogapp.com
Cognitive Applications Ltd | Phone: +44 (0)1273-821600
http://www.cogapp.com | Fax : +44 (0)1273-728866
More information about the use-livecode