/*--- XLATE - MS/PCDOS/NIX/WIN - 2005 - Mark McDonald ------------------ XLATE allows you to use WORD functions on strings delimited by a character other than a space such as commas, slashes, etc.. Useful to no end. Can change char 253 to any char, 253 is not used often in strings ----------------------------------------------------------------------*/ T = "The, quick,red,fox, jumps all around,the ,lambs" SAY T SAY "WORD 3 LENGTH (3) = "WORDLENGTH(XLATE(T,','),3) SAY "WORD 5 LENGTH (17) = "WORDLENGTH(XLATE(T,','),5) SAY "WORD 3 INDEX (12) = "WORDINDEX(XLATE(T,','),3) SAY "WORDS IN STRING (7) = "WORDS(XLATE(T,',')) SAY "WORD 3 (red) = "WORD(XLATE(T,','),3) SAY "WORD 5 (jumps...) = "XUNLATE(WORD(XLATE(T,','),5)) PULL Z;EXIT /*--- Translate spaces to ascii char 253 -----------------------------*/ XLATE: PROCEDURE PARSE ARG X, XDL X = TRANSLATE(X,D2C(253)," ") X = TRANSLATE(X," ",XDL) RETURN (X) /*--- Un Translate ascii char 253 to space ---------------------------*/ XUNLATE: PROCEDURE PARSE ARG X X = TRANSLATE(X," ",D2C(253)) RETURN (X) /*--------------------------------------------------------------------*/