I have Crystal 9.2. I have to take the number found in a memo field and write it out (24.5 would be "twenty four and one half hours"). I thought if I could locate the decimal I could print the numbers on either side. Any help would be appreciated.
I think you should isolate the numbers first and then use the towords function:
stringvar array x := split({table.memo}," ");
numbervar i;
numbervar j := ubound(x);
stringvar y := "";
for i := 1 to j do(
if not isnumeric(x) then
y := y + x+" " else
if isnumeric(x then
y := y + towords(tonumber(x),1)+" "
);
y
...where the 1 in the towords function indicates the number of decimals--although the decimals are expressed as a fraction like this: .5 becomes 5/10 or 50/100 if you set it to "2".
You should also be aware that arrays will only hold up to 1000 values so if your memo field contains more than a thousand words and your number is in position 1001 then this method won't work
WhilePrintingRecords;
Local StringVar Text := {@test};
Local Numbervar i;
Local NumberVar tmpNumber;
Local StringVar strWhole;
Local StringVar strDecimal;
For i := 1 to ubound(Split(Text))
Do(
If IsNumeric(Split(Text)) Then
tmpNumber := ToNumber(Split(Text)));
strWhole := ToWords(Truncate(tmpNumber),0);
tmpNumber := tmpNumber - Truncate(tmpNumber);
If tmpNumber = 0.25 Then
strDecimal := 'and one quarter hour'
Else If tmpNumber = 0.5 Then
strDecimal := 'and one half hour'
Else If tmpNumber = 0.75 Then
strDecimal := 'and three quarter hours';
//add the rest of you rules here for other decimal values
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.