FUNCTION INSTR(BYVAL TEXT_DATA AS TEXT, BYVAL TEXT_FIND AS TEXT)AS INTEGER ; Match Sub-String and Return its Position I INTEGER J INTEGER FOR I FROM 1 TO LEN(TEXT_DATA) - LEN(TEXT_FIND) + 1 FOR J FROM 1 TO LEN(TEXT_FIND) IF SUBSTR(TEXT_FIND,J,1) <> SUBSTR(TEXT_DATA,I + J - 1,1) THEN QUITLOOP ENDIF ENDFOR If J = LEN(TEXT_FIND) + 1 THEN RETURN I ENDIF ENDFOR RETURN 0 ENDFUNCTION
FUNCTION REPLACE_STR(BYVAL TEXT_DATA AS TEXT, BYVAL TEXT_FIND AS TEXT, BYVAL TEXT_REPLACE AS TEXT)AS TEXT ; Recursively Replace Sub-String (TEXT_FIND) with a string (TEXT_REPLACE) I INTEGER J INTEGER FOR I FROM 1 TO LEN(TEXT_DATA) - LEN(TEXT_FIND) + 1 FOR J FROM 1 TO LEN(TEXT_FIND) IF SUBSTR(TEXT_FIND,J,1) <> SUBSTR(TEXT_DATA,I + J - 1,1) THEN QUITLOOP ENDIF ENDFOR If J = LEN(TEXT_FIND) + 1 THEN STR_1 = SUBSTR(TEXT_DATA, 1, I - 1) STR_2 = SUBSTR(TEXT_DATA, I + LEN(TEXT_FIND) - 1, LEN(TEXT_DATA) - LEN(TEXT_REPLACE)) TEXT_DATA = SUBSTR(TEXT_DATA, 1, I - 1) + TEXT_REPLACE + SUBSTR(TEXT_DATA, I + LEN(TEXT_FIND), LEN(TEXT_DATA) - LEN(TEXT_REPLACE)) ENDIF ENDFOR RETURN TEXT_DATA ENDFUNCTION