Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create multiple records from a text without splitting words

Status
Not open for further replies.

gjbbroekhuis

Programmer
Jun 11, 2013
17
0
0
NL
Hi,

I'm looking for a simple solution for adding as many records as needed to add a text (say 500 - 600 characters). The tekst is already available as a string.
Just counting characters is not good enough, because we don't want to split words over 2 records. If a word doesn't fit it has to be added to the next record.
In my table the field has 80 positions.

Using memo fields is not an option here.

Regards, Gerrit
 
You can use the VFP functions to get what you need and then do what you want

GETWORDCOUNT( )
Counts the words in a string.

GETWORDNUM( )
Returns the word at the position specified by nIndex in the target string, cString. If cString contains fewer than nIndex words, GetWordNum( ) returns an empty string.

First find out how many words there are in your string.
Then use GETWORDNUM() to retrieve individual words and put them where you need them to go.

Good Luck,
JRB-Bldr

 
thread184-1701073

There are several solutions to your problem in the above thread.

mmerlinn


Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
 
For example you could take Left(text,81), then determine the rightmost space via RAT(), if it's 81, you're lucky and the last word ends at position 80. In the normal this gives you the position of the space you want to break the text, and so you store left(text,pos-1) and remove that part of the text, then go on until the text is shorter than 80 chars and put that into the last record.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top