-> doesn't work?!

Here is my script:
{
:local todate [/system clock get date];

$day is a string. It may have a preceeding 0.

:local day [:tonum [:pick $todate 4 6]];

$month = 3-letter month name; $mon = month number.

:local months (“jan”,“feb”,“mar”,“apr”,“may”,“jun”,“jul”,“aug”,“sep”,“oct”,“nov”,“dec”);
:local month [:pick $todate 0 3];
:local mon [:tonum ([ :find $months $month -1 ] + 1)];

$longyr = 4-digit year; shortyr = 2-digit year; year = 1-digit year.

:local longyr [:tonum [:pick $todate 7 11]];
:local shortyr [:tonum [:pick $todate 9 11]];
:local year [:tonum [:pick $todate 10 11]];
:local msg;
:set $msg “$todate is day $day of month $mon of $longyr.”; :put $msg;
#Julian Date
:local julian ($day);
:if ($mon>1) do={ :set $julian ($julian+31);}
:if ($mon>2) do={ :set $julian ($julian+28); :if (($shortyr%4)=0) do={ :set $julian ($julian+1);} }
:if ($mon>3) do={ :set $julian ($julian+31);}
:if ($mon>4) do={ :set $julian ($julian+30);}
:if ($mon>5) do={ :set $julian ($julian+31);}
:if ($mon>6) do={ :set $julian ($julian+30);}
:if ($mon>7) do={ :set $julian ($julian+31);}
:if ($mon>8) do={ :set $julian ($julian+31);}
:if ($mon>9) do={ :set $julian ($julian+30);}
:if ($mon>10) do={ :set $julian ($julian+31);}
:if ($mon>11) do={ :set $julian ($julian+30);}
:set $msg “$todate is day $julian of the year.”; :put $msg;

Weekday Calculation: 0 is Sunday. 1 January 2000 was a Saturday or the 6th day of the week. We calculate Leapyear offsets starting at the end of the year, so starting in 2001.

:local weekday ((($julian+6+($shortyr*365)+(($shortyr-1)/4))%7));
:local week {“Sunday”,“Monday”,“Tuesday”,“Wednesday”,“Thursday”,“Friday”,“Saturday”};
:local dofw; :set $dofw ($week->$weekday);

Correct weekday so that 1 is Sunday.

:set $weekday ($weekday+1);
#print a message
:set $msg “$todate is day $weekday of the week and is a $dofw.”; :put $msg;
}

And here is the output:
sep/03/2020 is day 3 of month 9 of 2020.
sep/03/2020 is day 247 of the year.
sep/03/2020 is day 5 of the week and is a .

The value for $dofw is obviously empty instead of “Thursday”. So what I can I do to assign the string indexed by $weekday in $week to $dofw?
/system routerboard print
routerboard: yes
model: CCR1016-12G
serial-number: 42D50262CE86
firmware-type: tilegx
factory-firmware: 3.10
current-firmware: 3.39
upgrade-firmware: 6.47.2

Hello,

Use semicolon instead of comma:
:local week {“Sunday”;“Monday”;“Tuesday”;“Wednesday”;“Thursday”;“Friday”;“Saturday”};

That works!

Corrected script:
{
:local todate [/system clock get date];

$day is a string. It may have a preceeding 0.

:local day [:tonum [:pick $todate 4 6]];

$month = 3-letter month name; $mon = month number.

:local months {“jan”;“feb”;“mar”;“apr”;“may”;“jun”;“jul”;“aug”;“sep”;“oct”;“nov”;“dec”};
:local month [:pick $todate 0 3];
:local mon [:tonum ([ :find $months $month -1 ] + 1)];

$longyr = 4-digit year; shortyr = 2-digit year; year = 1-digit year.

:local longyr [:tonum [:pick $todate 7 11]];
:local shortyr [:tonum [:pick $todate 9 11]];
:local year [:tonum [:pick $todate 10 11]];
:local msg;
:set $msg “$todate is day $day of month $mon of $longyr.”; :put $msg;
#Julian Date
:local julian ($day);
:if ($mon>1) do={ :set $julian ($julian+31);}
:if ($mon>2) do={ :set $julian ($julian+28); :if (($shortyr%4)=0) do={ :set $julian ($julian+1);} }
:if ($mon>3) do={ :set $julian ($julian+31);}
:if ($mon>4) do={ :set $julian ($julian+30);}
:if ($mon>5) do={ :set $julian ($julian+31);}
:if ($mon>6) do={ :set $julian ($julian+30);}
:if ($mon>7) do={ :set $julian ($julian+31);}
:if ($mon>8) do={ :set $julian ($julian+31);}
:if ($mon>9) do={ :set $julian ($julian+30);}
:if ($mon>10) do={ :set $julian ($julian+31);}
:if ($mon>11) do={ :set $julian ($julian+30);}
:set $msg “$todate is day $julian of the year.”; :put $msg;

Weekday Calculation: 0 is Sunday. 1 January 2000 was a Saturday or the 6th day of the week. We calculate Leapyear offsets starting at the end of the year, so starting in 2001.

:local weekday ((($julian+6+($shortyr*365)+(($shortyr-1)/4))%7));
:local week {“Sunday”;“Monday”;“Tuesday”;“Wednesday”;“Thursday”;“Friday”;“Saturday”};
:local dofw; :set $dofw ($week->$weekday);

Correct weekday so that 1 is Sunday.

:set $weekday ($weekday+1);
#print a message
:set $msg “$todate is day $weekday of the week and is a $dofw.”; :put $msg;
}

New Output:
sep/04/2020 is day 4 of month 9 of 2020.
sep/04/2020 is day 248 of the year.
sep/04/2020 is day 6 of the week and is a Friday.