Difference between revisions of "Documentation/BASIC Guide/Properties and Methods (API)"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
Line 16: Line 16:
 
The properties are set by means of a simple assignment:
 
The properties are set by means of a simple assignment:
  
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
Document.Title = "Apache OpenOffice Basic Programmer's Guide"
 
Document.Title = "Apache OpenOffice Basic Programmer's Guide"
 
Document.Filename = "basguide.odt"
 
Document.Filename = "basguide.odt"
</source>
+
</syntaxhighlight>
  
 
A property, just like a normal variable, has a type that defines which values it can record. The preceding <tt>Filename</tt> and <tt>Title</tt> properties are of the string type.
 
A property, just like a normal variable, has a type that defines which values it can record. The preceding <tt>Filename</tt> and <tt>Title</tt> properties are of the string type.
Line 31: Line 31:
 
Methods can be understood as functions that relate directly to an object and through which this object is called. The preceding <tt>Document</tt> object could, for example, provide a <tt>Save</tt> method, which can be called as follows:
 
Methods can be understood as functions that relate directly to an object and through which this object is called. The preceding <tt>Document</tt> object could, for example, provide a <tt>Save</tt> method, which can be called as follows:
  
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
Document.Save()
 
Document.Save()
</source>
+
</syntaxhighlight>
  
 
Methods, just like functions, may contain parameters and return values. The syntax of such method calls is oriented towards classic functions. The following call also specifies the <tt>True</tt> parameter for the document object when requesting the Save method.
 
Methods, just like functions, may contain parameters and return values. The syntax of such method calls is oriented towards classic functions. The following call also specifies the <tt>True</tt> parameter for the document object when requesting the Save method.
  
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
Ok = Document.Save(True)
 
Ok = Document.Save(True)
</source>
+
</syntaxhighlight>
  
 
Once the method has been completed, <tt>Save</tt> saves a return value in the <tt>Ok</tt> variable.  
 
Once the method has been completed, <tt>Save</tt> saves a return value in the <tt>Ok</tt> variable.  

Latest revision as of 12:17, 30 January 2021


An object in Apache OpenOffice Basic provides a range of properties and methods which can be called by means of the object.

Properties

Properties are like the properties of an object; for example, Filename and Title for a Document object.

The properties are set by means of a simple assignment:

Document.Title = "Apache OpenOffice Basic Programmer's Guide"
Document.Filename = "basguide.odt"

A property, just like a normal variable, has a type that defines which values it can record. The preceding Filename and Title properties are of the string type.

Real Properties and Imitated Properties

Most of the properties of an object in Apache OpenOffice Basic are defined as such in the UNO description of the service. In addition to these "real" properties, there are also properties in Apache OpenOffice Basic which consist of two methods at the UNO level. One of these is used to query the value of the property and the other is issued to set it (get and set methods). The property has been virtually imitated from two methods. Character objects in UNO, for example, provide the getPosition and setPosition methods through which the associated key point can be called up and changed. The Apache OpenOffice Basic programmer can access the values through the Position property. Regardless of this, the original methods are also available (in our example, getPosition and setPosition).

Methods

Methods can be understood as functions that relate directly to an object and through which this object is called. The preceding Document object could, for example, provide a Save method, which can be called as follows:

Document.Save()

Methods, just like functions, may contain parameters and return values. The syntax of such method calls is oriented towards classic functions. The following call also specifies the True parameter for the document object when requesting the Save method.

Ok = Document.Save(True)

Once the method has been completed, Save saves a return value in the Ok variable.


Content on this page is licensed under the Public Documentation License (PDL).
Personal tools