compileString or eval function

Would it be possible to have something like compileString or javascript eval() function. I’am looking for an easy way to externally define the content for an IF statement. In other words a string contains variable comparison statements that should be evaluated during runtime.

something like this:

The following string is given to the IMP, coming from an android app for example

extString = “(time > 0900) && (time < 1700) && !athome”

if (eval(extString)) lightsOff();

check out

When we compile Squirrel for the imp, we turn off the compiler part in order to get it to fit in the imp’s code space. So I’m afraid compilestring() is a non-starter. Either you need to invent your own way of specifying conditions (which I admit would be a little less flexible), or, as marcboon suggests, put the intelligence somewhere else.


Is a feature like this something that might be included in Agents in the future?

Looks like “pure” squirrel has a compilestring(string,[buffername]) function… is useful in many cases but I think not for this purpose. An agent could be a good alternative.