Not exactly one line, but this works for all the combinations I could think of:
function incTo x,i -- increments x to the next i if i = 0 then return x else if x mod i <> 0 and x * i < 0 then return x div i * i else return x div i * i + i end if end incTo Here's my test results. First column is x, second is i, third is expected result, fourth is actual result, fifth is whether test passed: 30 20 40 40 true 20 20 40 40 true 30 -20 20 20 true 40 -20 20 20 true -30 20 -20 -20 true -20 20 0 0 true -30 -20 -40 -40 true -20 -20 -40 -40 true 0 20 20 20 true 0 -20 -20 -20 true -30 0 -30 -30 true _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode