Go to:  Site entry | Site contents | Site index | Personal computer | JavaScript | Text bottom

TAILSTR  JavaScript  Function

TAILSTR JavaScript (stand-alone) is a function that extracts and returns the tail of the argument string after the first occurence the argument delimiter (delimiter is not returned).

Script is fairly simple: it checks for several special cases and, if none of them was encounted, extracts the required substring and returns it as the function value.

Along with its counterpart HEADSTR, this script provides a convenient tool for simple parsing of variable length symbolic strings  An example of TAILSTR function usage for string parsing can be found in the POSITION.JS function.

TAILSTR JavaScript was converted from an old PL/I program with the same name.  The development of the HEADSTR/TAILSTR pair of functions was prompted by the capability of PL/I to handle efficiently variable lenght strings.  It was back in the mid 1970-th when I've first written these functions in order to implement a variable length buffer processing methods (certain tasks can be substantially simplified when one process adds to the end of the buffer and another one cuts from it's head)  CAR/CDR of LISP have prompted this idea to me; both functions proved to be quite effective.  Parsing wasn't their originally intended use, but they appeared to be an effective tool for parsing as well.

TAILSTR JavaScript is a stand-alone one, which means that it s kept in a separate TAILSTR.JS file, that gets included into HTML <HEAD> (normally at its end) using the following operator (directory levelling may vary):

Included function is used in the <BODY> of HTML (most often in some other JavaScript function) in a way similar to the following:

         <SCRIPT LANGUAGE=JavaScript>
          // document.write(ALPHABET())
The code above gets displayed by the browser as a line of hyperlinks to the letters of an index:

<!-- Alphabeth Hyperlinks Generation  08/30/200009/01/2000 -->
<!-- ------------------------------------------- 09/01/2000 -->
<!-- www.davar.net/ALPHABET.JS                              -->
<!-- Copyright (C) 2000 by Vladimir Veytsel                 -->

// Generates a line of alphabeth hyperlinks to be used in text index.
// Serves merely as a shorthand to save typing as well as page loading
// time by eliminating massive HTML repetitions.

// The letter to be skipped (when specified) won't show in the generated
// alphabeth line (used when alphabeth line is for the links from this letter).

// The returned value is the HTML for hyperlinked alphabeth line to be used
// in the "document.write".

   function ALPHABET(Skip)
            {// Skip   - Alphabeth letter to be skipped
             for (i=0;i<26;i++)
                  if ((Alpha_Line!="" )&&  // Suppress ending "|" on the sides
                      (!((Skip   =="Z")&&
                         (Letter =="Z"))))
                     Alpha_Line=Alpha_Line+"<FONT COLOR=Green>|</FONT>"
                  if (Letter!=Skip)        // Suppress "Skip" letter (if any)
                     Alpha_Line=Alpha_Line+" <A HREF='#"+Letter+"'>"+Letter+"</A>"
                  if ((Letter!="Z")&&      // Suppress extra blanks
                     Alpha_Line=Alpha_Line+" "
             return Alpha_Line

View Index of PC FAQ   (Use [Back] button or [Alt]+[CL] to return here)
View [and save] ALPHABET.TXT text   (Use [Back] button or [Alt]+[CL] to return here)
To make text executable rename it to *.JS and make a global change of "&lt;" into "<" signs.
Go to:  Site entry | Site contents | Site index | Personal computer | JavaScript | Text top