Re: Which is Faster ? CALL or RUN PROGRAM
Posted in 1996
Dennis J Pimple wrote: > Appala.Naidu@KSNCABP03.SNSGATE.sprint.com wrote: > > Hi, > > > > I have a program and I would like to invoke it as a CALL > > function. For that I have to make a considerable change in my > > Code. I can invoke it as a RUN PROGRAM without making any changes. > > For efficiency and Response Purposes, which one is better? > > Calling as a Function or Calling as a RUN PROGRAM and for what reasons. > > CALL will always be faster than RUN, because RUN will open the database > again, and memory has to be allocated for the new process(es). I think > the only reasons to use RUN instead of CALL would be if you wanted to run > a seperate process without waiting for it to finish ("RUN ... WITHOUT > WAITING), or because the parent program is getting so big you don't want > to increase its size by adding the new code to it. That's exactly right. It is nice to keep programs as small as possible, particularly from a maintenance point of view. People often 'chain' programs together using the RUN command to reduce the resources used by the 'average' user, who only uses one 'screen' all day. This then allows the minority of users to chain to other programs as they need. This of course introduces another problem, and that is the licensing issue. Every chained program is effectivly another user on the license. The method we have often employed is to 'swap out' programs using the EXIT PROGRAM command. This of course requires a controlling program to be sitting there controlling where you go next and making sure you get back to where you came from. This also requires some very tight programming in the calling program to make sure you do get back to exactly where you 'chained' from. We have for example employed this in one of our comercial packages; 'zenmenu'. This is a menu system written in 4GL, which 'swaps' itself out when an option is selected to call another program. Again, Dennis's comments refer here in terms of performance. Using EXIT PROGRAM will give you worse performance than either CALL or RUN. But it does address some other issues. Hope this helps, -- Mark. +-------------------------------------------------------------------------+ |Mark D. Stock - The West Solutions Group http://www.west.co.za | | | |mailto:marks@west.co.za +------------------------------------------------+ |Tel: +27 11 803 2151 |If it doesn't work... force it! | |Fax: +27 11 803 2189 |If it breaks... it needed replacing anyway! | |Cell: +27 83 250 2325 |Well, that's how I code anyway! | +------------------------+------------------------------------------------+