Program Units and Libraries Question
Question
--------
If I want to create a procedure should I use a library, a
database stored procedure or a local form procedure ?
Answer
------
These different forms of procedures will produce different
performance results depending on what you are trying to
achieve. The database procedure will be invoked on the
server side and will perform all of the processing there.
This may help reduce network traffic, but may overload the
server if many clients are doing this.
Local form and library procedures are quite similar in that
they are both stored and run on the client with any SQL
statements being passed to the server.
The local procedures are typically faster on execution
because they are actually part of the .fmx file, but may use
more memory and have a longer startup time when the .fmx
file is initially invoked.
Library procedures may be better in terms of overall memory
as procedures are only loaded into memory in 4K chunks when
they are required. However, once loaded they are read from
memory.
They have the additional advantage that the library can be
attached to a number of forms and the code within the
library is then available to the forms.
If the code within the library procedures is altered, the
form does not require re-generation. That can be a *big*
advantage.
Question
--------
How does the use of libraries affect the size of the .FMX
file ?
Answer
------
If the library code were included in the FRM, there would
have been no reason to redo them the way we have. The beauty
of the new scheme is that the library modules remain
separate and compiled (into .PLL or .PLX files) so that runform
can bring program units into memory at runtime without adding to
the size of each and every FMX file.
Think of it like a DLL. The only overhead that's added to
the form that attaches a library is that negligible amount
required to remember the name of the libraries on which it
depends.
Question
--------
How should I make a reference to a block in my library
program units ?
Answer
------
At compile time, forms will attempt to resolve all
references to objects. Therefore, if you have code thus :
:BLOCK1.ITEM1 := 'Value';
or
IF
:BLOCK1.ITEM1 = 'Y'
THEN
....
Forms will attempt to resolve the reference to
:BLOCK1.ITEM1. When you are writing library code, there is
no way to resolve these references, since the library could
potentially be attached to *any* form.
Instead you need to use the Copy() and Name_In() builtins
when referencing Forms objects within libraries.
These builtins do not attempt to resolve references at
compile time. So the above code would become :
Copy ('Value','BLOCK1.ITEM1');
or
IF
Name_In ('BLOCK1.ITEM1') = 'Y'
THEN
...
Monday, April 20, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment