CLASS - Parameters

From Recital Documentation Wiki
Revision as of 16:36, 18 March 2009 by Yvonnemilne (Talk | contribs)

Jump to: navigation, search

CLASS - Parameters

Class

Objects


Purpose

Define a parameter list for a method inside a user-defined class


Syntax

PARAMETERS <name> [AS CHARACTER | NUMERIC | LOGICAL | DATE | <class name>] [, ...]


See Also

ADDPROPERTY(), CLASS, CLASS - Methods, CLASS - Properties, CLASS - Scoping, DEFINE CLASS, CREATEOBJECT(), DODEFAULT(), METHOD, NEWOBJECT(), REMOVEPROPERTY()


Description

The PARAMETER command is used inside the CLASS...ENDCLASS construct to define a parameter list for a method. You can pass parameters to methods just as you would to regular functions. If the method name is called CONSTRUCTOR then the parameters are passed to this method when you create the object.

<name> The parameter <name> is the name of a memory variable or array.

AS CHARACTER | NUMERIC | LOGICAL | DATE

The data type of values assigned to a property within an object can be checked at run-time by associating a data type with the property in the class definition. The AS clause is used to perform data scoping. Once a variable has been defined to a specific data type, you cannot change its data type by assigning it a value from a different data type. Doing this will result in the run-time error "Data type mismatch".

AS <class name>

A property data type can inherit a class <class name>, and its members and their implementation from another class. Inheritance enables developers to build a hierarchy of descendant objects. The specification of a property data type as an existing class name provides for construction of a class hierarchy. The inheriting class is called a derived class, and the class that the derived class inherits is called a base class.


Example

class Box
method Draw
parameters nX1, nY1, nX2, nY2, cFGCOL, cBGCOL
@nX1,nY1 clear to nX2,nY2
@nX1,nY1 fill to nX2,nY2 ;
color &(cFGCOL + "/" + cBGCOL)
@nX1,nY1 to nX2,nY2 ;
color &(cFGCOL + "/" + cBGCOL)
return  && Draw 
endclass
 
class Dialog1 of Box
property lOK
 
method Show
parameters nX1, nY1, nX2, nY2, cMESSAGE
 
this.Draw(nX1,nY1,nX2,nY2, "n", "bg")
@nX1 + 2,nY1 + int((nY2 - nY1 - ;
len(cMESSAGE))/2) say cMESSAGE color w+/bg
@nX2 - 2,nY1 + int((nY2 - nY1 - 5)/2) ;
menu [ <Ok ] 
menu quit 
this.lOK = (not empty(menuitem()))
@0,0 clear to 0,79
return  && Show
endclass 
 
oDIALOGOK = new Dialog1()
oDIALOGOK.Show(5,25,12,54, "Completed")
? oDIALOGOK.lOK
?


Products

Recital Database Server, Recital Mirage Server, Recital Terminal Developer