Difference between revisions of "NEWOBJECT()"
From Recital Documentation Wiki
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
− | Function to create a new | + | Function to create a new object |
==Syntax== | ==Syntax== | ||
− | NEWOBJECT(<expC1 | + | NEWOBJECT(<expC1> [, <exp1>, <exp2>, ...]]]) |
Line 12: | Line 12: | ||
==Description== | ==Description== | ||
− | The NEWOBJECT() function is used to create a new | + | The NEWOBJECT() function is used to create a new object. The <expC1> is |
+ | the class on which the new object is based. Optionally, parameters can be passed to the object's ''init'' method in <exp1>, <exp2>, ... . | ||
− | + | The NEWOBJECT() function returns a reference to the newly created object. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | The NEWOBJECT() function returns a reference to the newly created | + | |
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | + | class opentable | |
+ | property cAlias | ||
+ | property nRecnum | ||
+ | procedure init(pAlias) | ||
+ | use &pAlias | ||
+ | this.cAlias = pAlias | ||
+ | endproc | ||
+ | procedure nRecnum_access | ||
+ | this.nRecnum = recno() | ||
+ | endproc | ||
+ | endclass | ||
+ | |||
+ | oCompany = newobject("opentable","example") | ||
+ | ? oCompany.nRecnum | ||
+ | ? oCompany.cAlias | ||
</code> | </code> | ||
Revision as of 14:19, 14 December 2009
Purpose
Function to create a new object
Syntax
NEWOBJECT(<expC1> [, <exp1>, <exp2>, ...]]])
See Also
ACLASS(), ADDPROPERTY(), AMEMBERS(), CLASS, COMPOBJ(), CREATEOBJECT(), DEFINE CLASS, DODEFAULT(), METHOD, REMOVEPROPERTY(), SET CLASSLIBRARY, TOSTRING(), WITH
Description
The NEWOBJECT() function is used to create a new object. The <expC1> is the class on which the new object is based. Optionally, parameters can be passed to the object's init method in <exp1>, <exp2>, ... .
The NEWOBJECT() function returns a reference to the newly created object.
Example
class opentable property cAlias property nRecnum procedure init(pAlias) use &pAlias this.cAlias = pAlias endproc procedure nRecnum_access this.nRecnum = recno() endproc endclass oCompany = newobject("opentable","example") ? oCompany.nRecnum ? oCompany.cAlias
Products
Recital, Recital Server