• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >(2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb) (From: Michael Terry <email@hidden>)
 >Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb) (From: Walter Ian Kaye <email@hidden>)
 >Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb) (From: Michael Terry <email@hidden>)

  • Prev by Date: Re: Intro to DHTML/DOM and how to get to elements in JS
  • Next by Date: Re: A Faster Script
  • Previous by thread: Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
  • Next by thread: Strange Mount Volume behaviour
  • Index(es):
    • Date
    • Thread