'Is it possible to give scope defined value for handle? - PROGRESS 4GL
Is it possible to give something like below?
&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.
Solution 1:[1]
As Tom says, you just create the buffer handle dynamically, since you currently just want the column labels:
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.
Also do not forget, if you create it, you generally need to delete it.
https://abldojo.services.progress.com/?shareId=624ebdd93fb02369b2543eaa
Solution 2:[2]
Doing so would be meaningless because the actual value of the handle is not known until runtime.
But you don't need to use pre-processors to abstract that table name. You could make it totally dynamic at runtime like this:
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stefan Drissen |
| Solution 2 | Tom Bascom |
