%ArrayOfDataTypes- BuildValueArray

155 views
Skip to first unread message

praka...@gmail.com

unread,
Jun 21, 2014, 3:26:30 PM6/21/14
to intersystems...@googlegroups.com
Hi All,

    Could you any one known how to use   BuildValueArray method in %ArrayOfDataType class.

Can you show one example ?

Thanks in Advance.

DAiMor

unread,
Jun 23, 2014, 8:05:08 AM6/23/14
to intersystems...@googlegroups.com
list=$lb(
$lb("name","somename"),
$lb("value","somevalue"))
##class(%ArrayOfDataTypes).BuildValueArray(list,.arr)
zw arr
and result
arr("name")="somename"
arr("value")="somevalue"


суббота, 21 июня 2014 г., 23:26:30 UTC+4 пользователь praka...@gmail.com написал:

Brendan Bannon

unread,
Jun 23, 2014, 8:16:18 AM6/23/14
to intersystems...@googlegroups.com

Hello

 

This method would be generated for an Array Property that is indexed, but you can define it for any property.

 

The method takes in a value and then returns an array of value that need to be index.

 

For example if I have a property called kids that is a comma delimited list of my children:  “Kaitlin,Melissa,Robin,Kieran”

 

I can pass that into KidsBuildValueArray and build an array:

 

Results(1)=”Kaitlin”

Results(2)=”Melissa”

Results(3)=”Robin”

Results(4)=”Kieran”

 

 

Here are my properties and index

 

Property Name As %String;

Property KidsString As %String;

ClassMethod KidsStringBuildValueArray(val, result)
{
            i=1:1:$L(val,",") result(i)=$P(val,",",i)
}

Index Index2 On KidsString(ELEMENTS);

 

And after saving one object here are my globals

 

USER>s x=##class(User.BVA).%New()

USER>s x.Name="Brendan"

USER>s x.KidsString="Kaitlin,Melissa,Robin,Kieran"

USER>w x.%Save()

1

USER>zw ^User.BVAD

^User.BVAD=1

^User.BVAD(1)=$lb("","Brendan","","Kaitlin,Melissa,Robin,Kieran")

USER>zw ^User.BVAI

^User.BVAI("Index1"," ",1)=""

^User.BVAI("Index2"," KAITLIN",1)=""

^User.BVAI("Index2"," KIERAN",1)=""

^User.BVAI("Index2"," MELISSA",1)=""

^User.BVAI("Index2"," ROBIN",1)=""

USER>

--
--
Caché, Ensemble, DeepSee

---
You received this message because you are subscribed to the Google Groups "Caché, Ensemble, DeepSee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to intersystems-publi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages