home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
fdater.zip
/
DRIVER.REX
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-04-29
|
3KB
|
113 lines
signal on novalue
BaseDate = Date("B")
DO FOREVER
"cls"
say "┌─────────────────────────────────────────────────────────────────────────────┐"
say "│ DATE CONVERSION USING FDATER │"
say "│─────────────────────────────────────────────────────────────────────────────│"
say "│ │"
say "│ Base date from previous conversion:" left(BaseDate,34) "│"
say "│ │"
say "│ C Calendar date to base date │"
say "│ │"
say "│ B Base date to calendar date │"
say "│ │"
say "└─────────────────────────────────────────────────────────────────────────────┘"
call charout, "Select function letter, or press ENTER to exit> "
pull choice .
choice = left(choice,1)
select
when choice = "B" then call Base2Cal
when choice = "C" then call Cal2Base
when choice = "" then do; "cls"; exit ; end
otherwise
say "Invalid choice:" choice
end /*select*/
END /*DO FOREVER*/
EXIT
Base2Cal:
default = BaseDate
say "Enter base date as a number (0-999999)"
call charout , "or press ENTER to take default of:" default "> "
pull answer .
if answer = "" then BaseDate = default
else BaseDate = answer
do forever
if IsInRange( BaseDate, 0, 9999999 ) then LEAVE
pull answer .
if answer = "" then BaseDate = default
else BaseDate = answer
end
result = FdateR("Base2Cal", BaseDate)
parse var result CalYear CalMonth CalDay .
MonthName = FdateR("Monthname", Calmonth)
DowNum = FdateR("DowNum", BaseDate )
DowName = FdateR("DowName" , Downum )
IsLeapYear = FdateR("IsLeapYear", CalYear)
if IsLeapYear then LY = "(a leap year)"
else LY = " (not a leap year)"
say
say "Calendar date (mm/dd/ccyy):" Calmonth"/"CalDay"/"CalYear LY
say "Calendar date :" DowName CalDay MonthName CalYear
say
"pause"
RETURN
Cal2Base:
call charout ,"Enter day (number from 1 to 31 ) > "
pull CalDay .
do forever
if IsInRange( CALDAY, 1, 31 ) then LEAVE
pull CalDay .
end
call charout ,"Enter month (number from 1 to 12 ) > "
pull CalMonth .
do forever
if IsInRange( CalMonth , 1, 12 ) then LEAVE
pull CalMonth .
end
call charout ,"Enter year (number from 1 to 9999) > "
pull Calyear .
do forever
if IsInRange( CALYEAR, 1, 9999 ) then LEAVE
pull Calyear .
end
BaseDate = FdateR("Cal2Base", CalYear CalMonth CalDay)
say
say "Base date is:" BaseDate
say
"pause"
RETURN
IsInRange: procedure
invalue = arg(1)
lbound = arg(2)
ubound = arg(3)
if \datatype(invalue,"W") then do
say " ERROR: input value is not an integer."
call charout , " Please try again.> "
RETURN 0
end
if invalue < Lbound | invalue > ubound then do
say " ERROR: input value is not in range" lbound"-"ubound
call charout , " Please try again.> "
RETURN 0
end
RETURN 1