[Reprint] added the custom function in fastreport report to convert the lower-case amount to upper-case

Source: Internet
Author: User

// The following functions can convert the lowercase amount less than 100,000 million yuan to uppercase
// Author Fang Xiaoqing (inrm@263.net)
Function ntoc (N0: Real): widestring; stdcall;
Function IIF (B: Boolean; S1, S2: string): string;
Begin // This function is a system internal function in VFP and VB.
If B then IIF: = S1 else IIF: = S2;
End;
Const c = '0, 1, 2, 3, 3, 3, 3, 3, 3, 4, 3, 4, 4, 4, 4, 4, 3, 4, 4, 3, 4, 3 ';
VaR L, I, n, code: integer;
Z: Boolean;
S, St, ST1: string;
Begin
S: = formatfloat ('0. 00', N0 );
L: = length (s );
Z: = N0 <1;
For I: = 1 to L-3 do
Begin
Val (copy (S, L-i-2, 1), N, Code );
St: = IIF (n = 0) and (z or (I = 9) or (I = 5) or (I = 1), '', copy (C, N * 2 + 1, 2 ))
+ IIF (n = 0) and (I <> 9) and (I <> 5) and (I <> 1) or Z and (I = 1 )), '', copy (C, (I + 13) * 2-1, 2 ))
+ St;
Z: = (n = 0 );
End;
Z: = false;
For I: = 1 to 2 do
Begin
Val (copy (S, L-I + 1, 1), N, Code );
ST1: = IIF (n = 0) and (I = 1) or (I = 2) and (z or (N0 <1 ))),'', copy (C, N * 2 + 1, 2 ))
+ IIF (n> 0), copy (C, (I + 11) * 2-1, 2), IIF (I = 2) or Z ,'', 'Integral '))
+ ST1;
Z: = (n = 0 );
End;
For I: = 1 to length (ST) do if copy (St, I, 4) = 'billionaire then delete (St, I + );
Ntoc: = IIF (N0 = 0, '0', ST + ST1 );
End;

////////////////////////

Function tform2.frxpt1userfunction (const methodname: string;
VaR Params: variant): variant;
Begin
If uppercase (methodname) = uppercase ('f2c ') then
Result: = f2c (Params [0]);
End;

Procedure tform2.formcreate (Sender: tobject );
Begin
Frxpt1.addfunction ('function f2c (N0: Real): string; ', 'myfunction', 'function that converts lowercase values to uppercase ');
End;

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.