! ! UserZipStitch.scr ! 07/17/2000 pal ! Created this script to be the controlling script over ! Zip-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 ZipFn$[200] dim ZipMaskFn$[200] START_OF_ZIP_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 gosub RESUME_NEXT g_idTRMaskMode = 0 g_idTRMaskMode = getid(" Surface\Wavefront Map (T+R) / Controls / Mask Mode ") if (g_idTRMaskMode = 0) then g_idTRMaskMode = getid(" Surface\Wavefront Map (T+R) / Controls / Segmentation / Segmentation Mode ") endif on error goto USER_ST_ERR_EXIT if (g_idTRMaskMode <> 0) then MaskMode$ = getval$(g_idTRMaskMode) setstr(g_idTRMaskMode, "Editor") endif gosub CLEAR_USER_ABORT runscript(0, "ZipStitch.scr") ! run the Standard Zip-Stitch script ! ! At this point of the all 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_idZipFileID = getid("Controls/ZipStitch/ZipFile") ZipFn$ = getval$( g_idZipFileID ) g_idZipAutoLdMskCntl = getid("controls/ZipStitch/AutoLoadMasks") AutoLoadZipMask = getval(g_idZipAutoLdMskCntl, "") if ( AutoLoadZipMask = 1) then g_idZipMskFileCntl = getid("controls/ZipStitch/MasksFile") ZipMaskFn$ = getval$(g_idZipMskFileCntl) on error gosub NO_ZIP_MASK loadmasks(ZipMaskFn$) on error goto USER_ST_ERR_EXIT else resetmasks endif ! ! Restore auto aperture and Mask Mode ! if ( g_idAutoApId <> 0 ) then setnum(g_idAutoApId,AutoAp,"") ! restore auto aperture if ( g_idTRMaskMode <> 0 ) then setstr(g_idTRMaskMode, MaskMode$) ! ! 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_ZIP_FILE loaddata( ZipFn$ ) on error goto USER_ST_ERR_EXIT endif ! ! Determine if Process Stats should be stored ! g_idZipStProcStsCntl = getid("controls/ZipStitch/StoreProcessStats") StrPrSts = getval(g_idZipStProcStsCntl, "") 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 zip-stitching") goto USER_ZIP_EXIT NO_ZIP_FILE: gosub CHK_USER_ABORT if ( g_bUserAbort = 0 ) then on error gosub RESUME_NEXT ok = dialog(" Could not find zip-stitch file: " & ZipFn$, 2) endif goto USER_ZIP_EXIT USER_ST_ERR_EXIT: on error gosub RESUME_NEXT ok = dialog("Error Occurred " & errm$,2) goto USER_ZIP_EXIT USER_ZIP_EXIT: ! Make sure the controls are reset if ( g_idAutoApId <> 0 ) then setnum(g_idAutoApId,AutoAp,"") if ( g_idTRMaskMode <> 0 ) then setstr(g_idTRMaskMode, MaskMode$) end ! ! SUBROUTINES ! ! ! NO_ZIP_MASK - displays error message when the mask could not be found ! NO_ZIP_MASK: on error gosub RESUME_NEXT ok = dialog(" Could not find mask file: " & ZipMaskFn$, 2) error return ! ! NO_MASK_MODE - sets g_idTRMaskMode to 0 when Mask Mode does not exist ! NO_MASK_MODE: g_idTRMaskMode = 0 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