home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / os2 / etelr212 / frmtdate.vrm < prev    next >
Text File  |  1994-09-10  |  2KB  |  70 lines

  1. /***********************************************/
  2. /* VX-Rexx Macro to verify and format dates    */
  3. /* throughout E-Teller                         */
  4. /* Please do not modify                        */
  5. /***********************************************/
  6. /* Custom mainline for macro */
  7.  
  8.     call RXFuncAdd "VRLoadFuncs", "VROBJ", "VRLoadFuncs"
  9.     call VRLoadFuncs
  10.  
  11.     _VREVersion = SubWord( VRVersion( "VRObj" ), 1, 1 )
  12.     if( _VREVersion < 2.02 )then do
  13.         call VRMessage "", "This program requires VX-REXX version 2.0b to run.", "Error!"
  14.         return 32000
  15.     end
  16.  
  17.     signal on SYNTAX name _VRESyntax
  18.     signal _VREMain
  19.  
  20. _VRESyntax:
  21.     parse source . . _VRESourceSpec
  22.     call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL, "Error!"
  23.     exit 32000
  24.  
  25. _VREMain:
  26. /*:VRX         Main
  27. */
  28. Main:
  29. parse upper arg date form
  30. position = Pos( "/", date, 1 ) 
  31. if position = 0 then 
  32.     signal DateFormatError
  33. if Pos( '/', date, position + 1 ) = 0 then 
  34.     signal DateFormatError
  35. if form = 'O' then
  36.     parse var date year '/' month '/' day
  37. if form = 'E' then
  38.     parse var date day '/' month '/' year
  39. if form = 'U' then
  40.     parse var date month '/' day '/' year
  41. if month > 12 then 
  42.     signal DateFormatError
  43. if day > 31 then 
  44.     signal DateFormatError
  45. if Length( year ) = 1 then 
  46.     year = '0'||year
  47. if Length( month ) = 1 then 
  48.     month = '0'||month
  49. if Length( day ) = 1 then 
  50.     day = '0'||day
  51. if form = 'O' then
  52.     rc = year||'/'||month||'/'||day
  53. if form = 'E' then
  54.     rc = day||'/'||month||'/'||year
  55. if form = 'U' then
  56.     rc = month||'/'||day||'/'||year
  57. call VRMethod 'Application', 'PutVar', 'rc'
  58. exit
  59.  
  60. DateFormatError:
  61. if form = 'O' then
  62.     call VRMessage "", "Incorrect date format -- yy/mm/dd  ", "Warning"
  63. if form = 'U' then
  64.     call VRMessage "", "Incorrect date format -- mm/dd/yy  ", "Warning"
  65. if form = 'E' then
  66.     call VRMessage "", "Incorrect date format -- dd/mm/yy  ", "Warning"
  67. rc = 'ERROR'
  68. call VRMethod 'Application', 'PutVar', 'rc'
  69. exit
  70.