(define 
	(script-fu-parasite-image-test inDeleteParasite)
  (let* 
    (
	  	(x "")
	  	(imageID)
	  	
		)
	
		(gimp-message-set-handler ERROR-CONSOLE)
		
		
		

		(set! imageID 1)
		
		
		(catch 
		   (begin ; on error
		   		(gimp-message "failed 1")
		      (gimp-image-parasite-attach imageID (list "testing" 1 "0"))
		      (
		      	while (not (string=? (caddr (car (gimp-image-parasite-find imageID "testing"))) "0" ))  ; this  loop is needed because of the bug
			    	(gimp-image-parasite-detach imageID "testing")
		        (gimp-image-parasite-attach imageID (list "testing" 1 "0"))
		      )
			  	(gimp-message (string-append "Created New Parasite Value = " (caddr (car (gimp-image-parasite-find imageID "testing"))))) 
		   )
	     (gimp-image-parasite-find imageID "testing") ; catch test
		   () ; do nothing else if OK
	  )
	   
		;a parsite should now exist
		(set! x (caddr (car (gimp-image-parasite-find imageID "testing"))))	
	  (gimp-message (string-append "Parasite was = " x)) 
	
		(set! x (number->string (+ (string->number x) 1))) ; increment it
	
	  (gimp-message (string-append "X set to = " x)) 
		
		(gimp-image-parasite-detach imageID "testing") ; Saulgoode thinks this helps, but it doesn't seem to make a difference to me....
		(gimp-image-parasite-attach imageID (list "testing" 1 x))
    (while (not (string=? (caddr (car (gimp-image-parasite-find imageID "testing"))) x ))  ; this  loop is needed because of the bug
	  	(gimp-image-parasite-detach imageID "testing")
      (gimp-image-parasite-attach imageID (list "testing" 1 x))
    )
	
	
    (gimp-message (string-append "Parasite Changed to = " x)) 
		
		(if (eq? inDeleteParasite TRUE)
		  (begin
	    	(gimp-image-parasite-detach imageID "testing")
	      (gimp-message "Parasite Deleted") 
		  )	  
		)  
	)
)

(script-fu-register "script-fu-parasite-image-test"
        		    "<Toolbox>/Xtns/Parasite image Test"
                    ""
                    ""
                    ""
                    ""
                    ""
				    SF-TOGGLE     "Delete Parasite" FALSE
)				