Any tricks for assigning buffer tables?

Garyk

New Member
I have (2) identical tables (definition).
Ex: cust and hist_cust.

I want to write (1) browse routine and just set the buffer.

define buffer tmp_cust for cust/hist_cust.
I know that I could use an include file and compile it twice, However
I am looking for a more clever method.

something like
if input_var then tmp_cust:buffer = cust else tmp_cust:buffer =
hist_cust.

Thanks,
Gary...
 
How about this:
Code:
def var mybuffer as handle no-undo.
def var myquery as handle no-undo.

if input_var
then create buffer mybuffer for table cust
    buffer-name "tmp_cust".
else create buffer mybuffer for table cust_hist
    buffer-name "tmp_cust".

create query myquery.

myquery:set-buffers(mybuffer).
myquery:query-prepare("for each tmp_cust").

myquery:query-open.
myquery:get-next().

while not myquery:query-off-end:
    /* .... */
    myquery:get-next().
end.

delete object myquery no-error.
delete object mybuffer no-error.
 

Garyk

New Member
I played around with this method and I don't like what I see. Once you go into this mode, the program becomes very cryptic and unreadable. I was hoping to just reassign a buffer.

I will stick with the "old fashioned" method, because code maintenance is very important to me.

Thanks,
Gary...
 
Umm, I agree that in this case you are better of sticking with something that's simple.

Dynamic buffers are better suited to developing more generic routines that work for any table or combine a number of options and then select the appropriate index/table-joins dynamically.

Sometimes it's best to not be too clever, and think of the poor maintenance programmer coming along behind you. ;p
 
Top