PROCEDURE fred$extract(delimiter,reference_string,context) LOCAL len, ! Length of reference string temp, ! Work area for reference string temp1, ! Location of delimiter start, ! Start of substring end, ! End of substring sub_length, ! Length of substring sub_string; ! Element of reference string to return temp := reference_string; len := LENGTH (temp); if context = 0 then temp1 := INDEX (SUBSTR (temp,1,len),delimiter); if temp1 = 0 then end := len; else end := temp1 - 1; endif; sub_length := end; start := 1; else end := fred$x_extract_end; if end = len then RETURN (0); endif; start := end + 2; temp1 := INDEX (SUBSTR (temp,start,len),delimiter); if temp1 = 0 then end := len; sub_length := end; else end := end + temp1; sub_length := temp1 - 1; endif; endif; sub_string := SUBSTR (temp,start,sub_length); fred$x_extract_start := start; fred$x_extract_end := end; RETURN (sub_string); ENDPROCEDURE;