Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

MVBasic: Object Syntax

Caché MVBasic also extends MultiValue Basic by providing an object syntax to allow MVBasic to take advantage of Caché objects. This example uses the object syntax to access the GetVersion method of the %SYSTEM.Version class. This method displays the version information for the Caché instance.

MyAccount: ; PRINT "%SYSTEM.Version"->GetVersion() 
Cache for Windows (x86-64) 2015.2 (Build 646) Wed Jun 10 2015 19:29:07 EST

The object syntax uses quotation marks around class names and it uses the –> operator to invoke methods and access properties.

The MVBasic object syntax can be used with an imported multivalue file after the PROTOCLASS utility has been run on its dictionary. This utility creates a Caché class for the file and thereby provides the object representation. After running PROTOCLASS on PERSON, the following MVBasic routine displays the data for the record with id 2:

P = "MVFILE.PERSON"->%OpenId(2)
PRINT "NAME: ": P->Name
PRINT "AGE:  ": P->Age
PRINT "HAIR: ": P->Hair
FOR I=1 TO P->Phone->Count()
 PRINT P->Phone->GetAt(I)

To learn more about the PROTOCLASS utility, read PROTOCLASS Overview and Running PROTOCLASS.