Txt-Delimited string dynarray of char

From Vectorlab
Jump to: navigation, search


Function to return a delimited string as uppercase. Sets a variable with the extracted text and returns an integer corresponding to the position of the found text (if any). By Orso B. Schmid


{ Orso *********************************************** }
{ extracts delimited text, set up DYNARRAY[] OF char, returns the Pos of found item }
FUNCTION T_DelimitedStringXXL(sourceStr, delim1, delim2: DYNARRAY[] OF CHAR; VAR delimited: DYNARRAY[] OF CHAR): INTEGER;
	VAR
		delimTxt, rest : DYNARRAY[] OF CHAR;
		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;

		delimited := delimTxt;
		T_DelimitedStringXXL := copyStart;
	END;