;+
; NAME:
;	SMEI_SEQUENCE::GET_LAST
;
;
; PURPOSE:
;	Get the last image of a SMEI sequence
;
;
; CATEGORY:
;	SMEI_SEQUENCE
;
;
; CALLING SEQUENCE:
;	imref = seqref->get_last()
;
; KEYWORD INPUTS:
;	/noskip	If set, then return the last image not flagged for
;		hiding. (If all images are flagged then the true last
;		image is returned)
; 
; OUTPUTS:
;	imref	objref	A reference to the last image in the sequence.
;	index	long	The index of the image returned (only relevant
;			if noskip is specified).
;
; MODIFICATION HISTORY:
;	Original: 9/12/02; SJT
;	Added noskip & index keywords: 20/7/10; SJT
;-

function smei_sequence::get_last, noskip = noskip, index = index

img = self.last_image
index = self -> get_count()-1

if keyword_set(noskip) then $
  while obj_valid(img) && img -> get_pflags(/skip) do begin
    img = img -> get_prev()
    index--
endwhile

if ~obj_valid(img) then begin
    index = self -> get_count()-1
    return, self.last_image
endif

return, img

end
