[gradsusr] Day of week showing ???
Howard Staines
rossby at rossby.co.nz
Sat Jan 2 18:19:14 EST 2021
Re Day of the week showing ???
I have a workaround that will work for 2021
When creating strings for labels for graphics
‘q time’
….
At the end of the string creation for Month, Year etc my string for year is ‘yearnum’
* code work around for 2021 correcting daystr error
if yearnum = "2021"
daystr = daystring( monstr, datenum)
endif
daystring() is a function at the bottom of the script it takes two arguments monstr (a string for the month)
and datenum (the current day of the month as a number.
The function finds the day of the week name for the current date and returns this.
Does this by finding the month, if statement gets the 1st day of every month as a position in an array. MON is position 1 etc. The loop is used to move from the 1st day of the month till you reach the date in question. Then using the array you are able to return the day of the weeks name. Works well.
Trust this helps.
The function
***********************************************
function daystring( monstr, datenum)
monname = subwrd (monstr,1)
daynum = subwrd (datenum,1)
if (monname = JAN)
cposition = 5
endif
if (monname = FEB)
cposition = 1
endif
if (monname = MAR)
cposition = 1
endif
if (monname = APR)
cposition = 4
endif
if (monname = MAY)
cposition = 6
endif
if (monname = JUN)
cposition = 2
endif
if (monname = JUL)
cposition = 4
endif
if (monname = AUG)
cposition = 7
endif
if (monname = SEP)
cposition = 3
endif
if (monname = OCT)
cposition = 5
endif
if (monname = NOV)
cposition = 1
endif
if (monname = DEC)
cposition = 3
endif
while (daynum > 1)
cposition = cposition + 1
** end array correction
if cposition > 7
cposition = 1
endif
daynum = daynum - 1
endwhile
* Calculate the day name
dayarray = 'MON TUE WED THU FRI SAT SUN ????'
dayname = subwrd(dayarray,cposition)
return dayname
regards Howard Staines
Metris forecaster New Zealand.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20210103/3f6113ed/attachment.html>
More information about the gradsusr
mailing list