Main siteMain site  ForumForum  ForumSearch  Private messageEmail contact  RegisterRegister  Log inLog in 
Topic: Object expressions
Reply to topic
Author Message
GMartin



Joined: Feb 5, 2010
Posts: 308

PostPosted: Sep 20, 2021 12:16 PM    Post subject: Object expressions

Jarek.
I am not at all familiar with use of the object expression evaluator. I would like to set up a function so that when the current date from OSinfo is past a particular date, an action will be triggered. Could you give me some advice on how to accomplish this

Thanks

George
jarek



Joined: Oct 22, 2007
Posts: 913

PostPosted: Sep 20, 2021 3:32 PM    Post subject:

I wouldn't use OSInfo for that. That date there is useful as text. If you want to use date/time for further processing, here is what you can put in a Scalar ExpressionEvaluator:

try {
Out1 = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2021/9/20 14:25:00").after(new java.util.Date()) ? 1 : 0;
} catch (Exception ex) {
Out1 = -1;
}

This will send out 1 (TRUE) if your date/time text is after the current time when you execute it (for every input sample sent to ExpressionEvaluator, for example connect Button to its input).

There is many ways how this can be done (for example, you might use "before" instead "after" in the above expression) but it should give you an idea.

Let me know if I can clarify that more. This example here involves java code, so can be considered advanced. But it should get the job done with just a few lines (copy/paste) like above.
Reply to topic