Split string without splitting words

Rauf

Rauf

VIP Member
I need to split amount in words to print in pre printed bank form.

For example, the amount is 181,112.21 USD
The complete 'Amount in words' will be US DOLLAR ONE HUNDRED EIGHTY ONE THOUSAND ONE HUNDRED TWELVE AND 21/100 ONLY

In the pre printed form it should come in three lines. I cannot do word-wrap as it affects alignment. Instead I use three varaible (of size 30) to hold the three lines.
If I do a 'hard' split(using substr()), I will get the following lines

US DOLLAR ONE HUNDRED EIGHTY
ONE THOUSAND ONE HUNDRED TWE
LVE AND 21/100 ONLY

The line one is okay. But line two splits TWELVE to 'TWE' and 'LVE' which is not acceptable.

It should be like
US DOLLAR ONE HUNDRED EIGHTY
ONE THOUSAND ONE HUNDRED
TWELVE AND 21/100 ONLY

Is there anyway to do this by programming ?
 
I'm not playing in E1 at the moment, but my suggestion would be to do the "hard split" (substr)
into a 30 character and a 30+ character alpha, and test the 30+ character for non-blank 1st character,
which SHOULD get you the "L" from "TWELVE".

Not elegant, but I think it would work...
 
Back
Top