Function 无法在progress4gl上使用函数

Function 无法在progress4gl上使用函数,function,progress-4gl,Function,Progress 4gl,我一直在尝试创建一个简单的函数,它将积累一些字符串,然后我将其称为一个函数,它将返回它,但出于某种原因,我得到: 无法理解第1行(198) 这太模糊了,我一直在论坛上寻找比较我的例子,但似乎没关系,有人能给我解释一下我可能做错了什么吗 代码: put unformatted fcustomer(). /*line one*/ function fcustomer returns char(): define variable vgatherer as character. d

我一直在尝试创建一个简单的函数,它将积累一些字符串,然后我将其称为一个函数,它将返回它,但出于某种原因,我得到:

无法理解第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.

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文档以了解详细信息

函数需要在使用前声明,或者向前声明

您可能还需要一个输入参数

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.

再次非常感谢你,蒂姆。我仍然有一个问题,为什么即使在运行过程之后声明它们,过程仍然可以工作?我不能真正回答这个问题-我认为区别在于函数返回数据并对其参数进行严格的类型检查,因此在调用它们之前需要知道它们的调用接口。程序没有这些限制。谢谢汤姆提供了一个简洁的解决方案/解释,Tim首先回答+1