function strhas,full_string,sub_string ;+ ; ; STRHAS: A function to determine whether a given string contains the ; specified substring. Returns 1 if it does and 0 if it doesn't. ; ; Call Sequence: ; Result = STRHAS(FULL_STRING, SUB_STRING) ; ; Inputs: ; FULL_STRING - The full string to be searched. ; SUB_STRING - The substring to be found in FULL_STRING ; ; Returns: ; 1 if FULL_STRING contains SUB_STRING, ; 0 if FULL_STRING does not contain SUB_STRING. ; If FULL_STRING is an array, returns array of equal size containing ; zeros and ones. ; ; Notes: Really just a wrapper for (strpos( ) ne -1) syntax. ; ; Katie Peek / May 2006 ; ;- ; Find out how big to make ASSESS. sz = size(full_string,/dimensions) if (sz[0] eq 0) then assess = 0 else assess = intarr(sz) ; Use STRPOS to determine if SUB_STRING is in FULL_STRING, ; set those values to 1. w = where(strpos(full_string,sub_string) ne -1) if (w[0] ne -1) then assess[w] = 1 ; Return result. return,assess end