[Overview][Constants][Types][Classes][Index] | Reference for unit 'fgl' (#rtl)

# TFPSList.Insert

Insert a new item in the list.

## Declaration

Source position: fgl.pp line 84

`public procedure TFPSList.Insert(`
`Index: Integer;`
`Item: Pointer`
`); function TFPSList.Insert(`
`Index: Integer`
`):Pointer;`

## Arguments

`Index` |  | Index at which to insert the new item in the list
`Item` |  | Item to insert in the list

## Arguments

`Index` |  | Index at which to insert the new item in the list

## Function result

Newly allocated slot in the list

## Description

Insert comes in 2 overloaded version. The version without Item creates a slot for a new item at position Index in the list, and returns a pointer to the new slot. The slot will be of size TFPSList.ItemSize.

The version with Item argument will allocate a slot in the list at position Index and will copy the item pointed to by Item to the slot in the list.

In both cases, Index must be 0-based.

## Errors

If Index is invalid, an EListError exception will be raised.

## See also

TFPSList.Add |  | Add a new item to the list
TFPSList.Delete |  | Delete an item from the list
TFPSList.Extract |  | delete an element from the list

Documentation generated on: May 14 2021