docs.intersystems.com
MultiValue Quick Start Tutorial
MVBasic: Object Syntax
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Search:    

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
PRINT "PHONES: "
FOR I=1 TO P->Phone->Count()
 PRINT P->Phone->GetAt(I)
NEXT I
END   
Note:
To learn more about the PROTOCLASS utility, read PROTOCLASS Overview and Running PROTOCLASS.


Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA