Difference between revisions of "CLASS - Parameters"

From Recital Documentation Wiki
Jump to: navigation, search
(Example)
Line 34: Line 34:
 
<code lang="recital">
 
<code lang="recital">
 
class Box
 
class Box
method Draw
+
    method Draw
parameters nX1, nY1, nX2, nY2, cFGCOL, cBGCOL
+
    parameters nX1, nY1, nX2, nY2, cFGCOL, cBGCOL
@nX1,nY1 clear to nX2,nY2
+
        @nX1,nY1 clear to nX2,nY2
@nX1,nY1 fill to nX2,nY2 ;
+
        @nX1,nY1 fill to nX2,nY2 ;
color &(cFGCOL + "/" + cBGCOL)
+
            color &(cFGCOL + "/" + cBGCOL)
@nX1,nY1 to nX2,nY2 ;
+
        @nX1,nY1 to nX2,nY2 ;
color &(cFGCOL + "/" + cBGCOL)
+
            color &(cFGCOL + "/" + cBGCOL)
return  && Draw  
+
    return  && Draw  
 
endclass
 
endclass
  
 
class Dialog1 of Box
 
class Dialog1 of Box
property lOK
+
    property lOK
  
method Show
+
    method Show
parameters nX1, nY1, nX2, nY2, cMESSAGE
+
    parameters nX1, nY1, nX2, nY2, cMESSAGE
  
this.Draw(nX1,nY1,nX2,nY2, "n", "bg")
+
        this.Draw(nX1,nY1,nX2,nY2, "n", "bg")
@nX1 + 2,nY1 + int((nY2 - nY1 - ;
+
        @nX1 + 2,nY1 + int((nY2 - nY1 - ;
len(cMESSAGE))/2) say cMESSAGE color w+/bg
+
            len(cMESSAGE))/2) say cMESSAGE color w+/bg
@nX2 - 2,nY1 + int((nY2 - nY1 - 5)/2) ;
+
        @nX2 - 2,nY1 + int((nY2 - nY1 - 5)/2) ;
menu [ <Ok ]  
+
            menu [ <Ok ]  
menu quit  
+
        menu quit  
this.lOK = (not empty(menuitem()))
+
        this.lOK = (not empty(menuitem()))
@0,0 clear to 0,79
+
        @0,0 clear to 0,79
return  && Show
+
    return  && Show
 
endclass  
 
endclass  
  
Line 66: Line 66:
 
?
 
?
 
</code>
 
</code>
 
  
 
==Products==
 
==Products==

Revision as of 00:26, 19 March 2009

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