TIB: Strings


[Prev][Next][Index][Thread]

TIB: Strings



Can anyone help me with this?  It is supposed to be a function that gives a makes the inputted string seperated by spaces for the inputted length.  Here, I'll even throw in an example:
 
input:
chkdrstr("This is an example of what this function is supposed to do.",10)
result:
"This is anexample ofwhat this function  is        supposed  to do."
 
so that when I use the string, it will look like this:
 
/---10---\
"
This is an
example of
what this
function 
is       
supposed 
to do.
"
 
:chkdrstr(str,w)
:Func
:Local x,y,s,z
:0»x
:str&" "»str
:While dim(str)>0
:x+1»x
:For y,w,1,«1
:If mid(str,y,1)=" "
:Exit
:EndFor
:mid("                          ",1,w-y)»z
:mid(str,1,y)&z»s[x]
:mid(str,y+1)»str
:If mid(str,1,1)=" "
:mid(str,2)»str
:EndWhile
:""»str
:For y,1,x
:str&s[y]»str
:EndFor
:Return str
:EndFunc
 
-Miles Raymond      EML: m_rayman@bigfoot.com
ICQ: 13217756       IRC: Killer2        AIM: MRayMan
http://www.bigfoot.com/~m_rayman/

CHKDRSTR.89F