;------------------------------------------------------------------------------ ; NAME: POINTPDS ; ; PURPOSE: To process the pointer to an object in a PDS file ; ; CALLING SEQUENCE: Result = POINTPDS (label, filename, objectname) ; ; INPUTS: ; Label: String array containing the PDS header ; Filename: Scalar string containing the name of the PDS file to read ; objectname: The name of the object to process pointer information for ; OUPUTS: ; Result: a structure containing the name of the datafile and the skip ; offset in bytes ; ; OPTIONAL INPUT: none ; ; EXAMPLES: ; To obtain information from TABLE.LBL on a TABLE object: ; IDL> label = HEADPDS ('TABLE.LBL',/SILENT) ; IDL> pointer = POINTPDS (label, 'TABLE.LBL','TABLE') ; IDL> help, /STRUCTURE, pointer ; DATAFILE 'TABLE.TAB' ; SKIP 2056 ; ; PROCEDURES USED: ; Functions: PDSPAR, CLEAN, STR2NUM ; ; MODIFICATION HISTORY: ; August 2002, P. Khetarpal: obtained from IMAGEPDS to work for all ; pointer analyses for PDS programs ; 14 Feb 2003, P. Khetarpal: rewritten to process one object pointer ; at a time. Also, instead of returning ; four variable info, the code is modified ; to return a struct with only needed ; variables. The datafile, if present is ; tested here so as not to put load on the ; program module. ;------------------------------------------------------------------------------ function POINTPDS, label, fname, objname On_error, 2 record_bytes = PDSPAR (label,'RECORD_BYTES') param = '^'+objname point = PDSPAR (label, param) if !ERR EQ -1 then begin print, 'ERROR: pointer to '+objname+' object missing' return, -1 endif point = CLEAN(point[0],/SPACE) savepoint = point ; remove parentheses from string: rightp = strpos(point, '(' ) leftp = strpos(point, ')' ) if rightp GT -1 AND leftp GT -1 then begin rightp = rightp + 1 length = leftp - rightp point = strmid(point, rightp, length) endif ; check for flag and remove it if found: rightp = strpos (point,'') if rightp GT -1 then begin byte_offset_flag = 1 point = strmid(point, 0, rightp) endif else $ byte_offset_flag = -1 ; check for double quotes and extract: rightp = strpos (point, '"') if rightp GT -1 then begin leftp = strpos (point,'"', rightp + 1) endif else $ leftp = -1 ; if there was a filename, save it datafile = '' if rightp GT -1 AND leftp GT -1 then begin rightp = rightp + 1 length = leftp - rightp datafile = strmid (point, rightp, length) ; remove the file name from the pointer string length = strlen(point) - leftp point = strmid (point,leftp + 1, length) endif else if rightp EQ -1 XOR leftp EQ -1 then begin message, 'ERROR: badly formatted file pointer '+savepoint endif ; obtain bytes_offset or skip bytes rightp = strpos (point,',') if rightp GT -1 then begin rightp = rightp + 1 length = strlen(point) point = strmid (point, rightp, length-rightp) endif if strlen (point) EQ 0 then begin skip = 0 endif else begin skip = long(STR2NUM (point)) endelse if byte_offset_flag EQ -1 AND skip NE 0 then $ skip = (skip-1) * record_bytes[0] ;if there is a datafile, then check: if strlen(datafile) GT 0 then begin dir = fname rightp = strpos (dir,'/') last_slash = rightp while rightp GE 0 do begin last_slash = rightp rightp = strpos (dir,'/',rightp+1) endwhile if last_slash GT 0 then begin dir = strmid (dir,0,last_slash+1) endif else begin dir = '' endelse ; if data file is in mixed case: fname = dir + datafile openr, unit, fname, ERROR=err, /GET_LUN ; if real name is in lower case: if err NE 0 then begin fname = dir + strlowcase (datafile) openr, unit, fname, ERROR=err, /GET_LUN endif ; if real name is in upper case: if err NE 0 then begin fname = dir+ strupcase (datafile) openr, unit, fname, ERROR=err, /GET_LUN endif if err NE 0 then begin message, 'ERROR: could not open data file: '+dir+datafile endif endif else begin openr, unit, fname, ERROR=err, /GET_LUN if err NE 0 then begin message, 'ERROR: could not re-open '+fname endif endelse close, unit free_lun, unit pointer = CREATE_STRUCT ('datafile',fname,'skip',skip) return, pointer end