CImageSet:Insert


The Insert method adds a CImage to the image set prior to a specified index. For example, to add an image at the beginning of the set, before all other members, insert at position 1. A reference to the existing CImage is saved into the image set; no memory is allocated for a new image.

Syntax

CImageSet:Insert( CImage, nIndex )

where

    CImage is the CImage object to insert.

    nIndex is the index of the insertion point, starting at 1.

  

The CImage is inserted prior to the image set member existing at position index. This moves all the members down in the list in order to open up the new position at index. A reference to the target CImage is then saved at the new position.

Example

Suppose a CImageSet exists with name S and that it contains 10 images. The following script inserts a CImage I at index 5:

 

I = CImage:new()

-- create a CImage

local sPath, bOk = GetFileName()

-- use the Open dialog to get a filename

if ( not bOk ) then Exit() end

-- exit the loop after hitting Cancel

  I:Open(sPath)

-- load the image

  S:Insert( I, 5 )

-- Insert the new member at position 5

end

 

Printf("Count=%d", S:Count() )

-- result: Count=11

Related Topics

CImageSet class

CImage class