Subject: | |
From: | |
Reply To: | Dave Powell, MMfab |
Date: | Fri, 4 Dec 2009 13:11:57 -0800 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
This is the most important one, at least at MMfab. Have fun.
:print realdays.func.shr;page=0
option nolist
parm NUM_DAYS = 0 NOISE_LEVEL = 0
if bound (RDS_ERRORS)
deletevar RDS_@
endif
setvar RDS_ERRORS 0
if not numeric ("0!NUM_DAYS")
setvar RDS_ERRORS RDS_ERRORS + 1
echo 1st input must be digits only, number of work days we need
elseif !NUM_DAYS = 0
setvar RDS_ERRORS RDS_ERRORS + 1
echo 1st input (number of work days we need) is required,
echo and must be at least 1, never 0
elseif !NUM_DAYS > 50
setvar RDS_ERRORS RDS_ERRORS + 1
echo 1st input (number of work days we need) &
can't be more than 50
endif
if not numeric ("0!NOISE_LEVEL")
setvar RDS_ERRORS RDS_ERRORS + 1
echo 2nd input must be numeric unless it is omitted
echo 0 = no displays (default)
echo 1 = display final result only
echo 2 or higher = also display each days's status
endif
if RDS_ERRORS > 0
echo **exiting and returning '7' (the programmer's guess)**
return 7
endif
setvar RDS_NEW_CYMD TOMORROW.FUNC.SHR(HPYYYYMMDD)
setvar RDS_CNT !NUM_DAYS
setvar I 0
while (setvar (I, I + 1) < 99) AND (RDS_CNT <> 0)
setvar RDS_HOLIDAY HOLIDAY.FUNC.SHR(RDS_NEW_CYMD)
setvar RDS_WORKDAY not (RDS_HOLIDAY or HOL_DOW=1 or HOL_DOW=7)
if RDS_WORKDAY
setvar RDS_CNT RDS_CNT - 1
endif
if !NOISE_LEVEL > 1
echo ![rht("00!I",3)] date=!RDS_NEW_CYMD&
; day-of-week=!TOM_NEXT_DOW !HOL_DOW&
; holiday=![lft("!RDS_HOLIDAY ", 5)]&
; workday=![lft("!RDS_WORKDAY ", 5)]
endif
if RDS_CNT = 0
if !NOISE_LEVEL <> 0
echo need !I calendar days to get !NUM_DAYS work-days
endif
return I
endif
setvar RDS_NEW_CYMD TOMORROW.FUNC.SHR(RDS_NEW_CYMD)
endwhile
setvar RDS_ERRORS 1
echo ** UNKNOWN ERROR, RETURNING "0" **
return 0
# REALDAYS Dave Powell, 06/11/2009
#
# Function to return the number of "real" calendar days it
# takes to have "x" regular work days.
#
# 1st function input parm is the number of work days we want.
# 2nd parm controls the amount of info it displays.
#
# Intended to use mostly with programs that use "PARM=n"
# to tell them how many days ahead to look.
#
# Example: a credit-expiration warning report where the
# humans want to report orders with expiration days within
# 2 days ahead. Call this function with "2" as the input
# and it would return the needed value of the parm.
#
# RUN MYROG; PARM=![REALDAYS.FUNC.SHR(2)], etc.
#
# Note: "0" as input is bad because:
# - This rtn should be called only when we need some
# specific (non-zero) number of work days and need to
# to know how many calendar days that will take (zero is
# meaningless input)
# - Return value of this function may be used as parm
# telling one of our apps how many days ahead to look, but
# most such apps at MMfab use PARM=0 to tell them to
# report everything regardless of date.
#
# This rtn treats Sat & Sun as non-work days. Sites that
# work Saturdays will need to tweak the logic.
#
# Dependencies: HOLIDAY.FUNC.SHR
# TOMORROW.FUNC.SHR
# (locations are hard-coded, and don't need to be in the
# path, but sites that don't want to create a "FUNC.SHR"
# group & acct will need to tweak the fine-print).
#
# --------------------------------------------------
# To do:
#
#
# --------------------------------------------------
# See also: HOLIDAY.FUNC.SHR, TOMORROW.FUNC.SHR
# HOLITEST.TESTCMD.SHR WORKDAYS.FUNC.SHR
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|
|
|