Go to:  Davar site entry | Site contents | Site index | Personal Computer | PBCC | Text bottom

TAILSTR$  PBCC  (32-bit)  Function

         

TAILSTR$ function evaluates to the string tail of its first parameter that starts right after the first entry of the delimiter, specified by the second parameter.  Special cases are taken care of (see function description below).  With the older and less sophisticated Microsoft BASICs I used to have also the HEADSTR$ function (similar to TAILSTR$), but PBCC offers function EXTRACT$ that covers HEADSTR$ functionality.



 TAILSTR$  Source  Program                       Debugging program               Debugging logout

      ' 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
  
         

 TAILSTR$  Debugging  Program                     Source program               Debugging logout

      ' TAILSTR$(0.0)  Get Character String Tail             09/23/1992-07/05/1997
      ' --------------------------------------------------------------------------

        $INCLUDE "TAILSTR"

        DECLARE FUNCTION TAILSTR$(Strng$,Delim$)

        CLS
        PRINT "TAILSTR$(0.0)  Get Character String Tail  "; DATE$;
        PRINT "  "; LEFT$(TIME$,5)
        PRINT STRING$(59,"-")
        PRINT

        PRINT "TAILSTR$(''   ,'XYZ')='"; _
               TAILSTR$(""   ,"XYZ"); "'"
        PRINT "TAILSTR$('ABC',''   )='"; _
               TAILSTR$("ABC",""   ); "'"
        PRINT "TAILSTR$('ABC','XYZ')='"; _
               TAILSTR$("ABC","XYZ"); "'"
        PRINT "TAILSTR$('ABC','A'  )='"; _
               TAILSTR$("ABC","A"  ); "'"
        PRINT "TAILSTR$('ABC','AB' )='"; _
               TAILSTR$("ABC","AB" ); "'"
        PRINT "TAILSTR$('ABC','C'  )='"; _
               TAILSTR$("ABC","C"  ); "'"

        PRINT
        PRINT "Execution completed - hit [Enter] to continue..."
  
         

 TAILSTR$  Debugging  Logout           Source program      Debugging program

         

   TAILSTR$(0.0)  Get Character String Tail  05-01-2003  17:38
   -----------------------------------------------------------

   TAILSTR$(''   ,'XYZ')=''
   TAILSTR$('ABC',''   )=''
   TAILSTR$('ABC','XYZ')=''
   TAILSTR$('ABC','A'  )='BC'
   TAILSTR$('ABC','AB' )='C'
   TAILSTR$('ABC','C'  )=''

   Execution completed - hit [Enter] to continue...
	
      

         

View [and save] TAILSTR.BAS text       View [and save] ZTAILSTR.BAS text
(Use [Back] button or [Alt]+[CL] to return here from the viewed text)
Copyright © 1992–1996 by
Go to:  Davar site entry | Site contents | Site index | Personal Computer | PBCC | Text top