有关FastReport中的自定义函数,请指教。 (各位行行好。救救我吧) (20分)

  • 主题发起人 风雨燕归来
  • 开始时间
调用方法:
frVariables['dxje'] := '金额大写:'+fdm.dicimaltoint (ysk+sxj);
 
to zhanggeye:
数据库字段是float型的。不好改。
to WoDing:
我不能这么调,因为frVariables['dxje']字段是自定义的,我并不知道。
 
数据库字段是float型的。不好改。--------------我想你一定没有去试过吧。
 
to zhanggeye:
这个程序都在用了有一年多了,我怕改出许多毛病来。
 
索性帮忙帮到底。你帮我改改上面那两个函数吧。现在就当有个字段是float型的,我要在fastreport中打印这个字段。需要个自定义函数。我该怎么办?
 
这个模块很多地方有,再改没什么意义。
如果你怕改出许多毛病来,哪么试试我上面说的,问题应可以解决。
 
lich兄:
那个附加库是找着了,可是编译不了。怎么办?
提示:
[Fatal Error] FR7.dpk(35): Required package 'IBO40CRT' not found
 
to lich:
再有就是,我从你给的库文件中把转换的函数取出来,单个用,也不行,怎么办哪。取出来单个用,如下:
const
_ChineseNumeric: array[0..22] of string = (
'零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾', '佰', '仟',
'万', '亿', '兆', '圆', '角', '分', '厘', '点', '负', '整');
function frCurrToBIGNum(Value: Currency): string;
var
sArabic, sIntArabic: string;
sSectionArabic, sSection: string;
i, iDigit, iSection, iPosOfDecimalPoint: integer;
bInZero, bMinus: boolean;
function ConvertStr(const str: string): string;
//将字串反向, 例如: 传入 '1234', 传回 '4321'
var
i: integer;
begin
Result := '';
for i := Length(str)do
wnto 1do
Result := Result + str;
end;

begin
Result := '';
bInZero := True;
sArabic := FloatToStr(Value);
//将数字转成阿拉伯数字字串
if sArabic[1] = '-' then
begin
bMinus := True;
sArabic := Copy(sArabic, 2, 9999);
end
else
bMinus := False;
iPosOfDecimalPoint := Pos('.', sArabic);
//取得小数点的位置
//先处理整数的部分
if iPosOfDecimalPoint = 0 then
sIntArabic := ConvertStr(sArabic)
else
sIntArabic := ConvertStr(Copy(sArabic, 1, iPosOfDecimalPoint - 1));
//从个位数起以每四位数为一小节
for iSection := 0 to ((Length(sIntArabic) - 1) div 4)do
begin
sSectionArabic := Copy(sIntArabic, iSection * 4 + 1, 4);
sSection := '';
for i := 1 to Length(sSectionArabic)do
//以下的 i 控制: 个十百千位四个位数
begin
iDigit := Ord(sSectionArabic) - 48;
if iDigit = 0 then
begin
if (not bInZero) and (i <> 1) then
sSection := _ChineseNumeric[0] + sSection;
bInZero := True;
end
else
begin
case i of
2: sSection := _ChineseNumeric[10] + sSection;
3: sSection := _ChineseNumeric[11] + sSection;
4: sSection := _ChineseNumeric[12] + sSection;
end;
sSection := _ChineseNumeric[iDigit] + sSection;
bInZero := False;
end;
end;

//加上该小节的位数
if Length(sSection) = 0 then
begin
if (Length(Result) > 0) and (Copy(Result, 1, 2) <> _ChineseNumeric[0]) then
Result := _ChineseNumeric[0] + Result;
end
else
begin
case iSection of
0: Result := sSection;
1: Result := sSection + _ChineseNumeric[13] + Result;
2: Result := sSection + _ChineseNumeric[14] + Result;
3: Result := sSection + _ChineseNumeric[15] + Result;
end;
end;
end;

if Length(Result) > 0 then
Result := Result + _ChineseNumeric[16];
if iPosOfDecimalPoint > 0 then
//处理小数部分
begin
for i := iPosOfDecimalPoint + 1 to Length(sArabic)do
begin
iDigit := Ord(sArabic) - 48;
Result := Result + _ChineseNumeric[iDigit];
case i - (iPosOfDecimalPoint + 1) of
0: Result := Result + _ChineseNumeric[17];
1: Result := Result + _ChineseNumeric[18];
2: Result := Result + _ChineseNumeric[19];
end;
end;
end;

