Getting table buffer-handle without a create buffer

Posted by DenDuze on 16-Aug-2016 07:33

Is there some way to get the table:buffer-handle without the use of a create buffer?

I want to call some function/procedure to run some query on whatever table-name I provide to that function/procedure.
For that I use the handle to the buffer of that table.
The problem is that I need to perform some case to assign the correct buffer-handle to my variable (so always need to add some when if i call this with a new table
I know I can handle this with a create buffer <for my table> and use that BUT can't this be done some other way?
Isn't there some VST that holds the handles to the tables? (tried _File but no go).

So can I replace:
case table-name:
    when "customer"   then assign hbuffer = buffer customer:handle.
    when "language"   then assign hbuffer = buffer language:handle.
    when "country"      then assign hbuffer = buffer country:handle.
    .....

end case.

With something generic but without need of create buffer hbuffer for table tablename.

Regards

Didier

All Replies

Posted by Keith Sudbury on 16-Aug-2016 07:51

How about this.....

 CREATE BUFFER hBuffer FOR TABLE table-name.

No need for the case as long as the value of the table-name variable matches an actual _File-Name. 

Posted by DenDuze on 16-Aug-2016 08:05

Thanks but I mentioned that I know about the create buffer but would like some alternative withoput create and delete hbuffer statements

Posted by Keith Sudbury on 16-Aug-2016 08:10

Your original post was about getting rid of the case and the hard coding... this approach does that.

Why the hangup about not wanting to issue a single create/delete statement?

Posted by Fernando Souza on 16-Aug-2016 08:11

No, there isn't any other way. CREATE BUFFER is the "generic" way.

Posted by DenDuze on 16-Aug-2016 08:58

Because I don't see the need to create a buffer and the needed deletion of that buffer.

Creating a new buffer is just some (maybe minor) overhead that I wanted to prevent.

If the create is the only way I will use that but I was just wondering if someone had some clever idea to prevent that.

If there isn't some (like fernando also says - and I was afraid of) then I need to use that.

Thanks

Posted by Keith Sudbury on 16-Aug-2016 09:33

Creating a buffer is an extremely minor event. Very similar to defining/assigning a variable.

Even if you plan on creating/deleting the buffer many times inside a loop you aren't likely to notice a real world difference in performance. A simple test on my dev box for 10,000 buffer creates/deletes took 42ms.

Posted by DenDuze on 16-Aug-2016 09:47

Hi Keith,

Thanks for the testing and explenation!

I have no problem with using that (i have done it many times in the past) but I was just curious if there was another way to accomplish this without the need of a create buffer (all things created must be deleted so you have a possible leak and if it can be otherwise you can prevent that posible leak. Not only now by me but also after changes by others!)

Np if this is the only way then I have no problem of using it!

This thread is closed