cache/iris class array approach analogue to javascript Associative array
objects in javascript :
var oM = new Object;
var mMode=["down","up","click"] ;
var key,val ;
for (key in mMode)
{
val = mMode[key] ;
oM[val]={} ;
oM[val].id ="" ;
oM[val].type ="" ;
...
}
so I can access the .type directly as :
oM.down.type
or:
oM["down"].type
what is the syntax in CACHE or IRIS, to achieve such approach via class/key/property...?
acctually: class/object/key/property anlaogue to ^GLOBAL(key,"property")=val
Did you ever try this?
https://learning.intersystems.com/course/view.php?id=28
$property
I think you're looking for the %ArrayOfObjects class for this one. You'd create your objects with all of their value, ID, and type properties, then you'd create the array:
Then you set values of the array using the SetAt method:
Then to access a particular value, you use the GetAt method, then dot syntax to access the object's properties:
Here's the %ArrayOfObjects class documentation.
>do array.SetAt(downobject,"down")
how I set the: .id=val and .type=val1
Hmm. Upon re-reading your question, I realized this isn't really the answer you were looking for. Others have provided the correct solutions/references.
>
can I set also :
oM["click"].type="double" ?
is the oM, persistent, like set ^oM("click","type")="double" ?
or actually, I want to set "^global" values by objects/methods syntax, but maintain the direct approach of ^globals ?
not using some clumsy .openId(?)
just get/set values
No, you can't use the quoted string notation (or at least if you can, I haven't figured out how).
It's not persistent either, which is why I followed up to state that it's not really what you're looking for.
In additional experimentation, I found that there is a quoted-string mechanism:
is equivalent to
Regardless, it's still not persistent.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue