× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 5/1/2013 10:18 AM, Vidal, Peter wrote:

I would like to have your feedback on this thought / challenge:

I have a description field (let's call it "LongField") which is 64 characters long. I need to print this field but I have only a limited space of 20 characters. I would like to split the field in such a way that I can have it printed in this pre-printed form / column. For example:

/=========================/
LongField = "MAN BASIC W/ BUILT IN OSTOMY SUPPORT/BARRIER, MODULAR SYSTEM"

Required Printed Output:
MAN BASIC W/ BUILT
IN OSTOMY
SUPPORT/BARRIER,
MODULAR SYSTEM
/=========================/

Kurt's idea works fine, but for variety, here's another. Break the long
field into an array of words. Pass through the array, concatenating
them onto temporary fields. If the temporary field is over the limit,
use n-1.

Off the cuff:
t 64a varying
t1 64a varying

t = '';
t1 = '';
for i = 1 to max_array_elem;
t = t + array(i);
if %len(t) > 20; // reached it
// print t1;
t1 = '';
t = array(i);
endif;
t1 = t1 + array(i);
endfor;

This has a problem if any 'word' is longer than 20 bytes, but I didn't
see how you wanted that handled. Having code that breaks sentences into
words is a pretty useful thing to have.
--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.