Wednesday 8 March 2017

8. PowerBuilder Fundamentals1

Scope of Variables used in PB:
Local:
 Local variable is a temporary variable only declared in the script itself and they are available only in the script where they were declared, when the script is finished execution the local variable is destroyed.
Instance:
 Instance variable that belongs to an object and associated with an instance of object. It allows values to be shared between scripts in the same object.
Shared:
A shared variable is also called a class variable.  There is one copy of it
that is shared by all instances of the class. More of like static variable.
Global:
 Global variable can access anywhere in the application. Can access any object in the application. It has public access level.


PBR File:
When a resource is referenced at runtime, if the resource has not been included in the executable file or in a dynamic library, PowerBuilder looks for it in the search path i.e. (current directory, windows directory & directories listed in path variable)
While adding external resource like image (such as BMP, CUR, ICO), sounds, etc.,  we need to specify this in PBR file.
The path in PBR files and PB object source must be an exact match.
After this, include PBR file in the PBR file section in your project as the Resource file name.


Datastore:
- DataStore is a non-visual control of the data window, which can store data for applications without any graphics resources consumption. In addition to a number of visual characteristics, its functions and conduct the same control and data window.
- Used when  user doesn't need to see the data itself

// declare the variable
   DataStore  lds_datastore    
  // create the control
   lds_datastore = Create DataStore
  // assign the datawindow object to datastore
   lds_datastore.DataObject = "d_datawindow"
   // bind the data
   lds_datastore.SetTransObject(SQLCA)
   lds_datastore.Retrieve()  
  // destroy datastore
  DESTROY myDataStore



Structures:
A structure is a collection of one or more related variable of the same or different data types grouped under a single name.
Useful with OpenSheetwithParm () function to pass more than one parameters to other pb object.
Global - Not associated with any objects.
Object Level - Associated with types of windows, menu or user object.

No comments:

Post a Comment