// Script function: Bring the two earliest opened images to front and assign Clone ROI on them
// Requirement: Open multiple images

// Unless named starting with GlobalSino, EM, My, Self, the function commands are defined 
//by Gatan DM, please see at link: http://www.globalsino.com/EM/page2597.html


number GlobalSinoImage = CountImageDocuments()
imageDocument ForEMImageA = GetImageDocument( GlobalSinoImage-1 )
image EMImageA := ImageDocumentGetImage( ForEMImageA, 0 )
Showimage (EMImageA)
 
imageDocument ForEMImageB = GetImageDocument( GlobalSinoImage-2 )
image EMImageB := ImageDocumentGetImage( ForEMImageB, 0 )
Showimage (EMImageB)
 

ROI MyROI = NewROI()

MyROI.ROISetPoint( 100, 100 )

MyROI.ROISetVolatile( 0 )

if ( TwoButtonDialog( "Add Clone ROI?", "Clone ROI", "Cancel" ) )
{
 myROI.ROISetLabel( "Clone" )
 EMImageA.ImageGetImageDisplay(0).ImageDisplayAddROI( MyROI )
 EMImageB.ImageGetImageDisplay(0).ImageDisplayAddROI( MyROI.ROIClone()  ) // different from MirrorROI 
// (see at: http://www.globalsino.com/EM/page2597_MirrorROI.s)
}

else
{
Exit(0)
}


 
