How to extract the day of the week in a post-processor
If for whichever reason, the current day of the week (Monday through Sunday) is required to be known or printed as a comment in the NC program, here is a little utility that can extract this information from the system and make it available to the post-processor. It can be inserted in a Machine Startup Macro:
$$ DAY OF THE WEEK
$$
$$ -> Abbreviated day of week
DECLAR/STRING,TMPFILE,WKDAY $$ Declare string variables
TMPFILE=$FGETENV('TMP')//'\date.txt' $$ Name of temporary file
SYSTEM/'date /T > '//TMPFILE $$ Run 'date /T' saving to file
OPEN/21,TMPFILE $$ Open the file
READ/21,'!(a3)',WKDAY $$ Read first 3 characters
CLOSE/21 $$ Close the file
SYSTEM/'del '//TMPFILE $$ Run 'del' to delete the file
$$
$$ -> Day number of week (Sun=0,Mon=1,…,Sat=6)
DECLAR/REAL,DAYNO
DAYNO=$FINDEX('..MONTUEWEDTHUFRISAT',$FTOUPER(WKDAY))/3 $$ For English locale
$$
$$ -> Full day name (for English locale, otherwise please change)
DECLAR/DAYNAMES
DAYNAMES={'Sunday','Monday','Tuesday','Wednesday',$
'Thursday','Friday','Saturday'}
DECLAR/STRING,WEEKDAY
WEEKDAY=DAYNAMES(DAYNO+1) |