' TAILSTR$(0.0)  Get Character String Tail             09/23/1992-07/05/1996
' --------------------------------------------------------------------------
' Copyright (C) 1992-1996 by Vladimir Veytsel                  www.davar.net

' Type ---------------------------------------------------------------------

'    Function

' Declaration --------------------------------------------------------------

'    DECLARE FUNCTION TAILSTR$(Strng$,Delim$)

' Parameters ---------------------------------------------------------------

'    Strng$  - Character string
'    Delim$  - Delimiting substring of string tail

' Value --------------------------------------------------------------------

'  - IF specified string is EMPTY,
'       THEN returned string is EMPTY.

'  - IF specified string is NOT empty        AND
'       delimiting substring is either empty OR
'       NOT found within specified string,
'       THEN returned string is EMPTY.

'  - IF specified string is NOT empty AND
'       delimiter is found within specified string,
'       THEN string tail is returned to the point of invocation.

' Notes --------------------------------------------------------------------

'  - First delimiter occurance from string left side delimits
'    the returned substring.
'  - If specified string ends with unique delimiter,
'    then returned substring will be empty.
'  - Returned substring never contains delimiter itself.

' Examples -----------------------------------------------------------------

'    TAILSTR$(""   ,"XYZ")=""
'    TAILSTR$("ABC",""   )=""
'    TAILSTR$("ABC","XYZ")=""
'    TAILSTR$("ABC","A"  )="BC"
'    TAILSTR$("ABC","AB" )="C"
'    TAILSTR$("ABC","C"  )=""

' Start Function -----------------------------------------------------------

     DEFINT A-Z  ' All defaulted variables are integer

     FUNCTION TAILSTR$(Strng$,Delim$) PUBLIC

' Form and Return Function Value to the Point of Invocation ----------------

     IF ((LEN(Strng$)=0)OR _
         (LEN(Delim$)=0)) THEN
        TAILSTR$=""
     ELSE
        I=INSTR(Strng$,Delim$)
        IF ((I=0)OR _
            (I=LEN(Strng$)-LEN(Delim$)+1)) THEN
           TAILSTR$=""
        ELSE
           TAILSTR$=MID$(Strng$,I+LEN(Delim$))
        END IF
     END IF

' Finish Function ----------------------------------------------------------

     END FUNCTION
