我一直在尝试创建一个简单的函数来累积一些字符串然后我会称之为它会返回它,但出于某种原因我得到了:
Could not understand line 1 (198)
哪个太模糊了,我一直在论坛上寻找比较我的例子,但似乎没事,愿有人向我提供我可能做错的解释吗?
代码:
put unformatted fcustomer(). /*line one*/
function fcustomer returns char():
define variable vgatherer as character.
define variable i as integer no-undo.
do i = 1 to 10:
assign vgatherer = vgatherer + "thing(s)".
end.
return vgatherer.
end function.
答案 0 :(得分:4)
需要在使用前声明函数或进行前向声明。
您可能还想要一个输入参数。
function fcustomer returns character ( input p1 as character ) forward.
put unformatted fcustomer( "some text" ). /*line one*/
function fcustomer returns character ( input p1 as character ):
define variable vgatherer as character.
define variable i as integer no-undo.
do i = 1 to 10:
assign vgatherer = vgatherer + p1.
end.
return vgatherer.
end function.
答案 1 :(得分:3)
ABL使用单通道编译器,因此必须在它们被使用之前声明函数。如果您更改代码,那么它将起作用:
function fcustomer returns char():
define variable vgatherer as character.
define variable i as integer no-undo.
do i = 1 to 10:
assign vgatherer = vgatherer + "thing(s)".
end.
return vgatherer.
end function.
put unformatted fcustomer(). /*line one*/
您还可以使用FORWARD短语转发定义函数。有关详细信息,请查看ABL文档。