define script expression

Post Reply
MTswitch
Newbie
Posts: 12
Joined: Fri Aug 23, 2019 3:18 pm

define script expression

Post by MTswitch » Fri Aug 23, 2019 3:59 pm

Hi!

maybe someone can help me write the script expression in switch on a condition with variables.
I would like to compare the Proper Job Name (it is: "2019_08_23") with the scripted comparison value like this:

var pubdate = new Date();
var pubdateday = pubdate.getDate()+"";
var edd = pubdateday
if (edd < 10)
{
edd = "0" + pubdateday;
}
else
{
edd = pubdateday;
};
var pubdatemonth = (pubdate.getMonth()+1)+"";
var edm = pubdatemonth
if (edm < 10)
{
edm = "0" + pubdatemonth;
}
else
{
edm = pubdatemonth;
};
var pubdateyear = (pubdate.getYear()*1 +1900)+"";
var today = pubdateyear + "_" + edm + "_" + edd;
pubdate = today;

The scripted value "pubdate" is correct "2019_08_23" but I think I have to tell switch, that the Proper Job Name is meant?!

thx all for your help!

jan_suhr
Advanced member
Posts: 446
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: define script expression

Post by jan_suhr » Fri Aug 23, 2019 5:13 pm

I know it is fun to do scripting.

There is an app that do what you seem to want to accomplish. And it is FREE

https://www.enfocus.com/en/appstore/pro ... calculator
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps

MTswitch
Newbie
Posts: 12
Joined: Fri Aug 23, 2019 3:18 pm

Re: define script expression

Post by MTswitch » Mon Aug 26, 2019 7:19 pm

Hi Jan,

thanks for your answer!
That helped!!!

Where I would have liked to know why the script didn't work or how the correct settings would have been.
The Proper Job Name and the script expression string should have the same value (=2019_08_23). But why is the comparsion not true...?

greetings.

marc.

jan_suhr
Advanced member
Posts: 446
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: define script expression

Post by jan_suhr » Mon Aug 26, 2019 10:51 pm

The date you have is in String format, to do calculation on the dates you have to parse that string in to a number. That number is in milliseconds starting on 1st of January 1970.

When you have got your resulting number you can then create a date string from it.

https://www.enfocus.com/manuals/Develop ... _date.html
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps

MTswitch
Newbie
Posts: 12
Joined: Fri Aug 23, 2019 3:18 pm

Re: define script expression

Post by MTswitch » Tue Aug 27, 2019 8:01 pm

Hi Jan,

but isn't my string result fine?
I deliberately change the date value to a string.
the script result is than 2019_08_23 and the proper job name ist also 2019_08_23
both are strings.
Now, when i compare these two values, the result should be true.
or am I wrong?

Post Reply