User Tools

Site Tools


left

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

left [2006/08/01 04:13] (current)
Line 1: Line 1:
 +# $EPIC: left.txt,v 1.4 2006/08/01 04:12:59 sthalik Exp $
 +======Synopsis:​======
 +$__left__(<​count>​ <​text>​)
 +
 +======Technical:​======
 +   * If <​count>​ is omitted, this function returns the empty string.
 +   * If <​text>​ is omitted, this function returns the empty string.
 +   * If <​count>​ is less than 0, this function returns the empty string.
 +   * If <​text>​ is more than <​count>​ characters long, then this function will return a copy of the first <​count>​ characters in <​text>​.
 +   * If <​text>​ is less than or exactly <​count>​ characters long, then this function will return a copy of <​text>​
 +
 +======Practical:​======
 +Whenever you need to extract the initial part of a string, you would use
 +this function to get it.  This is more useful for fixed-format strings.
 +ircII used to use $left($[[index]](<​char>​ <​text>​) <​text>​) to extract the part
 +of <​text>​ that was before <​char>​. ​ In EPIC, use $[[before]](<​char>​ <​text>​)
 +because it is faster, more clear, and doesn'​t require two copies of <​text>,​
 +which may be important if <​text>​ is a function call.
 +
 +======Returns:​======
 +The first <​count>​ characters in <​text>​. ​ No padding is done.  If you need
 +a string that is always <​count>​ characters long, try:
 +<​file>​
 +$pad(<​count>​ " " $left(<​count>​ <​text>​))
 +</​file>​
 +
 +======Examples:​======
 +<​file>​
 +$left(5 biklmnopstv) ​                    ​returns "​biklm"​
 +$left(15 biklmnopstv) ​                   returns "​biklmnopstv"​
 +$left(-2 biklmnopstv) ​                   returns nothing
 +$left($index(@ $userhost()) $userhost()) returns a username in an /on.
 +  -- Note that this construction is obsolete, but is still used by some.
 +</​file>​
 +
 +======History:​======
 +This function first appeared in ircII.
  
left.txt ยท Last modified: 2006/08/01 04:13 (external edit)