objc-appscript

PreviousUpNext appscript / aem

10. Reference Examples

Application objects

// application "Finder"
#import "FNGlue.h"
FNApplication *finder = [[FNApplication alloc]
 initWithName: @"Finder.app"]
// application "Macintosh HD:Applications:TextEdit.app:"
#import "TEGlue.h"
TEApplication *textedit = [[TEApplication alloc]
 initWithPath: @"/Applications/TextEdit.app"]

Property references

// a reference to startup disk of application "Finder"
[finder startupDisk]
// a reference to name of folder 1 of home of application "Finder"
[[[[finder home] folders] at: 1] name]
// a reference to name of every item of home of application "Finder"
[[[finder home] items] name]
// a reference to text of every document of application "TextEdit"
[[textedit documents] text]
// a reference to color of character 1 of every paragraph of text ¬
// of document 1 of application "TextEdit"
[[[[[[[textedit documents] at: 1] text] paragraphs] characters] at: 1] color]

All elements references

// a reference to disks of application "Finder"
[finder disks]
// a reference to every word of every paragraph of text of every document ¬
// of application "TextEdit"
[[[[textedit documents] text] paragraphs] words]

Single element references

// a reference to disk 1 of application "Finder"
[[finder disks] at: 1]
// a reference to file "ReadMe.txt" of folder "Documents" of home of application "Finder"
[[[[[finder home] folders] byName: @"Documents"] files] byName: @"ReadMe.txt"]
// a reference to paragraph -1 of text of document 1 of application "TextEdit"
[[[[[textedit documents] at: 1] text] paragraphs] at: -1]
// a reference to middle paragraph of text of last document of application "TextEdit"
[[[[[textedit documents] last] text] paragraphs] middle]
// a reference to any file of home of application "Finder"
[[[finder home] files] any]

Relative references

// a reference to paragraph before paragraph 6 of text of document 1 of application "TextEdit"
[[[[[[textedit documents] at: 1] text] paragraphs] at: 6] previous: [TEConstant paragraph]]
// a reference to paragraph after character 30 of document 1 of application "Tex-Edit Plus"
[[[[[texEditPlus documents] at: 1] characters] at: 30] next: [TEConstant paragraph]]

Element range references

// a reference to words 1 thru 4 of text of document 1 of application "TextEdit"
[[[[[textedit documents] at: 1] text] words] at: 1 to: 4]
// a reference to paragraphs 2 thru -1 of text of document 1 of application "TextEdit"
[[[[[textedit documents] at: 1] text] paragraphs] at: 2 to: -1]
// a reference to folders "Documents" thru "Music" of home of application "Finder"
[[[finder home] folders] byRange: @"Documents" to: @"Music"]
// a reference to text (word 3) thru (paragraph 7) of document 1 of application "Tex-Edit Plus"
[[[[texEditPlus documents] at: 1] text] byRange: [[TEPCon words] at: 3]
 to: [[TEPCon paragraphs] at: 7]]

Test references

// a reference to every document of application "TextEdit" whose text is "\n"
[[textedit documents] byTest: [[TEIts text] equals: @"\n"]]
// a reference to every paragraph of document 1 of application "Tex-Edit Plus" ¬
// whose first character is last character
[[[[texEditPlus documents] at: 1] paragraphs] byTest:
 [[[TEPIts characters] first] equals: [[TEPIts characters] last]]]
// a reference to every file of folder "Documents" of home of application "Finder" ¬
// whose name extension is "txt" and size < 10240 [[[[[finder home] folders] byName: @"Documents"] files] byTest: [[[FNIts nameExtension] equals: @"txt"] AND: [[FNIts size] lessThan: [NSNumber numberWithInt: 10240]]]]

Insertion location references

// a reference to end of documents of application "TextEdit"
[[textedit documents] end]
// a reference to before paragraph 1 of text of document 1 of application "TextEdit"
[[[[[[textedit documents] at: 1] text] paragraphs] at: 1] before]
PreviousUpNext

AltStyle によって変換されたページ (->オリジナル) /