• No results found

1. What is the Message object. How do you use it? Why do you use it?

Objects work with one another by sending messages. A message is a subroutine call directed at an object. Every object has a predefined set of subroutines (in PB methods) that you can call to send messages to the object.

Object.Method (parameters) In PB, there are three types of messages:

1, 2. Functions & events which are collectively called “methods”;

3. Properties.

In PB, every object has a set of functions, events and properties for receiving messages. PB also has functions that are not directed to an object, such as a MessageBox.

MessageBox(“Hello”, “How are you?”)

For the transaction object, you do not use the object.function syntax. Instead, you use standard SQL syntax. A Message object is a PowerBuilder-defined global object. When we use functions OpenWithParm( ), OpenSheetWithParm( ), CloseWithReturn( ) (for response window only) specified parameters will be passed through the MessageObject. We can use this Message object to store a parameter when opening or closing a window.

2. How do you use OpenSheetWithParm( )?

We use function OpenSheetWithParm( ) to pass parameters between two Windows (sheets) in (MDI) application using Message Object’s attributes StringParm, DoubleParm or PowerObjectParm, depending on the variable datatype. The Parameters will be stored in MessageObject. OpenSheetWithParm( ) stores the parameter in the system's Message object so that it is accessible to the opened sheet. We use OpenWithParm( ) to open a window that is not an MDI sheet and pass information to the window. We use the OpenSheetWithParm( ) function to open MDI sheets when we need to pass information to the sheet that is being opened or use the information to open the sheet.

3. State briefly and in general terms when you would use each of the following functions.

Be sure your answer reflects the difference between the two functions.

OpenWithParm( )

OpenSheetWithParm( )

4. (true or false) The Open() and OpenWithParm() are only used in (SDI) applications.

5. Assume you are coding the script for the Open event of a window to which a number has been passed. Code the statement that tests whether the value is greater than 100.

6. Can a Message object Pass Parameters?

Yes, using Send () command

7. What functions can you use to pass parameters between the Windows in PB?

OpenWithParm( ) OpenSheetWithParm( ) CloseWithReturn( )

8. How do OpenWithParm() and CloseWithReturn() functions pass parameters?

Using Message Object’s attributes StringParm, DoubleParm, PowerObjectParm depending on a variable datatype. OpenWithParm( ) also stores a parameter in the system’s Message object so that it is accessible to the opened window. Closes a window and stores a return value in the Message object. Use CloseWithReturn() only for response windows.

9. What is the usage for StringParm, DoubleParm and PowerObjectParm attributes of Message Object?

10. What attribute in the Message Object do we have to use if we want to store a Structure in it?

We have to use the PowerObjectParm attribute.

11. What is the Message Object?

It is a PB System object that is used to communicate parameters between windows. When we Open and Close them and in TriggerEvent and PostEvent functions.

12. What attributes of System Object do you use to pass parameters windows?

DoubleParm for numeric parameters, StringParm for strings and PowerObjectParm for any PB objects including structure.

013. What function do you use to communicate parameters between windows?

OpenWithParm and CloseWithReturn power script function.

14. How can you handle Error Messages (examples)?

Put some code into DB Error event (using SetActionCode) int err_code

If SQLDB.Code <> 0 Then

MessageBox (“DB Error:”, “Number” + string (sqldbcode) + “” + &

sqlerrtext, StopSign!) return 1

End if

33. What is the Message object? How do you use it? Why do you use it?

Objects work with one another by sending messages. A message is a subroutine call directed at an object. Every object has a predefined set of subroutines (in PB methods) that you can call to send messages to the object.

Object.Method(parameters) In PB, there are three types of messages:

1, 2. Functions & events which are collectively called “methods”;

Properties.

In PB, every object has a set of functions, events and properties for receiving messages. PB also has functions that are not directed to an object, such as a MessageBox.

MessageBox(“Hello”, “How are you?”)

For the transaction object, you do not use the object.function syntax. Instead, you use standard SQL syntax.

Name Pronouns

1. Describe the circumstances under which you would use the pronoun This instead of the name of the object it represents.

The pronoun This refers to the MenuItem, object, or control for which the script is written.

2. What is SUPER keyword and how it is used?

SUPER is a reserved word used to refer to the immediate ancestor from a descendent level… If we are calling a script from an ancestor we have to use

Call SUPPER :: Clicked

