PowerBuilder Reference Guide
This document provides some more detailed information about the objects and links that are stored in the Analysis Service. Other technical information may also be available.
- Object Types
- Link Types
- Dynamic Links found by the analyzer (inference engine)
- Calling PB system functions
Object Types
Objects detected by the analyzer are summarized in the following table:PB Program/Analysis | . | ||
PB Library | - PB Program | ||
PB Window | - PB PBL | ||
PB User Object | - PB PBL | ||
PB DataStore | - PB PBL | ||
PB DataWindow | - PB PBL | ||
PB Structure (Global) | - PB PBL | ||
PB Menu | - PB PBL | ||
PB Application | - PB PBL | ||
PB Function Global | - PB PBL | ||
PB Control | - PB Window - PB User Object - PB Menu (item menu) | ||
PB Function | - PB Window - PB UserObject - PB Menu - PB Application - PB DataStore | ||
PB Event | - PB Window - PB UserObject - PB Menu - PB Application - PB DataStore - PB Control | ||
PB RPC Function | - PB UserObject (transaction) | ||
PB Declare Procedure | - PB Window - PB UserObject - PB Menu - PB Application - PB DataStore - PB Event - PB Function | ||
PB Declare Cursor | - PB Window - PB UserObject - PB Menu - PB Application - PB DataStore - PB Event - PB Function | ||
PB External Function | - PB Window - PB UserObject - PB Menu - PB Application - PB DataStore | ||
Variable (various types of variables exist, see columns to the right) | Member Variable | - | |
Instance Variable | - PB Window - PB Application - PB Menu | ||
Shared Variable | - PB Window - PB Application - PB Menu | ||
Global Variable | - PB Application | ||
Variable | - PB Structure (Global) | ||
PB8 Workspace | Hierarchy: Analysis, Workspace, Target, PBL. | ||
PB Proxy Object | - | ||
PB Target | - |
In addition, the following information about PowerBuilder objects is stored in the Analysis Service:
- For PB Window objects the following window types are stored: Child, Main, MDI Frame, MDI Frame with microhelp, Popup, Response
- For PB Events, information about whether the Event is "Inherit Extend" and "Inherit Override". In addition, there is a distinction made between a User Event and a Standard Event.
- The name of the system class for all objects as well as controls. This enables users to find out if the control is "button" for example.
- For global variables and instances information about the variable type is available. This can be very useful for system types.
Link Types
Links created by the analyzer are summarized in the following table:
Client/Client links
Link Type | When is this type of link created? | |
Access | - Read | Caller: Code object - fct, Event... Callee: Variable (instance, shared or global) Eg.: if a = 2 then...endif |
- Write | Caller: Code object - fct, Event... Callee: Variable (instance, shared or global) Eg.: a = 2 | |
- Exec | Caller: Code objetc - fct, Event... Callee: Fct, Evt, Global Fct Eg.: a.f() Please note that when a window is opened (open(w1) for example), there will be an Access Read on w1 | |
- Member | Caller: Code object - fct, Event... Callee: Variable (instance, shared or global) Eg.: a.b = 2 (member on a and write on b) | |
- Array | Caller: Code object - fct, Event... Callee: Variable (instance, shared or global) Eg.: A[5].b = 2 (array on a and write on b) | |
Prototype | - When declaring an external function in an object and the function in a DLL that implements it. | |
Use - Select - Insert - Delete - Update | - When the property of an object references a datawindow. | |
Inherit | - When there is inheritance between controls, user objects, menus, and windows. In the following example, the window "w_gui_authors2" inherits from "w_gui_authors":
| |
Mention | - During the creation of a class. The callee is always a class: (W,App,UO,M,Struct) Eg.: a = Create UO | |
Rely On | - This link is displayed when there is a link between a variable and a type. When the link is on a local type variable, the link will then be escalated internally. Eg.: w1 var |
Client/Server links
Type of Link | Where is this type of link created? | When is this type of link created? |
Use(): - Select - Insert - Delete - Update | Embedded SQL | - |
Datawindow | - Link between Datawindow and table (or view) with PB SELECT | |
- Link between Datawindow and table (or view) with SQL Select | ||
Dynamic SQL | - Link found by the inference engine | |
Prototype | RPC Declare Procedure Declare Cursor | - Link between the logical object corresponding to the logical name in PB and the server object. |
Call | Datawindow | - Link between Datawindow and Procedure (or sub object in Oracle) |
Dynamic SQL | - Link found by the inference engine for server functions or procedures | |
Use | Dynamic SQL | - in dynamic SQL character strings. |
Note about Dynamic SQL links found by the inference engine
- When the inference engine perceives that a string is an SQL string, then this string will not be passed through the Grep search.
Note about C/S links found by the inference engine
- When the inference engine finds a C/S link, the analyzer will place the link at the level of the object that contains the string and not at the level of the exec. There is various information about these links:
STRING: Concatenated SQL string
CONCATENATION: Compete, partial or not at all. This will enable you to find out whether the inference engine has managed to concatenate the SQL string.
EXECUTED IN: This is the qualified name of the object that contains the SQL exe.
STRING BUILD IN OBJECTS: a list of qualified names of objects that have participated in the construction of the SQL string. The number of objects is limited to 10. For example:
- STRING = DELETE FROM authors WHERE authors.au_lname = (SELECT discounts.stor_id FROM discounts WHERE discounts.stor_id = '2')
- CONCATENATION = COMPLETE
- EXECUTED IN = w1.fct3(Line1,Col51)
- STRING BUILT IN OBJECTS = typelnk.open ; w1.fct1
Note about links found by the inference engine for virtual functions
- For virtual functions, the link is found on the function call. For the link, information will be added about the location of the "create". E.g.:
- STATEMENT "CREATE" IN OBJECT(S) : w_dessin.wof_aire(Line=4,Col=2)
Information about other C/C links found by the inference engine (TiggerEVent, Open etc...)
- There is one link at the string level. The inference engine will gather and store the following information:
- EXECUTED IN OBJECT - the location of the TriggerEVent E.g.: EXECUTED IN OBJECT : w_macro.of_f
Dynamic Links found by the analyzer (inference engine)
Dependencies between variables
This algorithm enables you to locate dependencies in variables, function parameters, function returns, and instance variables. The algorithm is divided into two phases:
1st phase: Dependencies between variables in a function: microscopic analysis
For example :
f(int parama) string a,b a = "event1" if(param = 1) b = a else a = "event2" end if TriggerEvent(a) TriggerEvent(b)end function
In the example above:
- a is dependent on "event1" and "event2"
- b is dependent on a which is only dependent on "event1"
- During TriggerEvent (a) there will be a link between f and "event1" and one between "event2" and for TriggerEvent(b) there will be a link between f and "event1".
2nd phase: Dependencies between variables, functions, and parameters: macroscopic analysis
For example, there are two functions:
f (string param) TriggerEvent(param)end function---------------------g() string a,b a = "event1" if(param = 1) b = a else a = "event2" end if f(a) f(b)end function
In the example above:
In g there is a:
- a is dependent on "event1" and on "event2"
- b is dependent on a which is dependent on "event1"
- the first parameter of f is dependent on a
- the first parameter of f is dependent on b
In f there is a:
- param is triggered
During TriggerEvent(Param) there is a link between f and "event1" and one between f and "event2."
Control flow taken into account
Up until now we have mainly been dealing with dependencies between variables. If the algorithm does not take into account the control flow (condition, loop, etc.) it would be very quickly limited.
For example:
f(int param) string a,b a = "event1" if(param = 2) a = "event2" TriggerEvent(a) //Trig1 b =a end if b = "event3" TriggerEvent(a) // Trig2 TriggerEvent(b) // Trig3end function
In the example above, three triggers are evident (trig1, trig2, trig3). If the control flow is not taken into account, the following would be true:
- a is dependent on "event1"
- a is dependent on "event2"
- b is dependent on a => b is dependent on "event1", "event2" and "event3"
- * For Trig1 there would be a link between f and "event1" and between f and "event2".
- * For Trig2 there would be a link between f and "event1" and between f and "event2".
- * For Trig3 there would be a link between f and "event1", between f and "event2" and between f and "event3".
If the algorithm takes the control flow into account, the following would be true: for instructions such as if, the algorithm does not take the test value into account. For example, it does not differentiate between if(0) and if(1). However, it assumes that value taken from the if block is valid in the rest of the program.
In the example above, for Trig2 there are two possible values: event1 and event2, because it is possible to either enter the condition or not to enter it: if the param is not 2, the value of a would be event1 during Trig2 and if the param = 2, the value of a would be event2 during Trig2. It is true, however, that the value of "a" could be event1 or event2 in Trig2 (f - event1 and f - event2).
The results would thus be:
- * For Trig1 there would be a link between f and event2 (and NOT with event1 because the assignment a = "event2" hides the assignment a = "event1").
- * For Trig2 the value of "a" could be event1 or event2. There is, therefore, a link between f and event1 and between f and event2.
- * For Trig 3 the value of "b" will only be "event3" because the assignment b = "event3" hides the value of "event2".
Algorithm Limitations
- It cannot handle tables:
For example:
(int parama) string a[2] a[1] = "event1" if(param = 1) a[2] = "event2" end ifTriggerEvent(a[1])end function
Here, PB Analyzer will find two links: f with event1 and event2.
- Occasionally, the concatenation of strings can become too large. The inference engine will continue to search the stings, but it will not concatenate them.
- If a sting is constructed with a loop (for, while etc.) the result will not be correct.
- Break, continue and goto are not taken into account by the inference engine.
- Functions such as Trim and Upper etc. are not taken into account.
When is the inference engine used?
C/S links with the following instructions:
- Execute immediate
- PREPARE instructions that take a string
- When a datawindow calls the SetSQLSelect function
- When a datawindow calls the Syntaxfromsql function
C/C links
- Virtual functions: the inference engine will search for the values of the variable that qualify the function. Depending on the value, the analyzer will trace a link to the correct virtual function.
- During the instruction, CREATE USING string, the inference engine will search for the value of the string.
- For dw1dataobject ) string, the string corresponds to a datawindow.
- In the TriggerEvent(String) function, the inference engine will search for the value of the string. The analyzer will then trace links to the Events in question.
- Openwithparm(windowvar,parameter,string). The inference engine will search for the value of the string. The analyzer will then trace links to the Windows in question.
- OpenTab(uovariable,string,index). The inference engine will search for the value of the string. The analyzer will then trace links to the User Objects in question.
- OpenTabWithparm(uovariable,parameter,string,index). The inference engine will search for the value of the string. The analyzer will then trace links to the User Objects in question.
- OpenUserObject(uovariable,string). The inference engine will search for the value of the string. The analyzer will then trace links to the User Objects in question.
- OpenUserObjectWithparm(uovariable,parameter,string). The inference engine will search for the value of the string. The analyzer will then trace links to the User Objects in question.
How does the analyzer create links found by the inference engine?
C/S links:
- The link can be found at the level of the string that contains the name of the server object. However, there is no link at the exec level in order to avoid some points of contention.
- For calls to virtual functions, the link can be found on the function call.
- For others, e.g.: TriggerEvent, there are two links - one at the string level and one on the TriggerEvent.
Virtual Functions
If the instance creation and the virtual function's call are found in the same script (function or event), PB Analyzer will find the correct virtual function.
Management of a function's dynamic calls
If the instance creation and the dynamic function's call are found in the same script (function or event), PB Analyzer will find the correct link.
For example:
f(string typeobj) drawing objdrawing if(typeobj= "cercle" then objdrawing = create cercle; else objdrawing = create rectangle end ifobjdrawing.dynamic draw()
Calling PB system functions
The PB Analyzer recognizes certain functions and applies the algorithm to their parameters.
Recognized functions
- TriggerEvent (or PostEvent): the first parameter is the most interesting. It corresponds to the name of the event that you want to trigger. This parameter is either a string or an enumerator.
- Open: opens a window without knowing the window type.
- OpenTab: the second parameter is interesting as it is a character string which corresponds to the name of the UO (User Object).
- OpenTabWithParam: the third parameter is interesting as it is a character string which corresponds to the name of the UO.
- OpenUserObject: opens a user object without knowing its type. The second parameter is a string which corresponds to the name of the UO.
- OpenUserObjectWithParam: the third parameter is interesting as it is a character string which corresponds to the name of the UO.
- OpenWithParam: opens a window with parameters. The second parameter is a string which corresponds to the name of the window.
Create Using String
For example:
f(int param) string typeobj,typeobj1 drawing drawingbase,drawingbase1 Choose Case param case 0 typeobj = "cercle" case 1 typeobj = "rectangle" end choose typeobj1 = typeobj drawingbase = Create using typeobj1 drawingbase.Draw() (1) drawingbase1 = drawingbase if(param2 = 2) drawingbase1 = Create using "rectangle" drawingbase1.draw() (2) else drawingbase1.draw() (3) end if end function
A list of links found by PBAnalyzer for the calls of the function Draw (1)(2) et (3) (see above):
(1) : f->cercle.draw() f->rectangle.Draw()
(2) : f->rectangle.Draw()
(3) : f->cercle.draw() f->rectangle.Draw()
Dynamic modification of the dataobject property of a control datawindow or a datastore
For example:
string var = "dw_1"dw1.DataObject = var
In this case, PB Analyzer will create:
- A link between the event which contains the character string of the Datawindow and the Datawindow itself.
- A link between the Datawindow control and the Datawindow itself.