Hello everyone,
I have a problem with this:
I have for example 4 registers, and I just want one(local!contador), and inside of foreach, I have some conditions.
Well, I dont know how decrement local!contador for my condition in AND, i.e., if I just want one register(fv!item) I want to decrement the variable local!contador but I dont know how do it.
Someone can help me please?
Thank you so much.
Discussion posts and replies are publicly visible
You can't decrement external values from within a loop of a!forEach.
If I understand correctly what you're trying to do, I would just store the results of your a!forEach loop in a local variable (for example) and then get the first index (to get the result in the first position of the array), e.g. "local!results[1]", or "index(local!results, 1, {})".
Hello, thank you for answer.
I tried index but doesnt work for me, becuase the number of registers I need change, can be 1, 2, 3... not is always 1.
If I assume correctly that local!contador will be the number of entries you want to return, this is still pretty easy to do:
index( local!results, enumerate(local!contador)+1, /* if contador=3, this will return array like {1,2,3} */ null() )
Thank you, but doesnt work,just give me One register, i think because just do the loop one time
What is the value you're passing in for ri!register? Your code as written should be doing one loop for each item in that. So if you only pass in 1, it will only do the forEach loop once.
Use enumerate give me one idea, and its works:
In the end of the rule, i applied this and works. Thank you so much Mike
No prob - glad to help ;-)