Difference between revisions of "OBJECT()"
Yvonnemilne (Talk | contribs) |
Barrymavin (Talk | contribs) (→Example) |
||
(5 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | + | ==Purpose== | |
+ | Function to create an anonymous object | ||
+ | |||
+ | |||
+ | ==Syntax== | ||
+ | OBJECT([<property value> | <property name> => <property value> [,...]]) | ||
+ | |||
+ | |||
+ | ==See Also== | ||
+ | [[ACLASS()]], [[ADDPROPERTY()]], [[AMEMBERS()]], [[CLASS]], [[CLASS - Methods]], [[CLASS - Parameters]], [[CLASS - Properties]], [[CLASS - Scoping]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DISPLAY CLASSES]], [[DODEFAULT()]], [[FOREACH]], [[LIST CLASSES]], [[LOADOBJECT()]], [[METHOD]], [[NEWOBJECT()]], [[PRINT_HTML()]], [[PRINT_JSON()]], [[PRINT_R()]], [[PRINT_XML()]], [[REMOVEPROPERTY()]], [[REQUIRE_ONCE()]], [[SAVEOBJECT()]], [[SQL SELECT]], [[WITH]] | ||
+ | |||
+ | |||
+ | ==Description== | ||
+ | The OBJECT() function is used to create an anonymous object. Properties are declared in a comma-separated list. Properties can be values only, <property value>, in which case they are given an automatically generated name: 00000001, 00000002 ... Property names can be specified using the <property name> => <property value> syntax. The OBJECT() function can also be included within the <property value> definition. The OBJECT() function returns an object. | ||
+ | |||
+ | |||
+ | ==Example== | ||
+ | <code lang="recital"> | ||
+ | customer = object("custname" => "A Buyer Ltd.", ; | ||
+ | "currentorder" => object("ord_id" => "00001", "ord_date" => date(),"ord_total" => 1599,; | ||
+ | "orderitems" => object("10 reams A4 paper","500 business cards",; | ||
+ | "500 black ballpoint pens"))) | ||
+ | display memory | ||
+ | |||
+ | Memory Variables: | ||
+ | ------------------------ | ||
+ | CUSTOMER Object (refptr OBJECT, refcnt 1) | ||
+ | .CUSTNAME Character 'A Buyer Ltd.' | ||
+ | .CURRENTORDER Object (refptr OBJECT, refcnt 1) | ||
+ | .ORD_ID Character '00001' | ||
+ | .ORD_DATE Date 11/17/2009 | ||
+ | .ORD_TOTAL Numeric 1599 (1599.000000000) | ||
+ | .ORDERITEMS Object (refptr OBJECT, refcnt 1) | ||
+ | .00000001 Character '10 reams A4 paper' | ||
+ | .00000002 Character '500 business cards' | ||
+ | .00000003 Character '500 black ballpoint pens' | ||
+ | |||
+ | Total of 10 variables defined and 784 bytes used. | ||
+ | </code> | ||
+ | |||
+ | ==Products== | ||
+ | Recital, Recital Server | ||
+ | [[Category:Documentation]] | ||
+ | [[Category:Functions]] | ||
+ | [[Category:Objects]] | ||
+ | [[Category:Objects Functions]] |
Latest revision as of 03:34, 20 June 2010
Purpose
Function to create an anonymous object
Syntax
OBJECT([<property value> | <property name> => <property value> [,...]])
See Also
ACLASS(), ADDPROPERTY(), AMEMBERS(), CLASS, CLASS - Methods, CLASS - Parameters, CLASS - Properties, CLASS - Scoping, COMPOBJ(), CREATEOBJECT(), DEFINE CLASS, DISPLAY CLASSES, DODEFAULT(), FOREACH, LIST CLASSES, LOADOBJECT(), METHOD, NEWOBJECT(), PRINT_HTML(), PRINT_JSON(), PRINT_R(), PRINT_XML(), REMOVEPROPERTY(), REQUIRE_ONCE(), SAVEOBJECT(), SQL SELECT, WITH
Description
The OBJECT() function is used to create an anonymous object. Properties are declared in a comma-separated list. Properties can be values only, <property value>, in which case they are given an automatically generated name: 00000001, 00000002 ... Property names can be specified using the <property name> => <property value> syntax. The OBJECT() function can also be included within the <property value> definition. The OBJECT() function returns an object.
Example
customer = object("custname" => "A Buyer Ltd.", ; "currentorder" => object("ord_id" => "00001", "ord_date" => date(),"ord_total" => 1599,; "orderitems" => object("10 reams A4 paper","500 business cards",; "500 black ballpoint pens"))) display memory Memory Variables: ------------------------ CUSTOMER Object (refptr OBJECT, refcnt 1) .CUSTNAME Character 'A Buyer Ltd.' .CURRENTORDER Object (refptr OBJECT, refcnt 1) .ORD_ID Character '00001' .ORD_DATE Date 11/17/2009 .ORD_TOTAL Numeric 1599 (1599.000000000) .ORDERITEMS Object (refptr OBJECT, refcnt 1) .00000001 Character '10 reams A4 paper' .00000002 Character '500 business cards' .00000003 Character '500 black ballpoint pens' Total of 10 variables defined and 784 bytes used.
Products
Recital, Recital Server