uf_destroy() to POST objects' Destroy

Share this topic:



Link to this posting

Postby Ursego » 16 Apr 2013, 11:50

The function uf_destroy() is extremely simple (it just DESTROYs the object, sent to it - nothing else!) but very useful - it enables to POST object's destroying. Use this function if you have an object, created locally in a function, and many RETURNs from that function. Call uf_destroy() with POST, and only once - just after you CREATE the object. This approach exempts you from writing DESTROY many times, before each RETURN. In the next example (treating a local DataStore), instead of

Code: Select all
lds = create lds

[fragment 1]
if ... then
   destroy lds
   return
end if

[fragment 2]
if ... then
   destroy lds
   return
end if

destroy lds

you will write this way:

Code: Select all
lds = create lds
gn_util.post uf_destroy(lds)

[fragment 1]
if ... then return

[fragment 2]
if ... then return

So, here is the code of uf_destroy() (it can be added to the utilities NVO of your application or wherever):

Code: Select all
/**********************************************************************************************************************
Acc:   public
-----------------------------------------------------------------------------------------------------------------------
Dscr:   Enables to POST object's destroying. Example of use: http://forum.powerbuilder.us/viewtopic.php?f=4&t=90
-----------------------------------------------------------------------------------------------------------------------
Arg:   apo (PowerObject)
**********************************************************************************************************************/
if not IsValid(apo) then
   return
end if

destroy apo

return
User avatar
Ursego
Site Admin
 
Posts: 112
Joined: 19 Feb 2013, 20:33

Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 2 guests


uf_destroy() to POST objects' Destroy

Share this topic:


If you think that this site is not too bad, please LIKE it in Facebook. Thanks!





cron
free counters

eXTReMe Tracker