PRO ;+ ; ; NAME: ; ; PURPOSE: ; ; CATEGORY: ; ; CALLING SEQUENCE: ; ; INPUTS: ; ; OPTIONAL INPUT PARAMETERS: ; ; OUTPUTS: ; ; OPTIONAL OUTPUT PARAMETERS: ; ; KEYWORDS: ; ; COMMON BLOCKS: ; ; SIDE EFFECTS: ; ; RESTRICTIONS: ; ; EXAMPLE: ; ; PROCEDURE: ; ; ; MODIFICATION HISTORY: ; ; ;---------------------------------------------------------------------------- ; D I S R S O F T (C) 1 9 9 4 ;----------------------------------------------------------------------------- ;- STATUS=STRARR(4) STATUS(0)='S' STATUS(1)='SUCCESS' ; USER enter name of routine inside quotes STATUS(2)='' ; leave this STATUS(3)='' STATUS_SET=0 ; enter version number inside quotes VERSION='' ; enter the full procedure call in here CALL='' ; if the program is a function then set the output variable to the ; default failure value (-1) before entering error checking OUTPUT=-1 ; error checking ---- insert maximum and minimum number of parameter IF (N_PARAMS(0) LT ) OR (N_PARAMS(0) GT ) THEN BEGIN STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)='Bad input parameters' PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : '+STATUS(3)+'. EXIT.' PRINT,'Call is '+CALL GOTO,LEAVE ENDIF ; the status report should be the last parameter. Enter the number ; of parameters in the routine into the IF statement IF N_PARAMS(0) EQ THEN STATUS_SET=1 ; if your program includes a DISRSOFT header as input then you can ; verify existence using OUTPUT=D_EXIST(HEADER_IN,ERROR_MESS,/HEADER,STATUS) IF OUTPUT NE 1 THEN BEGIN STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)=ERROR_MESS IF STATUS_SET EQ 0 THEN BEGIN PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : '+STATUS(3)+'. EXIT.' ENDIF GOTO,LEAVE ENDIF ; if your program includes pixels as input then you can ; verify existence using OUTPUT=D_EXIST(PIXELS_IN,ERROR_MESS,/PIXELS,STATUS) IF OUTPUT NE 1 THEN BEGIN STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)=ERROR_MESS IF STATUS_SET EQ 0 THEN BEGIN PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : '+STATUS(3)+'. EXIT.' ENDIF GOTO,LEAVE ENDIF ; if your program calls another DISRSOFT routine then you should ; use a status checker e.g. if you call D_READ BY ; ; D_READ,'image',h,p,status1 ; ; then the following code will produce a controlled exit if an error ; occurs on the DISRSOFT routine. IF STRUPCASE(STRMID(STRTRIM(STATUS1(0),2),0,1)) NE 'S' THEN BEGIN STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)=' ROUTINE NAME produced an error' IF STATUS_SET EQ 0 THEN BEGIN PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : '+STATUS(3)+'. EXIT.' ENDIF GOTO,LEAVE ENDIF ; for widget applications use the following section of code ; this forces HPs into 8 bit graphics IF STRTRIM(STRUPCASE(!VERSION.OS),2) EQ 'HP-UX' THEN DEVICE,PSEUDO=8 ; test if widgets are available TEST=T_WIDGET() IF TEST EQ 0 THEN BEGIN STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)='No widgets available' IF STATUS_SET EQ 0 THEN BEGIN PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : '+STATUS(3)+'. EXIT.' ENDIF GOTO,LEAVE ENDIF ; this tests if the routine is already registered with the X manager IF(XRegistered(status(2)) NE 0) THEN BEGIN STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)=STRTRIM(STATUS(2),2)+' already registered' IF STATUS_SET EQ 0 THEN BEGIN PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : '+STATUS(3)+'. EXIT.' ENDIF GOTO,LEAVE ENDIF ; end of widget specific code ; enter your main routine here ; cleaning up for file manipulation errors GOTO,LEAVE CLOSING: STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)='I/O error' ; if the status parameter is not set then print to screen IF STATUS_SET EQ 0 THEN BEGIN PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : '+STATUS(3)+'. Exiting.' ENDIF CLOSE,UNIT FREE_LUN,UNIT LEAVE: RETURN ; or RETURN,OUTPUT if the program is a function END