function strpost,target,char,length,offset,occurance ;csee 16feb07 ;this function returns the string following 'char' in 'target' ;i.e. if target = 'alpha = 1.05' then result = strpost(target,'=',3,2,1) = '.05' ;length is the number of characters included in the result ;offset is the number of interviening charcters between 'char' and 'result' ;occurance is which occurance of 'char' to use (i.e. 1=1st, 2=2nd, etc) ;target & char must be sting vaiables ;length, offset and occurance are intigers ;result is a sting result='NUL' ;sort out missing parameters (defaults)... if n_params() eq 2 then goto,p2 if n_params() eq 3 then goto,p3 if n_params() eq 4 then goto,p4 goto,p5 p2: length=100 ;default length of result is 100 characters p3: offset=0 ;default offset is 0 (the next character after 'char') p4: occurance=1 ;default occurance is the 1st occurance in 'target' of 'char' p5: pos=-1 ;start at the beginning. ;calculate pos of occurance... for i=1,occurance do begin pos=strpos(target,char,pos+1) if pos eq -1 then begin print, 'There is(are) only ',sstr(i-1),' occurances of "',char,'" in "',target,'"' print,'returning...' goto,exit endif endfor off2=strlen(char) result=strmid(target,strpos(target,char,pos)+offset+off2,length) exit: return,result end