Files
harbour-core/harbour/samples/cccppc/felbont.prg
1999-11-09 01:37:27 +00:00

90 lines
1.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* $Id$
*/
//*******************************************************************
// felbont.prg: Egy string felbont sa elv laszt˘ karakterek mentn.
// 1999, Csisz r Levente
//*******************************************************************
function felbont(str,elvalasztok)
/*
Az str-t felbontja az 'elvalasztok' stringben lev“ karaktereknl, s
ad egy t”mb”t, amiben az elemek vannak.
Ha az 'elvalasztok' nincs megadva, akkor " "+chr(9)-t ttelez fel.
Az <20>reseket kiveszi.
Mj.: A chr(9) a tab karakter.
*/
local t,e,i,pos,elem
if (elvalasztok==nil)
elvalasztok:=" "+chr(9)
elseif (len(elvalasztok)<=0)
if (str=="")
return {}
else
return {str}
endif
endif
e:=left(elvalasztok,1)
for i:=2 to len(elvalasztok)
str:=strtran(str,substr(elvalasztok,i,1),e)
end for
t:={}
while(0<len(str))
if (0==(pos:=at(e,str)))
elem:=str
str:=""
elseif (pos==1)
elem:=""
str:=substr(str,2)
else
elem:=substr(str,1,pos-1)
str:=substr(str,pos+1)
endif
if (!elem=="")
aadd(t,elem)
endif
end while
return t
//*******************************************************************
#ifdef OLD
local wlist:={}, n:=0, i,sep1,welem
if(sep==NIL)
sep:=" "+chr(9)
end
sep1:=left(sep,1)
for i:=2 to len(sep)
txt:=strtran(txt,substr(sep,i,1),sep1)
next
while( n<len(txt) )
txt:=substr(txt,n+1)
if( (i:=at(sep1,txt))==0 )
wElem:=txt
n:=len(txt)
elseif(i==1)
wElem:=""
n:=1
else
wElem:=substr(txt,1,i-1)
n:=i
end
if !(wElem=="")
aadd(wlist,wElem)
endif
end
return wlist
#endif
************************************************************************