Action on evert n-th event

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
EvelineHermans
Posts: 28
Joined: Tuesday 28 July, 2015 - 10:34

Action on evert n-th event

Post by EvelineHermans »

Hi,

I am wondering if it is possible to simplify my code. I want to regulary close two inputchannels, to which I already made a reference. At every 150th output, I want to shortly open these two inputchannels. Now I write the code for the 150th and 300th output separately, but as I want to generate thousands of products, I assume this is not the most simple way to write my 4DScript.

The script I use now is:

Code: Select all

Do(
 If(
 output(c)=150,OpenInput(refAtom1),CloseInput(refAtom1)
 ),
 If(
 output(c)=150,OpenInput(refAtom2),CloseInput(refAtom2)
 ),
 If(
 output(c)=300,OpenInput(refAtom1),CloseInput(refAtom1)
 ),
 If(
 output(c)=300,OpenInput(refAtom2),CloseInput(refAtom2)
 )  
 )
Is there someone who can help me out :)?

Thanks!

Eveline
EvelineHermans
Posts: 28
Joined: Tuesday 28 July, 2015 - 10:34

Re: Action on evert n-th event

Post by EvelineHermans »

I was too fast in asking.. sorry.
I found the answer already in one of the predefined functions in another atom :)

Code: Select all

mod(output(c),150)
Post Reply