adding and deleting time scales

5.69K viewsScripting
0

Same issue different model.

Thgis creates a non destructive method of adding to a time scale where entries may have taken place. The adding of time works but deleting does not. Any ideas what I am doing wrong.

Also documentation would be helpful.

script below and file attached.
——————————————————————-
void perform()
{
def currentConstruction = (int) |Matrix1::Construction|.children.size()
def currentPerformance = (int) |Matrix1::Performance|.children.size()

def desiredConstruction = (int) |Matrix2::Construction|.value;
def desiredPerformance = (int) |Matrix2::Performance|.value;

if(desiredConstruction > currentConstruction)
{
|Matrix1::Construction|.children.createAt(0,(-desiredConstruction)..<(-currentConstruction)).each {name = “”Month “” + name ;}
}
else if(desiredConstruction < currentConstruction)
{
|Matrix1::Construction|.children.get((-currentConstruction)..<(-desiredConstruction)).delete()
}

if(desiredPerformance > currentPerformance)
{
|Matrix1::Performance|.children.create((currentPerformance+1)..desiredPerformance).each {name = “”Month “” + name ;}
}
else if(desiredPerformance < currentPerformance)
{
|Matrix1::Performance|.children.get((desiredPerformance+1)..currentPerformance).delete()
}
}

boolean enabled()
{
return !(|Matrix1::Construction|.children.size() == |Matrix2::Construction|.value
&& |Matrix1::Performance|.children.size() == |Matrix2::Performance|.value);
}

Attachments

script.model
0

Hi Simon,

You have just uncovered my lazyness to dive into the nice features Groovy has :) ! Thank you for this hint, it is very interesting.

The source of my bias to for loops is more coming from Java than von VBA. You can nearly copy / paste Java code into the Groovy editor in Quantrix and use the code without much modification. Remember: This is called lazyness :D !

Dominik

You are viewing 1 out of 6 answers, click here to view all answers.