Re: line breaking and indenting
Re: line breaking and indenting
- Subject: Re: line breaking and indenting
- From: Richard 23 <email@hidden>
- Date: Mon, 29 Jan 2001 12:04:49 -0800
>
Question 1:
>
>
The script
>
>
{,
>
a:1, ,
>
b:2, ,
>
c:3,
>
}
>
>
becomes
>
>
set a to ,
>
,
>
,
>
{a:1, b:2, c:3 ,
>
} ,
>
after a compilation. Are there any ways to avoid this? Probably not.
Well, hopefully it doesn't compile like that... This is doubly
obfuscated, first by AppleScript's attempt to incorporate manually
inserted continuation characters, then by the list server's attempt
to apply a lite version of PGP.
(The flippant reply would be not to post to the list server.)
>
Question 2:
>
It seems records do not allow line-breaking with the continuation
>
character between their properties. No ways to line-break between
>
properties?
>
Gaji
Actually I get the sort of formatting miscues with choose from list
and display dialog as well as with records.
So before I get to the big question (records), permit me to quickly
show how the same formatting is applied to AppleScript statements in
general, and a method for taming both...
Breaking lines after a value, before the next parameter
label seems logical but often isn't allowed.
Most people have probably run into it with display dialog.
Much easier to see than to describe however:
-- ---------------------------------------------------------
-- NOTE: Continuation characters removed for readability...
-- ---------------------------------------------------------
these are the places I might normally want to insert a break
in fact this is the way it is presented in the dictionary:
-- ---------------------------------------------------------
display dialog "string"
default answer "string"
buttons "list"
default button "number or string"
with icon "constant number or string"
giving up after "integer"
-- ---------------------------------------------------------
-- but this is how it compiles, is AppleScript dyslexic too?
-- ---------------------------------------------------------
display dialog
"string" default answer
"string" buttons
"list" default button
"number or string" with icon
"constant number or string" giving up after
"integer"
-- ---------------------------------------------------------
-- Parentheses and braces act like glue allowing just about
-- any desired layout, as long as command isn't segmented:
-- ---------------------------------------------------------
display dialog ("string")
default answer ("string") buttons {"list"}
default button ("number or string")
with icon ("constant number or string")
giving up after "integer"
-- ---------------------------------------------------------
As to records, the solution I apply to make things more readable
is to concatenate records breaking at the (inferred) comma rather
than at the colon:
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d2
-- ---------------------------------------------------------
property CTS_Data : {info:{name:"CoerceToString", version:"1.0d16p1"} &
==>
{revision:"r5", author:"Richard 23", date:current date, path:""}} &
==>
{mode:{contents:true, style:false},
data:{ready:false, sPos:0,
ePos:0}}
-- ---------------------------------------------------------
Although still a little ugly for mainstream typesetting, it's not too bad
for a record. At least each label and associated value are on the same
line. Also, note that as this is in a script property, the concatenation
is taken care of at compile time without any negative impact on execution
time.
R23
-- ---------------------------------------------------------
Convert Script Note (so you can follow along at home!):
-- ---------------------------------------------------------
Since Gakuji cheated (edited by hand without observing AppleScript's
formatting rules, applied during compilation), Convert Script didn't
quite get the first "pseudo script" right. Applying whitespace which
normally follows a "real" comma results in a clean translation.
-- ---------------------------------------------------------
The second (compiled version) translated correctly the first time.
-- ---------------------------------------------------------
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d2
-- ---------------------------------------------------------
set a to ==>
==>
==>
{a:1, b:2, c:3 ==>
} ==>
-- ---------------------------------------------------------
http://homepage.mac.com/richard23/docs/ConvertScript2.html