how to do a rule if attribute x ends in 1 then
can anybody pls tell me if it is possible to do a rule if attribute x ends in 1 then do action
Best Answers
-
RH Posts: 1,079
you can't directly create a rule that when x ends in 1 but you can create a new attribute that stores the end digit of an integer and create a rule that when that attribute = 1 do action.
for example:
create self.lastdigit
constrain or change self.lastdigit (depending on which is more appropriate) to x%10 - this returns the last digit of x
now create your rule that when self.lastdigit = 1 do action
I think this works up to a value of 999999, beyond that it returns self.lastdigit = 0 regardless of the actually value -
gyroscope I am here.Posts: 6,598
@haza
A neat way by @RH....
Another way would be to make another attribute that is Text (lets call it OneCheck) and change it to your number, (this will make it a string, but it doesn't matter) then see if it has a 1 is at the end. If it has, then you can take your action.
So:
Change attribute YourNumber to random(1,301) -- for instance; or however your number you want to check is being derived and whatever number range you require --
Change Attribute OneCheck to YourNumber
Rule: When OneCheck ends with 1
----your action""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps