Hi,
def var fieldname as char no-undo.
fieldname = "custname".
for first customer no-lock:
disp custname.
end.
If I want to display the data in the field fieldname (this can be any valid field like custname, custaddr, etc), how do i give the disp statement?
Thanks,
S
You would need to do it dynamically. Something like this should get you started:
DEFINE VARIABLE hB AS HANDLE NO-UNDO.
DEFINE VARIABLE hBf AS HANDLE NO-UNDO.
DEFINE VARIABLE cField AS CHARACTER NO-UNDO.
CREATE BUFFER hB FOR TABLE "Customer".
UPDATE cField.
ASSIGN hBf = hB:BUFFER-FIELD(cField).
hB:FIND-FIRST().
DISPLAY hBf:BUFFER-VALUE.
Of course, you would need to check that the value of cField is a valid field in the table in question..
Kevin
Thanks a lot for your help.
You can also use the static buffer in the loop, so
def var fieldname as char NO-UNDO INITIAL "custname".
def var fieldHandle as handle no-undo.
ASSIGN fieldHandle = BUFFER customer:HANDLE:BUFFER-FIELD(fieldname).
for first customer no-lock:
disp fieldHandle:BUFFER-VALUE.
end.