NEW Operator

From Lianjapedia
Jump to: navigation, search

Purpose

Create a new object based on a class

Syntax

NEW <classname>([<arg> [, ...]])

See Also

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

Description

The NEW operator is used to create a new object based on the class <classname>. The <classname> should be followed by brackets (). Parameters can optionally be passed to the object's init method.

The NEWOBJECT() function returns a reference to the newly created object.

Example

define class product as custom
	productname = "Lianja App Builder"
	version = "3.4"
	proc init(arg1)
		? etos(arg1)
	endproc
	proc getver
		? this.version
	endproc
enddefine
 
oProduct = new product("Hello World")
oProduct.getver()
? oProduct.productname