A Script That will Create an Item and Populate the Cell of the Just Created Item with a value

655 viewsScripting
0

Quantrix Community,  I’m no scripting master, but I know several of you are.  Here is my question.

QuantrixAuthority Answered question October 31, 2023
0

Thanks for the effort lyndseyweber perhaps this will help clarify what I’m after.

lyndseyweber Posted new comment October 30, 2023

Thanks Rich! Maybe this script then?
//if you want to clear the previous “last” item value in C1, include this line first: |Matrix2::B|.children.last().value = “”//

|Matrix2::B|.children.create()
|Matrix2::B|.children.last().value = |Matrix2::B|.items.size

Or, depending on what it is you’re trying to do, you could just put a formula in Matrix 2 in lieu of the last line in the script above… C1:B[LAST] = #B

0

Here is a simple example that may not do what you’re asking, so let me know.

This will check the # of items in Matrix1::B and add that # of items to Matrix2::C. Then, the script will populate/re-index all items in C.

So, with this script, the # of items in Matrix2::C is only ever increasing.

def size = |Matrix1::B|.items.size

|Matrix2::C|.children.create(size)

|Matrix2::C|.values = 1..|Matrix2::C|.items.size
lyndseyweber Answered question October 30, 2023
0

Hey Rich, a few questions:

  • each time the script is run, do you want to add another batch of items based on the number of items in Matrix1::B, or is this more like “please ensure the number of items in C matches the items in B”
  • For the population of the cells, are you wanting to reindex all the cells in Matrix2 each time the script is run, or only set the index for newly created values?
lyndseyweber Answered question October 30, 2023

Latest Questions

Qloud Losing Formatting 4 Answers | 0 Votes
Meditation on timelines 3 Answers | 0 Votes