Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
- Subject: Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
- From: Walter Ian Kaye <email@hidden>
- Date: Sat, 10 Apr 2004 04:46:16 -0700
At 12:03a -0700 04/10/2004, Michael Terry didst inscribe upon an
electronic papyrus:
On Apr 9, 2004, at 11:19 PM, Walter Ian Kaye wrote:
The alternative would be to do like is often done with Excel:
1. get the boundaries of the range you want to affect
2. build a range reference based on those boundaries
3. assign an array to that range
Oh, and the other thing is that you can extract references to
noncontiguous cells in OO.
You can do that in Excel, too:
tell app "Microsoft Excel"
Select Range "R1C1:R5C3,R1C5:R5C7,R3C9"
set sel_areas to count Areas of Selection
end tell
--> 3
AppleScript's reference forms are more powerful than simple ranges
references, which makes sense because AS's reference forms are
designed to be powerful enough for any sort of application, not just
spreadsheet-types. Can the table suite handle noncontiguous cells in
a single Apple event?
You would need to define a 'range' object, and do it better than Excel does.
The hard part is making sure that a list of ranges doesn't look like
a range itself. One way to do that would be to define a range as a
record:
set range1 to {first cell:"A1", last cell:"C5"}
set range2 to {first cell:"E1", last cell:"G5"}
But I don't like that.
I think we should determine the "right" way to do this. Here's a
first stab, not necessarily "right" but at least a start:
tell app "Table Range Demo.app"
select range "R1C1:R2C2,R5C1"
count ranges of selection
--> 2
range 1 of range "R1C1:R2C2,R5C1"
--> range "R1C1:R2C2"
range 2 of range "R1C1:R2C2,R5C1"
--> range "R5C1"
count ranges of range "R1C1:R2C2"
--> 0
count ranges of range "R5C1"
--> 0
values of range "R1C1:R2C2,R5C1"
--> {{{1, 2}, {3, 4}}, {5}}
values of range "R1C1:R2C2"
--> {{1, 2}, {3, 4}}
values of range "R5C1"
--> {5}
value of cell "R5C1"
--> 5
value of cell 1 of range "R5C1"
--> 5
set values of range "R1C1:R2C2,R5C1" to {{{6, 7}, {8, 9}}, {10}}
end tell
In this brainstorming concept, a range always contains values as a
list, even when only one cell is in the range (but a cell value could
still be scalar). This eliminates any ambiguity which could otherwise
arise in a list of lists vs. a list of lists of lists (and I think
that ambiguity is why Excel only lets you operate on a single area of
a range at one time). Also, there are no 'areas' here as Excel uses
the term; only sub-ranges, easily addressable as shown above.
It's 4:30am so I may have done something dopey, I dunno.
I started; you guys finish.
-boo
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.