Difference between revisions of "NEWOBJECT()"

From Lianjapedia
Jump to: navigation, search
 
(3 intermediate revisions by 2 users not shown)
Line 3: Line 3:
  
 
==Syntax==
 
==Syntax==
NEWOBJECT(<expC1> [, <exp1>, <exp2>, ...]]])
+
NEWOBJECT(<expC1> [, <expC2> [, <exp1> [, <exp2> [, ...]]]])
  
 
==See Also==
 
==See Also==
[[ACLASS()]], [[ADDPROPERTY()]], [[AMEMBERS()]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DISPLAY CLASSES]], [[DODEFAULT()]], [[FOREACH]], [[LIST CLASSES]], [[LOADOBJECT()]], [[OBJECT()]], [[PRINT_HTML()]], [[PRINT_JSON()]], [[PRINT_R()]], [[PRINT_XML()]], [[REMOVEPROPERTY()]], [[REQUIRE_ONCE()]], [[SAVEOBJECT()]], [[SQL SELECT]], [[WITH]]
+
[[ACLASS()]], [[ADDPROPERTY()]], [[AMEMBERS()]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DISPLAY CLASSES]], [[DODEFAULT()]], [[FOREACH]], [[LIST CLASSES]], [[LOADOBJECT()]], [[NEW Operator]], [[OBJECT()]], [[PRINT_HTML()]], [[PRINT_JSON()]], [[PRINT_R()]], [[PRINT_XML()]], [[REMOVEPROPERTY()]], [[REQUIRE_ONCE()]], [[SAVEOBJECT()]], [[SET CLASSLIB]], [[SQL SELECT]], [[WITH]]
  
 
==Description==
 
==Description==
The NEWOBJECT() function is used to create a new object.  The <expC1> is  
+
The NEWOBJECT() function is used to create a new object.  The <expC1> is the class on which the new object is based.  If <expC1> is defined in a class library, the class library can be specified in <expC2>, otherwise it must be explicitly opened with [[SET CLASSLIB]]. If the class library does not have a '.vcp' extension, the full filename should be specified.  Parameters can be passed to the object's init method in <exp1>, <exp2>, ... .
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 object.
Line 16: Line 15:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
class opentable
+
// myclasslib.vcp
        property cAlias
+
define class Product as custom
        property nRecnum
+
productname = "Lianja App Builder"
        procedure init(pAlias)
+
version = "1.0"
                use &pAlias
+
proc init(arg1)
                this.cAlias = pAlias
+
? etos(arg1)
        endproc
+
endproc
        procedure nRecnum_access
+
proc getver
                this.nRecnum = recno()
+
? this.version
        endproc
+
endproc
endclass
+
enddefine
 +
// end of myclasslib.vcp
  
oCompany = newobject("opentable","example")
+
oProduct = newobject("Product","myclasslib","Hello World")
? oCompany.nRecnum
+
? oCompany.cAlias
+
 
</code>
 
</code>
  
Line 36: Line 34:
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:Objects]]
 
[[Category:Objects]]
[[Category:Objects Functions]]
+
[[Category:Declaring Variables and Arrays]]

Latest revision as of 07:01, 7 April 2017

Purpose

Function to create a new object

Syntax

NEWOBJECT(<expC1> [, <expC2> [, <exp1> [, <exp2> [, ...]]]])

See Also

ACLASS(), ADDPROPERTY(), AMEMBERS(), COMPOBJ(), CREATEOBJECT(), DEFINE CLASS, DISPLAY CLASSES, DODEFAULT(), FOREACH, LIST CLASSES, LOADOBJECT(), NEW Operator, OBJECT(), PRINT_HTML(), PRINT_JSON(), PRINT_R(), PRINT_XML(), REMOVEPROPERTY(), REQUIRE_ONCE(), SAVEOBJECT(), SET CLASSLIB, SQL SELECT, WITH

Description

The NEWOBJECT() function is used to create a new object. The <expC1> is the class on which the new object is based. If <expC1> is defined in a class library, the class library can be specified in <expC2>, otherwise it must be explicitly opened with SET CLASSLIB. If the class library does not have a '.vcp' extension, the full filename should be specified. 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

// myclasslib.vcp
define class Product as custom
	productname = "Lianja App Builder"
	version = "1.0"
	proc init(arg1)
		? etos(arg1)
	endproc
	proc getver
		? this.version
	endproc
enddefine
// end of myclasslib.vcp
 
oProduct = newobject("Product","myclasslib","Hello World")