• ### [expr] logic problem – why is it doing this?

So, I'm working on a patch that is supposed to trigger a sound file to play on the hour and on the half between a specific start and end time.

I'm getting the time using zexy's [time] object. I'm then feed that into an [expr] object that's performing some basic logic to determine if the current time is between the specified start hour and end hour for playback, and either at the beginning of the hour or the beginning of the half hour, and the seconds are equal to zero. If all these conditions are true, the [expr] object outputs a 1, which then triggers the soundfile to play.

This expression looks like this:

expr if((\$f1 >= \$f4 && \$f1 <= \$f5) && (\$f2 == 30 || \$f2 == 0) && (\$f3 == 0), 1, \$f1)

where:
\$f1 is the current hour
\$f2 is the current minute
\$f3 is the current second
\$f4 is the start hour (this is currently set to 12 – i.e. noon)
\$f5 is the end hour (currently set at 18 – i.e. 6pm)

It works perfectly. However, if \$f1, \$f2, \$f3 are values like 1, 29, 32 (that's 01:29:32 in 24 hour time), the [expr] gives me true when it should be false! 01:29:32 is not within the specified start or end hour for playback.

I can't figure this out at the moment. I'm wondering if someone can help point out what dumb mistake I'm probably making.

Thanks

• Posts 6 | Views 153
• @me-andmymonkey It gives 1 because \$f1 is 1. Last entry should probably 0.

• duh! thank you for pointing out that very obvious mistake! @ingox

• To explain why the last entry is \$f1, I need to pass that number on for another operation if it doesn't meet any of the conditions. But of course that was the issue. I've changed the 'true' entry to a three digit number, that then gets caught by a [sel] object to trigger the soundfile.

• This post is deleted!
• This post is deleted!
Posts 6 | Views 153
Internal error.

Oops! Looks like something went wrong!