Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSAppleEventDescriptorMBS class.

NSAppleEventDescriptorMBS.attributeDescriptorForKeyword(keyword as string) as NSAppleEventDescriptorMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns a descriptor for the receiver's Apple event attribute identified by the specified keyword.

keyword: A keyword (a four-character code) that identifies the descriptor to obtain.

Returns the attribute descriptor for the specified keyword, or nil if an error occurs.

NSAppleEventDescriptorMBS.coerceToDescriptorType(descriptorType as string) as NSAppleEventDescriptorMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns a descriptor obtained by coercing the receiver to the specified type.

descriptorType: The descriptor type to coerce the receiver to.

Returns a descriptor of the specified type, or nil if an error occurs.

NSAppleEventDescriptorMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 13.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The private constructor.

NSAppleEventDescriptorMBS.copy as NSAppleEventDescriptorMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a copy of the apple event descriptor.

NSAppleEventDescriptorMBS.descriptorAtIndex(index as Integer) as NSAppleEventDescriptorMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the descriptor at the specified (one-based) position in the receiving descriptor list.
Example
dim n as NSAppleEventDescriptorMBS = NSAppleEventDescriptorMBS.listDescriptor
dim d as NSAppleEventDescriptorMBS = NSAppleEventDescriptorMBS.descriptorWithString("Hello")
dim e as NSAppleEventDescriptorMBS = NSAppleEventDescriptorMBS.descriptorWithString("World")

n.insertDescriptor(d,1)
n.insertDescriptor(e,2)

MsgBox str(n.numberOfItems)

dim x1 as NSAppleEventDescriptorMBS = n.descriptorAtIndex(1)
dim x2 as NSAppleEventDescriptorMBS = n.descriptorAtIndex(2)
MsgBox x1.stringValue+" "+x2.stringvalue

Index: The one-based descriptor list position of the descriptor to return.

Returns the descriptor from the specified position (one-based) in the descriptor list, or nil if the specified descriptor cannot be obtained.

Some examples using this method:

NSAppleEventDescriptorMBS.descriptorForKeyword(keyword as string) as NSAppleEventDescriptorMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the receiver's descriptor for the specified keyword.
Example
dim n as new NSAppleScriptMBS("return system info")
dim r as NSAppleEventDescriptorMBS = n.execute

dim lines(-1) as string

dim u as Integer = r.numberOfItems
for i as Integer = 1 to u
dim keyword as string = r.keywordForDescriptorAtIndex(i)
dim value as string
dim p as NSAppleEventDescriptorMBS = r.descriptorForKeyword(keyword)
if p<>Nil then value = p.stringValue
lines.Append keyword+": "+value
next

MsgBox Join(lines,EndOfLine)

keyword: A keyword (a four-character code) that identifies the descriptor to obtain.

Returns a descriptor for the specified keyword, or nil if an error occurs.

Some examples using this method:

