;+
; NAME:
;	SMEI_DELETE_IMAGE
;
;
; PURPOSE:
;	Delete an image from a SMEI sequence.
;
;
; CATEGORY:
;	CLI
;
;
; CALLING SEQUENCE:
;	smei_delete_image, seqref, image
;
;
; KEYWORD PARAMETERS
;	/all	If set, then delete all images in the sequence.
;
;
; INPUTS:
;	seqref	objref	Object reference to the sequence.
;	image		Either an image number, or an image reference.
;
;
; MODIFICATION HISTORY:
;	Original: 19/12/02; SJT
;	Add ALL keyword: 27/5/04; SJT
;-

pro smei_delete_image, seqref, image, help = help

if keyword_set(help) then begin
    self_help
    return
end

if not obj_valid(seqref) then begin
    smei_msg, /alert,  'SMEI_DELETE_IMAGE requires an object reference'
    return
endif

if not obj_isa(seqref, 'SMEI_SEQUENCE') then begin
    smei_msg, /alert, $
              'The object you are trying to modify is not a ' + $
              'SMEI_SEQUENCE'
    return
endif

if keyword_set(all) then begin
    if smei_query(["Do you really want to", $
                   "delete ALL the images", $
                   "in the sequence?"], dialog_parent = event.top) $
      then begin
        while obj_valid((img = seqref -> get_first())) do $
              seqref -> delete_image, img
    endif
endif else seqref -> delete_image, image

end
