Txt-Delimited string

From Vectorlab
Jump to: navigation, search


Function to extract delimited text from a string. Returns the resulting string. By Orso B. Schmid


{ Orso *********************************************** }
{ extracts delimited text }
FUNCTION T_DelimitedString(sourceStr, delim1, delim2: STRING): STRING;
	VAR
		delimTxt, rest : STRING;
		copyStart, copyEnd, copyCnt : INTEGER;
		
	BEGIN
		delimTxt := '';
		copyStart := Pos(delim1, sourceStr);
		
		IF copyStart > 0 THEN BEGIN
			copyStart := copyStart + Len(delim1);
			rest := Copy(sourceStr, copyStart, Len(sourceStr));
			copyEnd := Pos(delim2, rest);
			
			IF copyEnd > 0 THEN
				delimTxt := Copy(sourceStr, copyStart, copyEnd-1);
		END;

		T_DelimitedString := delimTxt;
	END;