How i can use recursive methods ??

jhdz

New Member
Hi, I've been searching like a month and I didn't found anything useful about recursive methods in progress I would want to know if someone here could advise me.

Can I use recursive methods with Progress???
If yes, how would I could implement them.
 
Hi, I've been searching like a month and I didn't found anything useful about recursive methods in progress I would want to know if someone here could advise me.

Can I use recursive methods with Progress???
If yes, how would I could implement them.
Could you be more specific about that ? Because I can't understand what's your problem...

It is possible to use recursive methods, as in most languages I think. If you mean something like that :
Code:
RUN myProc(1).

PROCEDURE myProc :
  DEF INPUT PARAMETER p1 AS INT.

  IF p1 < 10
  THEN DO :
    DISP p1.
    RUN myProc(p1 + 1).
  END.
END PROCEDURE.

it is possible !
 
Could you be more specific about that ? Because I can't understand what's your problem...

It is possible to use recursive methods, as in most languages I think. If you mean something like that :
Code:
RUN myProc(1).
 
PROCEDURE myProc :
  DEF INPUT PARAMETER p1 AS INT.
 
  IF p1 < 10
  THEN DO :
    DISP p1.
    RUN myProc(p1 + 1).
  END.
END PROCEDURE.

it is possible !

Thanks for the answer,

And about the specific question that I have is this;

For example, I have a method and a Table0, and I want to find a record in the mentioned table, so I do a FIND statement, I get my record, which will be stored in a buffer, then I will call the same method again to do another find, so on "n" times, but for each time I call the method, the Table0 buffer will be overwritten and I will lost the previous searches.

What I'm wondering with this, is if there's someway to stop the buffer from being overwritte.

I'm thinking that I could define a global temp-table for my procedure and store each of my results in that table for each time my method gets called, and at the end of my procedure, just clear that temp-table.
 
Isn't there a way to create a query that will retrieve all the results you need, so you will be able to browse it as many times you want ?
 
Code:
procedure r:

  define input parameter c as integer no-undo.

  define buffer customer for customer.

  find first customer no-lock where custNum > c no-error.

  if not available( customer ) or ( c > 10 ) then
    return.
   else
    run r ( customer.custNum ).

  display customer.custNum customer.name with no-box no-labels.

  return.

end.

run r ( 0 ).
 
Back
Top