*
* DropLastChar.PRG
* RETURNs the passed string minus the
* very last character.
*
* Mike Yearwood's FoxPro Advisor Magazine tip
* http://my.advisor.com/articles.nsf/aid/14710
* showed when building a comma-delimited list, the
* fastest way of dealing with an extraneous comma
* is to add the comma after each item and then drop
* the final comma. This routine unconditionally
* drops the last character from the end
* of the passed specified string.
* Further, instead of having a cryptic formula to drop the
* last character, which you should comment every time it's used,
* you have a readable function name. This makes the calling
* code self-documenting.
*
* It will produce ERROR 11 if parameters are
* passed improperly.
*
* Copyright (c) 2005 Fox Ridge Software, Inc. All Rights Reserved
* 120 Parsell Square
* Toronto, ON M1B 2A6
* 416-282-3942
* http://www.foxridgesoftware.com
*
* Donated freely to the Visual FoxPro community.
*
* Author: Mike Yearwood - In memory of Drew Speedie
*
* USAGE
* =====================================
* LOCAL m.lcString, m.lnI
* m.lcString = ""
* FOR m.lnI = 1 to FCOUNT()
* m.lcString = m.lcString + FIELD(m.lnI) + ","
* ENDFOR
* m.lcString = DropLastChar(m.lcString)
*
* PARAMETERS
* =====================================
* tcString (R) String from which last character
* must be removed.
*
LPARAMETERS m.tcString
IF VARTYPE(m.tcString) # "C"
ERROR 11
ENDIF
RETURN IIF(LENC(m.tcString)=0,m.tcString,;
LEFTC(m.tcString,LENC(m.tcString)-1))