home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
rettig
/
source
/
wrap.c
< prev
Wrap
C/C++ Source or Header
|
1990-10-21
|
1KB
|
48 lines
/*********
* WRAP.C
*
* by Tom Rettig
*
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
* Syntax: WRAP( <expC>, <max len> )
* Return: <expN> position of last space less than or equal to <max len>,
* or position of last char in <expC> if less than <max len>.
* Returns <max len> of word and breaks the rest
* to the next line.
* Note..: Hyphens are not included so as not to cause a wrap on
* a negative number like -100.
*********/
#include "trlib.h"
TRTYPE wrap()
{
char *instr;
int end, too_long;
if ( PCOUNT==2 && ISCHAR(1) && ISNUM(2) )
{
instr = _parc(1);
end = too_long = _parni(2);
if (end <= 0)
{
_retni( ERROR ); /* 0 error value */
return;
}
if ( _tr_strlen(instr) > end )
{
while ( instr[end] != SPACEC )
end--;
_retni( (end >= 0) ? end : too_long );
}
else
_retni( _tr_strlen(instr) );
}
else
_retni( ERROR ); /* 0 error value */
}