Operating System - OpenVMS
1753332 Members
5389 Online
108792 Solutions
New Discussion юеВ

Re: submiting a job based on the day of the week

 
John Gillings
Honored Contributor

Re: submiting a job based on the day of the week

re: selection control structure depending on weekday...

For slightly more language independence give the work to DCL. You can code for several languages (but *complete* language independence might be a bit voluminous) like this:

$ ON WARNING THEN GOTO UnexpectedDay
$ GOTO DAY_'F$CVTIME(,,"WEEKDAY")
$ UnexpectedDay:
$ ! Error Trap
$ EXIT
$ ...
$ DAY_Sunday:
$ DAY_Saturday:
$ DAY_Dimanche:
$ DAY_weekend-in-your-language:
$ ! Weekend branch
$ GOTO BackToMainLine
$
$ DAY_Monday:
$ DAY_Tuesday:
$ DAY_Wednesday:
$ etc...
$ ! Weekday branch
$ GOTO BackToMainLine

If you're running V8.2 or higher, there are more options. Specifically we can eliminate all language dependencies.

1-JAN-1990 was a Monday, so:

$ J=F$DELTA("1-JAN-1990",F$TIME())
$ D=J-J/7*7

will return 0 for Monday, 1 for Tuesday etc... So your test for a weekend day becomes simply:

$ IF D.GE.5
$ THEN
$ ! weekend branch
$ ELSE
$ ! weekday branch
$ ENDIF

WARNING - since Delta times are limited to 10000 days, the above code will fail for dates after May 2017.

I think I'll a suggestion that F$CVTIME(date,"COMPARISON","WEEKDAY") should return a number...
A crucible of informative mistakes
Hein van den Heuvel
Honored Contributor

Re: submiting a job based on the day of the week

>> 1-JAN-1990 was a Monday, so:
>>
>> $ J=F$DELTA("1-JAN-1990",F$TIME())
>> $ D=J-J/7*7

Ah... My kinda thinking, but I did not have V8 to try. Good.


>> the above code will fail for dates after May 2017.

or you could just start closer in.


>> I think I'll a suggestion that F$CVTIME(date,"COMPARISON","WEEKDAY") should return a number...

I suppose you could call it a a low impact bug, as "MONTH" already does the right thing for ABS vs COMPARE


Cheers,
Hein.
John Gillings
Honored Contributor

Re: submiting a job based on the day of the week

Hein,

>I suppose you could call it a a low impact bug, as "MONTH" already does the right thing for ABS vs COMPARE

Unfortunately it's not quite as simple as it seems at first. The default output format is "COMPARISON", so to do this in a safe, upwards compatible manner, we'd have to change the default output format for "WEEKDAY" to "ABSOLUTE" and return numeric values only if the output format was explicitly "COMPARISON". It's probably more difficult to describe in the documentation than actually implement...
A crucible of informative mistakes
patricia_28
New Member

Re: submiting a job based on the day of the week

Hi to All,
Sorry I didn't reply sooner. Thank you for all your responses. I "TRULY" appreciate the help. I won't be able to work on this issue until Monday. Bosses are always changing priorities. I will keep you posted on my progress. Thanks again.

Sincerely,
Pat
Robert Gezelter
Honored Contributor

Re: submiting a job based on the day of the week

Hein,

(Smile) Perhaps I was unclear, I did write that response in a hurry.

I meant to say:
- If you find "Saturday" or "Sunday", then you are ok.
- If no string matches, take some appropriate action (error message: "Language not English"... If I had the time, I would delve into the multi-language support, my recollection is that there is a clean way to tell if your language is English, but it should not be too hard to find in the manual.

- Bob Gezelter, http://www.rlgsc.com
Doug Graver
Occasional Advisor

Re: submiting a job based on the day of the week

$ show logical sys$language

(LNM$SYSTEM_TABLE)

"SYS$LANGUAGE" = "ENGLISH"

Lawrence Czlapinski
Trusted Contributor

Re: submiting a job based on the day of the week

It would be nice if VMS had a logical for weekend, weekend_day_1 and weekend_day_2 since system managers often have to create DCL which checks for weekend, Saturday, or Sunday.
A freeware international solution of the day of week might include something like this using symbols:
$! Is_Weekend.com
$! Defines weekend names.
$weekend==""
$weekend_day_1=""
$weekend_day_2=""
$if (f$trnlnm("SYS$LANGUAGE")) .eqs. "ENGLISH"
$THEN
$ weekend_table=="Saturday,Sunday"
$ weekend_day_1=="Saturday"
$ weekend_day_2=="Sunday"
$ELSE
$! Non-English Customizations
$ENDIF
.
.
.
$exit

or it could be done with system logicals.

Robert_Boyd
Respected Contributor

Re: submiting a job based on the day of the week

You don't have to wait for V8.2 to take advantage of F$DELTA_TIME -- it's already in V7.3-2

Cheers,
Robert
Master you were right about 1 thing -- the negotiations were SHORT!