Question
Blaise ZARKA · Apr 15, 2020

%Library.ListOfDataTypes to $LIST conversion

Hi,
Do you know the best way to convert a %Library.ListOfDataTypes instance to a $LIST format string?

Thanks,
Blaise

00
1 0 10 214
Log in or sign up to continue

Replies

I think fairly straightforward approach works best

set l = ##class(%ListOfDataTypes).%New()
do l.Insert(1)
do l.Insert(2)
do l.Insert(4)
set lb = ""
for i=1:1:l.Count() { set lb = lb _ $lb(l.GetAt(i)) }
zw lb
>lb=$lb(1,2,4)

thanks @Eduard Lebedyuk 
Yes it works great. that's the way we did it. So no direct straight serialization system function. ;-)

There is actually. %GetSerial method builds a $lb from %ListOfDataTypes and %SetSerial does the reverse.

Both of these methods are private though. You can subclass %ListOfDataTypes and publish them.

Oh great!
Please InterSystems developers, make these useful methods public and supported ;-)

You can request new features/enhancements in WRC tickets.

%Collection classes are internal and not to be used.

You're sure about that?
I understand these methods should only be used when the list property comes from a %Persistent object, but new instance with %New method is not allowed.

Well, %Collection classes are the implementation of these constructs:

  • Property X As List Of Type
  • Relationships

You can call their methods but do not explicitly create objects of these classes.

And you can request it here in case you don't have WRC account or/if you want to make it public and get votes.