Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Group info
Recent pages and files
RESOURCE: COS to MVBASIC cross-reference    

The following are some translations that should make reading COS easier and make it easier to convert code written in COS to MVBASIC. Please feel free to add to this page other translations as you learn them.

 

If you see: write change it to: print

 

If you see: do or its shorthand d just drop it

 

If you see: set or its shorthand s just drop it

 

If you see: ##class(someclassname) change it to "someclassname"

 

If you see: ##class(someclassname).somemethod() change it to "someclassname"->somemethod()

 

If you see: someobject.somemethod() or someobject.someproperty such as %request.somemethod() change it to: someobject->somemethod() or someobject->someproperty

 

If you see: _ change it to: : (underscore is concatenation)

 

If you see: ' change it to ! (single quote is negation)

 

If you see: a dot . between an object reference and a method or property name, translate that to an arrow ->

 

If you see: $$$OK change it to: 1 or  "%SYSTEM.Status"->OK()

 

If you see: &html<...> change it to: print ... statements to output the same html

 

If you see: if (condition) { } change it to: IF condition THEN ... END

 

If you see: $IsObject change it to IsObject

 

If you see: $$$Text or other three dollar sign things, they are COS macros and cannot be used in mvbasic.  These could be wrapped with ClassMethods that execute them and return the output. 

 

If you see: .. (two dots) before a method or property it stands for %this. (the %this object and a dot) change it to: @ME-> (at ME arrow)

 

If you see: Goto (yup, I've seen it in COS), pretend there is no equivalent construct in MVBASIC ;-) 

 

If you see: Quit change it to: RETURN

 

If you see: ! in an output statement, it is a new line 

 

If you see: $S or other $ single character things, take a look at http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS (changing the URL for your installation, specifically this page http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_abbreviations for $S)

 

Some examples below:

In COS:
Set result = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
Translates to MVBASIC:
result = "%ResultSet"->%New("%Dictionary.ClassDefinition:Summary")

Explanation: 

So, in this case, we are calling the %New method (aka, the constructor) of the %ResultSet class by putting the class name in double quotes, then an arrow, then the %New method, passing it the same parameter no matter what language is calling it. One place you often need to use COS syntax is within a parameter value, such as the %Dictionary.ClassDefinition example above. You do not change that to %Dictionary->ClassDefinition.

 

Object methods and properties.


Class methods.

In COS:
Do ##class(P.Person).Populate()
Translates to MVBASIC:
"P.Person"->Populate()

Methods and properties:
In COS:
set obj=##class(Sample.Person).%OpenId(1)
write obj.Name
set obj.Name="Umnikov, Anton"
do obj.%Save()
Translates to MVBASIC:
obj = "Sample.Person"->%OpenId(1)
PRINT obj->Name
obj->Name="Umnikov, Anton"
obj->Save()

Version: 
2 messages about this page
Apr 14 2008 by Lee Burstein
Nice addition to the community. Thanks Dawn.
Lee H. Burstein
Sales Engineer
InterSystems Corporation
Office: 302-477-0180
Mobile: 302-345-0810
FAX: 270-494-0180
-----Original Message-----
[mailto:InterSystems-MV@googlegroups.com] On Behalf Of dawn
Sent: Monday, April 14, 2008 2:12 PM
To: InterSystems: MV Community
Apr 14 2008 by dawn
Please feel free to add to this page. It is intended to help someone
who knows MVBASIC learn to read COS more quickly. There is plenty
missing, such as any mention of globals (^ stuff), dates, etc. so jump
in when you have something to add to this.

Click on http://groups.google.com/group/InterSystems-MV/web/resource-cos-to-mvbasic-cross-reference
Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google