Your IP : 216.73.216.48


Current Path : /usr/X11/share/epic5/help/6_Functions/
Upload File :
Current File : //usr/X11/share/epic5/help/6_Functions/shift

# $EPIC: shift,v 1.4 2003/09/23 01:00:18 nsx Exp $
Synopsis:
   $shift(<word list>)
   $shift(<variable name>)

Technical:
   * If the argument list contains only one word, it will be taken as a 
     variable name! (Do not prepend a $)
   * If the argument list contains more than one word, it will be taken as
     a word list.
   * If provided with <variable name>, this function CHANGES $<variable name>
     by removing its first word.  The return value is that first word.
   * If provided with <word list>, this function returns the first word in
     <word list> and does not change any variable.
   * If $<variable name> does not exist, then the empty string is returned.
   * Double quotes are honored.

Practical:
   This function can destructively remove the first word from an lvalue 
   (ASSIGN variable), or non-destructively remove the first word from 
   an rvalue (string of text).  This is an essential operation when you are
   creating LIFOs, FIFOs, or other types of queues.

Returns:
   The first word, which is "shifted" off of the variable, or the word list,
   whichever applies.  If a variable name is provided, the variable IS CHANGED.

Examples:
   assign foo blah booya
   $shift(foo)                    removes "blah" from $foo and returns "blah".
   $shift(one two three)	  returns "one" -- no variable is changed.

See Also:
   pop(6); push(6); unshift(5)