Dynamic Dataset creation for template repeater Vision

Looking for best way to create dynamic dataset for a template repeater

dataset to be based on variables ValueA, ValueB, startid, stopid (all these are values from screen objects/parameters

such that

colnames : Name / type / ID
row1 : =valueA / =valueB / =startid
row2 =valueA / =valueB / =startid+1
row3 =valueA / =valueB / =startid+2
row4 =valueA / =valueB / =startid+3
...
until startid=stopid

This would be a pretty simple list comprehension paired with system.dataset.toDataSet, I imagine.


valueA = "ValueA"
valueB = "ValueB"
startId = 10
stopId = 20

headers = ["Name", "Type", "ID"]
data = [
  [valueA, valueB, index]
  for index in range(startId, stopId)
]

dataset = system.dataset.toDataSet(headers, data)

ok, what I was generally thinking, but was hoping there was some solution that i could do in expression instead of using scripting.

Thanks

Nope, no ability to loop in expressions, so you'll have to use some amount of scripting.

Funny you should say that.

I had to stay home today, so my thumb twiddling has been off in that sort of left field....

3 Likes

Now for a working example, using the latest Simulation Aids:

As an expression function (use a reference to a startid tag instead of 50):

unionAll(
	asList("Name", "Type", "ID"),
	asList("str", "str", "i"),
	forEach(
		15,
		"ValueA",
		"ValueB",
		50+it()
	)
)

Yields this dataset:

"#NAMES"
"Name","Type","ID"
"#TYPES"
"str","str","O"
"#ROWS","15"
"ValueA","ValueB","50"
"ValueA","ValueB","51"
"ValueA","ValueB","52"
"ValueA","ValueB","53"
"ValueA","ValueB","54"
"ValueA","ValueB","55"
"ValueA","ValueB","56"
"ValueA","ValueB","57"
"ValueA","ValueB","58"
"ValueA","ValueB","59"
"ValueA","ValueB","60"
"ValueA","ValueB","61"
"ValueA","ValueB","62"
"ValueA","ValueB","63"
"ValueA","ValueB","64"
5 Likes