---
title: "AEPutPtr(_:_:_:_:_:)"
framework: coreservices
role: symbol
role_heading: Function
path: coreservices/1445287-aeputptr
---

# AEPutPtr(_:_:_:_:_:)

Inserts data specified in a buffer into a descriptor list as a descriptor, possibly replacing an existing descriptor in the list.

## Declaration

```swift
func AEPutPtr(_ theAEDescList: UnsafeMutablePointer<AEDescList>!, _ index: Int, _ typeCode: DescType, _ dataPtr: UnsafeRawPointer!, _ dataSize: Size) -> OSErr
```

## Parameters

- `theAEDescList`: A pointer to the descriptor list to add a descriptor to. See doc://com.apple.documentation/documentation/coreservices/aedesclist.
- `index`: A one-based positive integer indicating the position to insert the descriptor at. If there is already a descriptor in the specified position, it is replaced. You can pass a value of zero or count + 1 to add the descriptor at the end of the list. AEPutPtr returns an error (AEIllegalIndex) if you pass a negative number or a value that is out of range.
- `typeCode`: The descriptor type for the descriptor to be put into the list. For a list of AppleScript’s predefined descriptor types, see doc://com.apple.documentation/documentation/coreservices/apple_events/1542788-descriptor_type_constants. See doc://com.apple.documentation/documentation/coreservices/desctype.
- `dataPtr`: A pointer to the data for the descriptor to add.
- `dataSize`: The length, in bytes, of the data for the descriptor to add.

## Return Value

Return Value A result code. See Result Codes.

## Discussion

Discussion Thread safe starting in OS X v10.2.

## See Also

### Adding Items to Descriptor Lists

- [AEPutArray(_:_:_:_:_:_:)](coreservices/1442535-aeputarray.md)
- [AEPutDesc(_:_:_:)](coreservices/1450093-aeputdesc.md)
