4

here is my current code

def var hbTT as handle.

for each Cust:
  hbTT:buffer-create().
  assign
    hbTT::Name    = Cust.Name
    hbTT::address = Cust.Address.
end.

now what I want to do is to loop through hbtt. How can I do that?

I tried

for each hbTT:
  /* Do something */
end.

the error I get is

unknown or ambiguous table hbTT. (725)

thank you

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
BobNoobGuy
  • 1,551
  • 2
  • 30
  • 62

1 Answers1

7

You won't be able to do a loop that way, as for each requires a static name. Instead, try this:

DEFINE VARIABLE hQuery AS HANDLE      NO-UNDO.

create query hQuery.
hQuery:set-buffers(hbtt).
hquery:query-prepare('for each tt'). /* <-- Where tt is the original buffer name */
hquery:query-open().

hquery:get-first().
do while not hquery:query-off-end:
    disp hbtt::name hbtt::address .
    hquery:get-next().
end.
bupereira
  • 1,463
  • 8
  • 13