This example calls the Clicked Event in the ancestor object. If you are calling an ancestor function, then you only need to use SUPER ::

SUPER :: wf_name( arguments )

If the script is for an event in a control : Call ancestor window control :: event or a user object in an ancestor window : Call ancestor window object :: event

3. What if you need to call a function from not an immediate ancestor?

We have to specify the full path to that function. For example:

w_name :: function_name( ) to call an event from not an immediate ancestor Call ancestor window :: event.

4. What are :THIS, PARENT, PARENTWINDOW clauses?

They are Name pronouns and used to refer to current objects or controls instead of using actual names. This is used to refer to an object or control from any script coded for it. Parent is used to refer to the window from any script for a control on window. ParentWindow is used to refer to the window from a MenuItem script at execution time.

5. What is the difference between reserved word Parent an ParentWindow, When are they used in the script for the MenuItem?

ParentWindow refers to the window that associated with a Menu. ParentWindow can be used only in scripts for MenuItems. Parent is used in the following scripts :

A script for a control in a window.

A script for a custom UserObject.

A script for a MenuItem.

When we use Parent in the script for a MenuItem, Parent refers to the MenuItem on the level above the MenuItem the MenuItem the script is for. ParentWindow is the name of the window object that owns the menu.

6. What are Object Name pronouns and how do use them?

Name Pronouns are reserved words that are used to refer to objects or controls instead of using actual name. They are:

This is used to refer to an object or control from within any script coded for it.

Parent is used to refer to the window from any script for a control on the window.

ParentWindow can be used only in scripts for MenuItems.

Super is a reference used in a script of an inherited object to refer to the script in its immediate ancestor (parent).

When we use Parent in a script for a control, it refers to the window that contains the control. When we use Parent in the script for a MenuItem, Parent refers to the MenuItem on the level above the MenuItem the script is for. When we use Parent in a script for a control in a custom UO, Parent refers to the UO. The pronoun ParentWindow refers to the window with which the menu is associated at execution time.

ParentWindow can be used only in scripts for MenuItem. The pronoun This refers to the window, UO, MenuItem, application object, or control itself. When we write a script for a descendant object or control, we can call scripts written for many ancestor. We can directly name the ancestor in the call, or we can use the reserved word Super to refer to the immediate ancestor (parent) CALL Super :: Clicked.

7. What reserve word for window do you know?

ParentWindow type refer to the window that the menu is associated with at runtime.

We can use ParentWindow to refer to attributes of the window a menu is associated with but not refer to attributes of controls or user objects in the window.

NULL

1. What is NULL? What happens when you use NULL in expressions?

Null is an Undefined, Unknown value. If we use Null in arithmetic expression the expression becomes Null. If we use Null in a Boolean expression, Null and some value, expression becomes Null (False). If we use Null in a Boolean expression, the Null or some values it gives value and becomes True. PB does not initialize to NULL. To set NULL to the variable we use SetNull() function. Use SetNull() to set a variable to NULL before writing it to the DB. Note that PB does not initialize variables to NULL; it initializes variables to the default initial value for the data type unless you specify a value when you declare the variable. If you assign a value to a variable whose data type is Any and then set the variable to NULL, the data type of the NULL value is still the data type of the assigned value. You cannot un-type an Any variable with the SetNull function.

2. How can a variable become NULL?

Can be read from database or SetNull() function can be used 3. How to test whether variable or expressions is NULL?

Using ISNULL()

4. How does NULL behave in boolean expressions?

In AND logical operators that contain NULL result is always False In OR logical operators that contain NULL result is always True.

21. What is NULL? What happens when you use NULL in expressions?

What NULL means:

NULL means undefined. Think of NULL as unknown. It is not the same as an empty string or zero or a date of 0000-00-00. For example, NULL is neither 0 nor not 0.

Null is an unknown variable. When you use null in expressions they become null.

When a NULL value is read into a variable, the variable remains NULL unless it is changed in a script.

NULL means “no value”, “undefined”, “unknown”. It is not the same as an empty string or zero, or false. A common way for a variable to get a NULL value is when you retrieve its value from a DB column that has never been filled in –a missing zip code for a customer, for example.

Any variable, regardless of its type, can be set to NULL using the PowerScript SetNull function.

E.g.

string i1 SetNull (i1)

If any part of the expression is NULL, the result of the entire expression is NULL.