// 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;