是否可以为句柄提供范围定义值? - 进步 4GL

Is it possible to give scope defined value for handle? - PROGRESS 4GL

是否可以提供类似下面的内容?

&SCOPED-DEFINE Tablename "Customer".

DEFINE VARIABLE hFieldBufferHandle  AS HANDLE NO-UNDO.
DEFINE VARIABLE icount AS INTEGER NO-UNDO.

 hFieldBufferHandle = BUFFER Customer:handle.
 /* hFieldBufferHandle = BUFFER {&Tablename}:handle.     /*What I need..will be helpful if it has to be defined inside the loop*/ */

 do icount = 1 to hFieldBufferHandle:NUM-FIELDS:
    DISP buffer Customer:buffer-field (icount):label. 
 end.

这样做是没有意义的,因为句柄的实际值直到运行时才知道。

但是您不需要使用 pre-processors 来抽象那个 table 名称。您可以像这样在运行时使其完全动态化:

define variable b as handle    no-undo.
define variable t as character no-undo.
define variable f as character no-undo.

t = "customer".  /* these could just as easily be parameters to a function/procedure/method */
f = "name".

create buffer b for table t no-error.

b:find-first( "", no-lock ) no-error.

message b:buffer-field( f ):buffer-value.

正如 Tom 所说,您只需 create 动态处理缓冲区,因为您目前只需要列标签:

def var hb as handle no-undo.
def var ic as int    no-undo.

create buffer hb for table 'customer'.

do ic = 1 to hb:num-fields:
   message hb:buffer-field( ic ):label.
end.

finally:
   delete object hb no-error.
end finally.

另外别忘了,如果创建了,一般都需要删除。

https://abldojo.services.progress.com/?shareId=624ebdd93fb02369b2543eaa