Application Classes Built-in Functions and Language Constructs

In this section, we discuss the Application classes built-in functions and language constructs, in alphabetical order.

Syntax

class ClassName [{extends | implements} SuperClassName]
   [Method_declarations]
   [Property_declarations]
[protected
   [Method_declarations]
   [Instance_declarations]
   [Constant_declaration]]
[private
   [Method_declarations]
   [Instance_declarations]
   [Constant_declaration]]
end-class

Where Method_declarations are of the form:

method methodname([MethodParam1 [, MethodParam2...] [Returns Datatype]] [abstract])

Where Property_declarations are of the form:

property DataType PropertyName {{[get] | [set]} | [abstract] | [readonly]}

Where Instance_declarations are of the form:

instance DataType &Variable1 [, &Variable2...]

Where Constant_declarations are of the form:

constant &Constant = {Number  | String | True | False | Null }

Description

Use the Class language construct to build application classes in an application package. All classes within a package must be uniquely named, however, classes contained in different packages do not have to be named uniquely.

External function declarations are allowed in application classes, in the global and component variable declarations, after the class declaration (after the end-class statement), and before the method definitions.

Parameters

Field or Control

Definition

ClassName

Specify the name of the class that you are creating. All classes within a package must be uniquely named, however, classes contained in different packages do not have to be named uniquely.

extends | implements SuperClassName

For a regular class, specify the name of the class that this class extends. If the class is an interface type of class, specify the name of the interface that this class implements.

Important! You must import the class to extend it.

Method_declarations

Specify the methods (and their signature) as used in this class.

Property_declarations

Specify the properties, and their usage, in this class.

protected

Use this keyword to declare any methods, constants, or instance variables as protected to the class, that is, are only visible to the declaring class and subclasses.

private

Use this keyword to declare any methods, constants, or instance variables as private to the class, that is, they can't be accessed by any other classes.

Instance_declarations

Specify any variables that should be in any instance (object) of the class.

Constant_declarations

Specify any constants that should be used with this class.

Returns

None.

Example

class Example extends ExampleBase
   method NumToStr(&Num As number) Returns string;
   method AppendSlash();
   property number SlashCount get;
   property number ImportantDayOfWeek get set;
   property string SlashString readonly;
   property date ImportantDate;
private
   method NextDayOfWeek(&DoW As number) Returns date;
   constant &Sunday = 1;
   instance number &BaseString;
end-class;

Syntax

get PropertyName
   StatementList 
end-get

Description

Use the get language construct when defining properties in an application class that are implemented by methods rather than an instance variable. All properties within an application class must be uniquely named.

Parameters

Field or Control

Definition

PropertyName

Specify the name of the property that you're implementing.

StatementList

Returns the value of the property. In other words, this is a method which has no parameters and must return the value of the property.

Returns

Depends on the assignment within StatementList

Example

get FruitCount
   Return &MyFruit.Number();
end-get;

Syntax

import PKG_NAME[:SubpackageName[:SubpackageName]]{:ClassName | *}

Description

Before you can use a class name, you must first import it using an import declaration statement at the beginning of your program.

An import declaration statement names either all the classes in a package or a single application class.

Parameters

Field or Control

Definition

import PKG_NAME

Specify the name of the package that you want to import.

:SubpackageName[:SubpackageName]

Specify the subpackage path to the class.

ClassName

Import only this class of the specified package. You won't have access to any other classes in the specified package, only this one.

*

Import all the classes of the specified package.

Returns

None.

Example

The following gives you access to all the classes in the FRUIT package:

import FRUIT:*;

The following gives you access to the Banana class only in the FRUIT package:

import FRUIT:Banana;

The following gives you access to the Apple class only from the Fruit subpackage of the DRINKS package:

import DRINKS:Fruit:Apple;

Syntax

interfaceClassName [{extends | implements} SuperClassName]
   [Method_declarations]
   [Property_declarations]
[protected   [Method_declarations]
   [Instance_declarations]
   [Constant_declaration]]
end-interface

Where Method_declarations are of the form:

method methodname([MethodParam1 [, MethodParam2...] [Returns Datatype]] [abstract])

Where Property_declarations are of the form:

property DataType PropertyName {{[get] | [set]} | [abstract] | [readonly]}

Where Instance_declarations are of the form:

instance DataType &Variable1 [, &Variable2...]

Where Constant_declarations are of the form:

constant &Constant = {Number  | String | True | False | Null }

Description

Use the Interface language construct to create classes of type interface in an application package. An interface class is a purely abstract class.

Parameters

An interface does not have private methods or properties, but all the other parameters are identical to the class language construct.

Returns

None.

Syntax

method MethodName
   StatementList
end-method

Description

Use the method statement to define the methods of your application class.

Parameters

Field or Control

Definition

method MethodName

Specify the name of the method that you are creating.

StatementList

Specify the program of the method, what it does.

Returns

Depends on the method.

Example

method NumToStr
   /+ Returns String +/
   Return String(&Num);
end-method;

method AppendSlash
   &SlashString = &SlashString | "/";
end-method;

While properties are declared, they do not have explicit definitions like methods. However, you can create definitions to set or get the value of a property. See set and get.

Syntax

setPropertyName
   StatementList
end-set

Description

Use the set language construct when implementing properties in an application class. All properties within an application class must be uniquely named. The new value for the property is available in the &NewValue parameter of the set definition.

Note: You cannot create a set-only property. You can create only get-set properties.

Parameters

Field or Control

Definition

set PropertyName

Specify the name of the property that you're implementing.

StatementList

Change the value of the property to be &NewValue.

Returns

None.

Example

set FruitCount
   /+ &NewValue as String +/
   &NewValue = &MyFruit.ActiveRowCount;
   &FruitCount = &NewValue;
end-set;