/********************************/
/* Image Engineer Macro script  */
/* by Simon Edwards             */
/* 22/6/95                      */
/*                              */
/* 18/1/97 FORM interface added */
/*                              */
/* Extract a colour component   */
/********************************/

Options results
signal on error         /* Setup a place for errors to go */

if arg()==0 then exit

PROJECT_INFO arg(1) TYPE
if RESULT~="COLOUR" then exit

'FORM "Extract Colour Components" "Ok|Cancel"',
' TEXT,"Components to extract"',
' CHECKBOX,"Red",1',
' CHECKBOX,"Green",1',
' CHECKBOX,"Blue",1'

parse var result ok red green blue
if ok=0 then exit

if red=1 then do
    'BRIGHTNESS' arg(1) '-255 GREEN BLUE'
end

if green=1 then do
    'BRIGHTNESS' arg(1) '-255 RED BLUE'
end

if blue=1 then do
    'BRIGHTNESS' arg(1) '-255 RED GREEN'
end

exit

/*******************************************************************/
/* This is where control goes when an error code is returned by IE */
/* It puts up a message saying what happened and on which line     */
/*******************************************************************/
error:
if RC=5 then do         /* Did the user just cancel us? */
    IE_TO_FRONT
    LAST_ERROR
    'REQUEST "'||RESULT||'"'
    exit
end
else do
    IE_TO_FRONT
    LAST_ERROR
    'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
    exit
end
