Blaise ZARKA · Apr 15, 2020

%Library.ListOfDataTypes to $LIST conversion

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


0 505
Discussion (10)0
Log in or sign up to continue

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

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.