! ! UserStitch.scr ! 10/08/97 mdc Created this script to be the controlling script over Stitching ! This script can be modified by the user to add pre and post ! stitching activities. Note that the loading of the Stitched data ! is done here and not done in GenStitch.scr. ! ! 07/17/2002 PAL Added code so there is always an error handler ! ! 02/18/2003 PAL Added RESUME_NEXT error handler that ignores errors. Also ! made sure there is always an appropriate error handler in use. ! dim StitchFn$[200] dim StitchMaskFn$[200] START_OF_STITCH: ! ! runscript(0, "Any script you want to run before stitching") ! ! Auto Aperture does not exist in all apps on error gosub RESUME_NEXT g_idAutoApId = 0 g_idAutoApId = getid("Controls/AutoAperture/AutoAperture") if ( g_idAutoApId = 0 ) then g_idAutoApId = getid("Controls/AutoAperture") endif on error goto USER_ST_ERR_EXIT if ( g_idAutoApId <> 0 ) then AutoAp = getval( g_idAutoApId, "" ) ! save temp copy setnum(g_idAutoApId ,0 ,"") ! shut off auto aperture till the end endif on error goto USER_STITCH_EXIT gosub CLEAR_USER_ABORT runscript(0, "GenStitch.scr") ! run the Standard Stitch script on error goto USER_ST_ERR_EXIT ! ! At this point the Stitching is complete. ! If any controls need to be changed, change them here so the analysis ! will be done when the data is loaded ! ! runscript(0, "Any script you want to run before the data is loaded") ! ! Determine if Masks should be loaded ! g_idStitchFileID = getid( "Controls/Stitch/StitchFile" ) StitchFn$ = getval$( g_idStitchFileID ) g_idStchAutoLdMskCntl = getid("controls/stitch/AutoLoadMasks") AutoLoadStitchMask = getval(g_idStchAutoLdMskCntl, "") if ( AutoLoadStitchMask = 1) then g_idStchMskFileCntl = getid("controls/stitch/MasksFile") StitchMaskFn$ = getval$(g_idStchMskFileCntl) on error gosub NO_STITCH_MASK loadmasks(StitchMaskFn$) on error goto USER_ST_ERR_EXIT else resetmasks endif ! ! Restore auto aperture ! if ( g_idAutoApId <> 0 ) then setnum(g_idAutoApId,AutoAp,"") ! restore auto aperture ! ! Load data if Stitching or if Zip Stitching and has show Stitched Data on or ! g_idZipShowStchSurfCntl = getid("controls/ZipStitch/DisplayStitchedSurfaces") ZipShowStch = getval(g_idZipShowStchSurfCntl, "") if ((DoZip=0) OR (ZipShowStch=1)) then ! do not disp if zip and no show on error goto NO_STITCH_FILE loaddata( StitchFn$ ) on error goto USER_ST_ERR_EXIT endif ! ! Determine if Process Stats should be stored ! g_idStchStProcStsCntl = getid("controls/stitch/StoreProcessStats") StrPrSts = getval(g_idStchStProcStsCntl, "") if ( StrPrSts = 1 ) then storeprocstats ! ! Determine if Reports should be logged ! g_idStchLogReportsCntl = getid("controls/stitch/LogReports") LogReports = getval(g_idStchLogReportsCntl, "") if ( LogReports = 1 ) then logreports ! ! runscript(0, "Any script you want to run after stitching") goto USER_STITCH_EXIT NO_STITCH_FILE: gosub CHK_USER_ABORT if ( g_bUserAbort = 0 ) then on error gosub RESUME_NEXT ok = dialog(" Could not find stitch file: " & StitchFn$, 2) endif goto USER_STITCH_EXIT USER_ST_ERR_EXIT: on error gosub RESUME_NEXT ok = dialog(" Error Occurred \n" & errm$, 2) goto USER_STITCH_EXIT USER_STITCH_EXIT: ! Make sure the auto aperture is reset if ( g_idAutoApId <> 0 ) then setnum(g_idAutoApId,AutoAp,"") end ! ! SUBROUTINES ! ! ! NO_STITCH_MASK - displays error message when the mask could not be found ! NO_STITCH_MASK: ok = dialog(" Could not find mask file: " & StitchMaskFn$, 2) error return ! ! RESUME_NEXT - Ignores the error ! RESUME_NEXT: error return ! ! CHK_USER_ABORT - Checks to see if the user pressed the ESC key ! CHK_USER_ABORT: g_bUserAbort = 0 if (trim$(errm$) = "Processing aborted.") then g_bUserAbort = 1 ! Delete the old file if (g_bUNIX = 1) then l_nTemp = execute("rm -f UserAbort" ) else l_nTemp = execute("erase /f /q UserAbort" ) endif ! Create the new file assign @fpUserAbort to "UserAbort" "w" assign @fpUserAbort to "" else on error gosub RESUME_NEXT ! Get a new error message l_nTemp = 1 / 0 ! Try to open the file assign @fpUserAbort to "UserAbort" "r" if ( trim$(errm$) = "Cannot open 'UserAbort' for mode 'r': No such file or directory" ) then g_bUserAbort = 0 else g_bUserAbort = 1 endif assign @fpUserAbort to "" on error goto USER_ST_ERR_EXIT endif return ! ! CLEAR_USER_ABORT - Erase the fact that the user pressed the ESC key ! CLEAR_USER_ABORT: on error gosub RESUME_NEXT if (g_bUNIX = 1) then l_nTemp = execute("rm -f UserAbort" ) else l_nTemp = execute("erase /f /q UserAbort" ) endif l_nTemp = 1 / 0 on error goto USER_ST_ERR_EXIT return