home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / dongrovs.zip / tz1folder.CMD < prev   
OS/2 REXX Batch file  |  1996-10-16  |  5KB  |  182 lines

  1. /* Off-line Time/Date Stamp Modifyer for MR/2 ICE */
  2. /* ********************************* */
  3. /*   By: Jetnick Enterprise          */
  4. /*       Don E. Groves, Jr.          */
  5. /*   Contact Information:            */
  6. /*     E-mail: jetnick@erols.com     */
  7. /*        CIS: 71310,3702             */
  8. /* Date: 27 Aug 1996                  */
  9. /* ********************************** */
  10.  
  11.  /* Requires */
  12. parse source . invhow myName
  13. wrk = myname~substr(1,myname~lastpos('\'))
  14. tz1File = wrk~''('tz1File.cmd')
  15. call (tz1File)
  16.  
  17. RtCode = 0
  18. if invhow == 'COMMAND'
  19. THEN DO
  20.    RtCode = 1
  21.    elsp_counter = .Elasp_Time~NEW
  22.    say time()
  23.    Argv = .ARRAY_CLI~of(ARG(1), .false, .false) /* parse the arguments */
  24.    if Argv~items > 0
  25.    THEN DO
  26.       user_name = Argv[1]     /* get path to folder */
  27.       inbox2_file = .ndx_File~New(user_name~''("\")~''("folder.ndx"))
  28.       if \ inbox2_file~Exist
  29.       THEN inbox2_file = .ndx_File~New(user_name~''("\")~''("mr2i.ndx"))
  30.       if inbox2_file~Exist
  31.       THEN DO
  32.          say 'Working on:'~' '(inbox2_file~Qualify)
  33.          if Argv~items > 1
  34.          THEN fix = Argv[2]
  35.          else fix = ''
  36.          if fix=='fix'
  37.          then worker = .FixTimeZone~new
  38.          else worker = .DoTimeZone~new
  39.          inbox2_file~Doer(worker)   /* do the folder */
  40.          RtCode = 0
  41.       END
  42.       ELSE DO
  43.          SAY 'ERROR:'~' '(user_name)~' '('required  *.NDX file not found.')
  44.       END
  45.    END
  46.    else DO
  47.       /* future message concerning Commandline arguments goes here */
  48.    END
  49.    say elsp_counter
  50. END
  51. return RtCode
  52.  
  53. /* ************* */
  54. /* I could use the following, but then the support file would have to */
  55. /* be in the current directory or along the PATH. */
  56. /* ::requires Tz1File   */
  57. /* ************* */
  58.  
  59. ::class ndx_File_Base
  60. ::method init
  61.   expose fh inbuf curRec updated
  62.   use arg FileName
  63.   fh = .stream~new(FileName)
  64.   inbuf = .Array~new
  65.   updated = .false
  66.   curRec = -1
  67.   outbuf = .Array~NEW
  68. return self
  69. ::method Load
  70.   expose fh inbuf curRec updated
  71.   IF curRec = -1
  72.   THEN DO
  73.      curRec = 0
  74.      if self~Exist
  75.      THEN Do
  76.         fh~OPEN('READ')
  77.         inbuf= fh~makearray('LINE')
  78.         fh~close
  79.      END
  80.   END
  81. return (inbuf~items < curRec)
  82. ::method available
  83.   expose fh inbuf curRec updated
  84. return (inbuf~items < curRec)
  85. ::method Read
  86.   expose fh inbuf curRec updated
  87.   curRec = curRec + 1
  88. return inbuf[curRec - 1]
  89. ::method write
  90.   expose fh inbuf curRec updated
  91.   use arg what
  92.   updated = .true
  93.   inbuf[curRec] = what
  94. return what
  95. ::method close
  96.   expose fh inbuf curRec updated
  97.   IF updated
  98.   THEN do
  99.      /* make a backup copy of the orginal */
  100.      fn = self~Qualify
  101.      address cmd '@copy "'~''(fn)~''('" "')~''(fn)~''('-baz" >nul')
  102.      /* write out the new file data */
  103.      self~save_ea
  104.      fh~OPEN('WRITE REPLACE')
  105.      su = inbuf~supplier
  106.      do while su~available
  107.         fh~LINEOUT(su~item)
  108.         su~next
  109.      end
  110.      tmp = fh~close
  111.      self~Join_ea
  112.   END
  113. return tmp
  114. ::method exist
  115.   expose fh inbuf curRec updated
  116. return (fh~query('exist')~length \= 0)
  117. ::method Qualify
  118.   expose fh inbuf curRec updated
  119. return fh~qualify
  120. ::method Home
  121.   expose fh inbuf curRec updated
  122.   fn = self~Qualify
  123. return fn~substr(1,fn~lastpos('\'))
  124. ::method save_ea private
  125.   expose fh inbuf curRec updated
  126.   FileName = fh~query('exist')
  127.   fh~close
  128.   if FileName~length \= 0
  129.   THEN address cmd '@eautil.exe "'~''(fileName)~''('" "')~''(FileName)~''('-ea" /S')
  130. ::method join_ea private
  131.   expose fh inbuf curRec updated
  132.   FileName = fh~query('exist')
  133.   fh~close
  134.   if FileName~length \= 0
  135.   THEN if .Stream~new(FileName~''('-ea'))~Query('exist')~length \= 0
  136.   THEN address cmd '@eautil.exe "'~''(FileName)~''('" "')~''(FileName)~''('-ea" /J')
  137. ::method Size
  138.   expose fh inbuf curRec updated
  139. return fh~QUERY('SIZE')
  140.  
  141. ::class ndx_File subclass ndx_File public
  142. ::method Doer
  143.   use arg worker
  144.   .output~CharOut(' :')
  145.   IF Self~Load
  146.   THEN DO
  147.      home = Self~Home
  148.      do while self~available
  149.         wrk = 'S'
  150.         ln1 = Self~READ
  151.         /* break out the parts of the record we're interested in, only. */
  152.         name = Ln1~substr(28,8)
  153.         ext  = Ln1~substr(37,3)
  154.         IF ext == 'RCV'
  155.         THEN DO
  156.            /* w4  = Ln1~substr(54,8)  */ /* date yy/mm/dd */
  157.            /* white space */
  158.            /* w5  = Ln1~substr(63,5)  */ /* time hh:mm */
  159.            hDate = worker~work(Home~''(name)~''('.')~''(ext))
  160.            wrk = 'E'
  161.            if hDate \= .nil
  162.            THEN DO
  163.               wrk = '.'
  164.               /* format the DateTime object information into the proper format */
  165.               sda = hDate~DATE('O')~' '(hDate~TIME('N')~SUBSTR(1,5))
  166.               /* check if there not the same */
  167.               IF \ (Ln1~substr(54,14) == sda)
  168.               THEN DO
  169.                  ln1 = Ln1~substr(1,53)~''(sda)~''(Ln1~substr(68))
  170.                  Self~Write(ln1)
  171.                  wrk = '*'
  172.               END
  173.            END
  174.         END
  175.         .output~CharOut(wrk)
  176.      end
  177.      Self~Close
  178.   END
  179.   .output~LineOut('')
  180. return
  181.  
  182.