• No results found

MENUS; USER OBJECTS; WINDOWS

6. Give an example of how you would use inheritance in your project?

I used the base (class) library to inherit it for all my application objects in order to increase the development process.

A standard company logon window that requires minimal changes.

7. How can you customize a descendant?

We can change the values of attributes and variables, extend/override the script, add controls, reference an ancestor’s functions, events, or structures, or declare variables, events, functions and structures for the descendant.

8. Can you delete a MenuItem in the descendant menu if it was created in the ancestor one?

We cannot delete a MenuItem in the descendant menu if it was created in the ancestor one but we can make it disabled and invisible.

9. What happens when you change the ancestor?

The changes apply to the all descendants.

10. What can you do with ancestor scripts?

We can Override or Extend the ancestor script at the descendant level. We can also call it from the descendant script.

11. Let’s say, you developed a window w_customers. After some time you developed a base ancestor window w_base_win and want to use all functionality that you put in this ancestor in your w_customers window. How can you do this?

By exporting w_customers, editing the exported file and importing it back.

12. How many levels of inheritance do you usually use?

I try not to use more than 3 levels, because my opinion is that each extra level decreases the performance and makes the code more difficult to read, but Powersoft says that with PB5, if we use the right structure of inheritance, it will increase the performance.

13. How can you call an ancestor script from a descendant object? (see pronouns)

There is CALL command that calls an ancestor script from a script for a descendant object. For example, CALL w_emp :: Open

CALL w_emp.cb_close :: Clicked

We can also use the word SUPER to refer to the immediate ancestor (parent). For example, to call the parent’s Clicked script: CALL SUPPER :: CLICKED

You can name directly the ancestor in the call or use the reserved word SUPER Call Super :: Clicked

14. How can you override ancestor script at descendent level with no script in descendant?

Put comments //

15. How can you customise a Descendant?

Override or extend script, add controls, change value of attributes and variables.

16. How can you change an object’s ancestor without recording it?

Export the descendant, edit it (changing the name of the ancestor) and import it back.

17. Can you inherit a DataWindow?

We cannot do it directly, but we can create a standard UserObject of DataWindow type (which can be inherited) and use it instead of DataWindow controls. You use the same method when you need to inherit any control.

18.

What is the difference between inheriting and copying an object?

When you change the ancestor object the changes are reflected in all the descendants.

When copying, you have to manually make changes. In copying you can delete or add the same control from the window. In descendant you cannot delete control just can make it nonvisible.

P.S. Changes to an attribute in the ancestor affect only the descendant on which that attribute has not been changed. WHEN YOU CHANGE ATTRIBUTE IN AN INHERITED CONTROL,

YOU BREAK THE CONNECTION TO THE PARENT FOR THAT ATTRIBUTE ONLY. To re-establish the link to the parent you can click on the control and choose Edit/Reset Attribute 19. How can you execute ancestor script from the descendant?

CALL calls an ancestor script from a script for a descendent object. Call Super::Clicked (execute the script on the clicked event in ancestor). You can call scripts for events in an ancestor of the user object, menu, or window. You can also call scripts for events for controls in an ancestor of the user object or window. The following statement calls a script for an event in an ancestor window.

CALL w_emp::Open

The following statement calls a script for an event in a control in an ancestor window.

CALL w_emp`cb_close::Clicked

In some circumstances, you can use the Super reserved word when ancestor object is the descendant object's immediate ancestor.

20. How you can call function in ancestor from descendant?

w_parent::functionname(arg)

If the descendant has a function with the same name Supper:: wf_functionname( )

You can call function from the descendant: just put the function name and give it the arguments.

The only exception is if another function in the descendant window has been named exactly the same as the ancestor window function. In this case calling this name would call the descendant window’s function, not the ancestor. The solution to this problem depends on where you are making the call from. If you are calling the ancestor function from the window script (open or other event) you can:

w_parent::functionname(arg)

If you are calling the function from within a control or user object event, you must create a new descendant window function that does nothing but make a qualified call to the ancestor window function (as previously). Then you call the new descendant window function from within the control or user object.

21. You are working with inherited windows, and your application does not work or produces ambiguous errors. You are tracing the program though the DEBUGGER, and still - nothing. What can you do next?

22. Which of the following can be inherited? (pick all) -window -Y

23. You can create, delete and change controls in a descendent? False

24. A descendant can only have one ancestor? False 25. What is SUPER keyword and how it is used?

SUPER is a keyword used to make a reference to an object without having to specify its name:

When you write a script for a descendant object or control, you can call scripts written for any ancestor. You can directly name the ancestor in the call, or you can use the reserved word Super to refer to the immediate ancestor (parent). If you are calling an ancestor function, you only need to use Super if the descendant has a function with the same name and the same arguments as the ancestor function. Otherwise, you would simply call the function with no qualifiers.You can only use Super in an event or function associated with a direct descend-ant of the ancestor whose function is being called.

INSTANTIATION