On 11/17/2012 05:45 PM, Lee Adkins wrote:
Can a bundle contain a list? If so, how? If not, are there
any preferred workarounds?
I was going to say yes it should be able to, but I just learned this
isn't in the specs. So I was getting curious and this is what I came up
with so far:
The following code transfers the list to the bundle, so that the number
of the series is stored within the bundle (as a scalar under the key
"testlist_nelem"), the series themselves are stored (under the keys
"testlist_serX", where X was the position of the series in the list),
and finally the original names of the series are also stored in the
bundle, as strings (under the keys "testlist_nameX").
In principle one should be able to wrap this in a function, I guess.
cheers,
sven
<hansl>
nulldata 100
list testlist = dataset # so far the only series will be 'index'
bundle proto
# populate the bundle with the list contents
n = nelem(testlist)
proto["testlist_nelem"] = n
loop i=1..n
sprintf serieskey "testlist_ser%d", i
sprintf namekey "testlist_name%d", i
proto[namekey] = "$i" # saves the original name of the series
proto[serieskey] = i # saves the series
endloop
# how to retrieve those series
m = proto["testlist_nelem"]
loop i=1..m
series newser$i = proto["testlist_ser$i"]
string message = "Retrieved copy of '" ~
proto["testlist_name$i"] ~
"'."
print "@message"
endloop
</hansl>