TIP: Click on subject to list as thread! ANSI
echo: foxpro
to: ALL
from: DAVID POWELL
date: 1997-01-03 20:45:00
subject: FPLib(): Choose()

*!*******************************************************************
*! Function..........: Choose()
*! Author............: David Lee Powell
*! Project...........: FPLib()
*! Created...........: 13-Aug-1992
*! Copyright.........: (c) Data-Train MicroComputing, 1992
*) Description.......: Returns item from character string that is
*)                   : delimited by a specified delimiter.
*)                   : Inspired by Lotus 123's function of same name
*! Syntax............: lcElement = Choose( jcStr, jnPos, jcSep )
*! Parameter list....: jcStr - character string with list of items
*!                   : jnPos - position in list (optional)
*!                   : jcSep - delimiter used to separate items (optional)
*! Platform..........: DOS/WIN/MAC
*! Major change list.: None
*! Called by.........: Any
*! Calls.............: None
*!*******************************************************************
FUNC Choose
PARA jcStr, jnPos, jcSep
PRIV ALL LIKE j*
 
IF TYPE("jcStr") != "C" OR EMPT(jcStr)
   RETU ""
ENDI
IF TYPE("jnPos") != "N" OR jnPos < 1
   jnPos = 1
ENDI
IF TYPE("jcSep") != "C" OR LEN(jcSep) = 0
   jcSep = ","
ENDI 
jcStr = ALLT(jcStr)
IF RIGH(jcStr,1) = jcSep
   jcStr = LEFT(jcStr,LEN(jcStr)-1)
ENDI
jnCnt = OCCU(jcSep,jcStr)+1
IF ! BETW(jnPos,1,jnCnt)
   RETU ""
ENDI
DO CASE
   CASE AT(jcSep,jcStr) = 0
      lcRetVal = jcStr
   CASE jnPos = jnCnt
      lcRetVal = SUBS(jcStr,RAT(jcSep,jcStr)+1)
   OTHE
      lcRetVal = LEFT(jcStr,AT(jcSep,jcStr,jnPos)-1)
      lcRetVal = SUBS(lcRetVal,RAT(jcSep,lcRetVal)+1)
ENDC
lcRetVal = ALLT(lcRetVal)
RETU lcRetVal                          && EOF: Choose()
 
* ------------------------------------------------------------ *
The FoxPro Library still lives.  Table of Contents coming tomorrow.
 
David in Dallas.
--- Maximus/2 3.01
---------------
* Origin: * MacSavvy OS/2 BBS * Dallas, Texas * 972-250-4479 * (1:124/1208)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.