REM
REM Contributed by James C. Fuller - April 2009.
REM
REM RTRIM
REM multiple entries in Match$ are treated individually
FUNCTION RTrim(STRING Main$,STRING Match$)
    LOCAL mlen,mtlen,i,j TYPE int
    i = 0
    
    mlen = LEN(Main$)
    j = mlen
    mtlen = LEN(Match$)
    IF (mlen EQ 0) OR (mtlen EQ 0) THEN
        RETURN Main$
    END IF
    FOR i = mlen TO 1 STEP -1
       IF INSTR(Match$,MID$(Main$,i,1),1) EQ 0 THEN
            RETURN LEFT$(Main$,j)
       ELSE
           j = j - 1
       END IF      
    NEXT
REM needed to elimnate compiler warning. Never used    
    RETURN Main$
END FUNCTION
REM Test
REM PRINT RTrim("James Fuller    ",CONCAT$(" ",CHR$(9)));
REM PRINT "More"