NSAppleEventDescriptorMBS.insertDescriptor(descriptor as NSAppleEventDescriptorMBS, index as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Inserts a descriptor at the specified (one-based) position in the receiving descriptor list, replacing the existing descriptor, if any, at that position.

descriptor: The descriptor to insert in the receiver. Specifying an index of 0 or count + 1 causes appending to the end of the list.
Index: The one-based descriptor list position at which to insert the descriptor.

Because it actually replaces the descriptor, if any, at the specified position, this method might better be called replaceDescriptor. The receiver must be a list descriptor. The indices are one-based. Currently provides no indication if an error occurs.

Some examples using this method:

NSAppleEventDescriptorMBS.keywordForDescriptorAtIndex(index as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the keyword for the descriptor at the specified (one-based) position in the receiver.
Example
dim n as new NSAppleScriptMBS("return system info")
dim r as NSAppleEventDescriptorMBS = n.execute

dim lines(-1) as string

dim u as Integer = r.numberOfItems
for i as Integer = 1 to u
dim keyword as string = r.keywordForDescriptorAtIndex(i)
dim value as string
dim p as NSAppleEventDescriptorMBS = r.descriptorForKeyword(keyword)
if p<>Nil then value = p.stringValue
lines.Append keyword+": "+value
next

MsgBox Join(lines,EndOfLine)

Index: The one-based descriptor list position of the descriptor to get the keyword for.

Returns the keyword (a four-character code) for the descriptor at the one-based location specified by anIndex, or 0 if an error occurs.

NSAppleEventDescriptorMBS.paramDescriptorForKeyword(keyword as string) as NSAppleEventDescriptorMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns a descriptor for the receiver's Apple event parameter identified by the specified keyword.

keyword: A keyword (a four-character code) that identifies the parameter descriptor to obtain.

Returns a descriptor for the specified keyword, or nil if an error occurs.

Some examples using this method:

NSAppleEventDescriptorMBS.print

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 12.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Writes description for this event descriptor to the console.

You can see result in Console.app.

NSAppleEventDescriptorMBS.removeDescriptorAtIndex(index as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Removes the descriptor at the specified (one-based) position in the receiving descriptor list.

Index: The one-based position of the descriptor to remove.

The receiver must be a list descriptor. The indices are one-based. Currently provides no indication if an error occurs.

NSAppleEventDescriptorMBS.removeDescriptorWithKeyword(keyword as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Removes the receiver's descriptor identified by the specified keyword.

keyword: A keyword (a four-character code) that identifies the descriptor to remove.

The receiver must be an Apple event or Apple event record. Currently provides no indication if an error occurs.

NSAppleEventDescriptorMBS.removeParamDescriptorWithKeyword(keyword as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Removes the receiver's parameter descriptor identified by the specified keyword.

keyword: A keyword (a four-character code) that identifies the parameter descriptor to remove. Currently provides no indication if an error occurs.

The receiver must be an Apple event or Apple event record, both of which can contain parameters.

NSAppleEventDescriptorMBS.send(options as Integer, timeoutInSeconds as Double, byref error as NSErrorMBS) as NSAppleEventDescriptorMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 16.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Sends an Apple event.
Example
// pick a file
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rtf")
// make a descriptor for file
dim fd as NSAppleEventDescriptorMBS = NSAppleEventDescriptorMBS.descriptorWithFSRef(f)
// make a descriptor for target app. here by bundle id
dim bd as NSAppleEventDescriptorMBS = NSAppleEventDescriptorMBS.descriptorWithBundleIdentifier("com.apple.finder")
// make a descriptor for apple event, here OpenDocument event
dim ad as NSAppleEventDescriptorMBS = NSAppleEventDescriptorMBS.appleEventWithEventClass("aevt", "odoc", bd, fd.kAutoGenerateReturnID, fd.kAnyTransactionID)

// assign parameter
ad.setParamDescriptor(fd, "----")

// now run
dim e as NSErrorMBS
dim rd as NSAppleEventDescriptorMBS = ad.send(ad.NSAppleEventSendDefaultOptions, 0.1, e)

// error sending?
if e <> nil then
MsgBox e.LocalizedDescription
end if

Break // inspect rd for success or failure of event?

NSAppleEventDescriptorMBS.setAttributeDescriptor(descriptor as NSAppleEventDescriptorMBS, keyword as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds a descriptor to the receiver as an attribute identified by the specified keyword.

descriptor: The attribute descriptor to add to the receiver.
keyword: A keyword (a four-character code) that identifies the attribute descriptor to add. If a descriptor with that keyword already exists in the receiver, it is replaced.

The receiver must be an Apple event. Currently provides no indication if an error occurs.

NSAppleEventDescriptorMBS.setDescriptor(descriptor as NSAppleEventDescriptorMBS, keyword as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds a descriptor, identified by a keyword, to the receiver.

descriptor: The descriptor to add to the receiver.
keyword: A keyword (a four-character code) that identifies the descriptor to add. If a descriptor with that keyword already exists in the receiver, it is replaced.

The receiver must be an Apple event or Apple event record. Currently provides no indication if an error occurs.

NSAppleEventDescriptorMBS.setParamDescriptor(descriptor as NSAppleEventDescriptorMBS, keyword as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds a descriptor to the receiver as an Apple event parameter identified by the specified keyword.

descriptor: The parameter descriptor to add to the receiver.
keyword: A keyword (a four-character code) that identifies the parameter descriptor to add. If a descriptor with that keyword already exists in the receiver, it is replaced.

The receiver must be an Apple event or Apple event record, both of which can contain parameters.

The items on this page are in the following plugins: MBS MacCocoa Plugin.


The biggest plugin in space...