//其他例外状况的处理
if Length(Result) = 0 then
Result := _ChineseNumeric[0];
if Copy(Result, 1, 4) = _ChineseNumeric[1] + _ChineseNumeric[10] then
Result := Copy(Result, 3, 254);
if Copy(Result, 1, 2) = _ChineseNumeric[20] then
Result := _ChineseNumeric[0] + Result;
if bMinus then
Result := _ChineseNumeric[21] + Result;
if ((Round(Value * 100)) div 1) mod 10 = 0 then
Result := Result + _ChineseNumeric[22];
end;
procedure TGzb.frReport1UserFunction(const Name: String;
p1, p2,
p3: Variant;
var Val: Variant);
begin
// try
if AnsiCompareText('NumtoRmb', Name) = 0 then
val := frCurrToBIGNum(p1);
// except
// end;
end;

我觉着这原因是由fastreport造成的,有什么办法吗?
 
你先看看这个函数在DELPHI中运行是否正常,正常再用在FASTREPORT
 
是的,在delphi中运行正常,上面所有的转换函数也没有一个不正常的,只有在fastreport2.5中不正常,fastreport2.5也重编译了好几遍了。
有QQ吗,能否当面请教。
 
我的QQ:45758677
 
我明天试试,好我要睡了,88
 
风雨燕归来,
我照你的方法做,没有什么问题啊,
(就是你自己最开始贴出来的代码)
//来自:风雨燕归来, 时间:2004-2-28 23:49:09, ID:2476266
//to lich:
//再有就是,我从你给的库文件中把转换的函数取出来,单个用,也不行,怎么办哪。
//取出来单个用,如下:
用上面后面的代码也没有问题。呵呵
XP+D7+FR2.5
 
经与WoDing讨论,事情又有新发展,把接口函数改为:
if AnsiCompareText('NumtoRmbNew', Name) = 0 then
begin
showmessage(p1);
s := frCurrToBIGNum(p1);
val:=s;
end;
在打开报表时showmessage(p1)的结果是:
[dataset."xxx"]
即只显示的是这个字串,而不是具体值,这是怎么回事,还该如何?
 
郁闷,再顶一下!
 
这是我很久以前写的,看下吧也许有帮助{rx:接收的意思 }
function Tfrmmain.big(rxchar:char):string;
begin
case rxchar of
'0':big:='零';
'1':big:='壹';
'2':big:='贰';
'3':big:='叁' ;
'4':big:='肆';
'5':big:='伍';
'6':big:='陆';
'7':big:='柒';
'8':big:='捌';
'9':big:='玖';
end;
end;
function Tfrmmain.smalltobig(rxcurr:currency):string;
var
okay:string;
temp:string;
len:integer;
position:integer;
low:integer;
i:integer;
begin
temp:=currtostr(rxcurr);
len:=length(temp);
position:=pos('.',temp);
low:=len-position;
if position=0 then
position:=len+1 ;
if low=len then
low:=0;
i:=1;
{取整数部分}
while i<positiondo
begin
case position-i of
4,8:eek:kay:=okay+self.big(temp)+'仟';
3,7:eek:kay:=okay+self.big(temp)+'佰';
2,6:eek:kay:=okay+self.big(temp)+'拾';
5:eek:kay:=okay+self.big(temp)+'萬';
1:eek:kay:=okay+self.big(temp)+'元';
end;
inc(i);
end;
position:=pos('.',temp);
{取小数部分}
if position>0 then
begin
if position+1<=len then
okay:=okay+self.big(temp[position+1])+'角'
else
okay:=okay+self.big(temp[position+1])+'零角';
if position+2<=len then
okay:=okay+self.big(temp[position+2])+'分'
else
okay:=okay+self.big(temp[position+2])+'零分';
end;
smalltobig:=okay;
end;
 
ezero,
你错了,上面写出来的所有函数都正确,但就是不能用到fastreport中
 
这是一个在fastreport中自定义一个金额小写转大写的问题,如下:
(你别看了简单就跑,关键是如何有fastreport连接)
----------------------------------------------------
哈哈,说的就是我呀!
 
to 风雨燕归来:
这里错了:
...
while l2>0do
begin
s3:=copy(s1,l3*2+1,2)+s3;
//如果 rmb 含小数点,则 dxs 包含 '.'
//strtoint 是不允许含小数点的,因此出错!
s3:=copy(s2,strtoint(copy(dxs,l2,1))*2+1,2)+s3;
//<===错
l2:=l2-1;
l3:=l3+1;
end;
...
 
kaida, 不知你认真看了题目没有,还有别人的回复?
 
顶部