home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / os2 / etelr212 / cnvtdatf.vrm next >
Text File  |  1994-08-12  |  4KB  |  116 lines

  1. /**********************************************/
  2. /* VX-Rexx macro to convert old .dat files    */
  3. /* Please do not modify                       */
  4. /**********************************************/
  5. /* Custom mainline for macro */
  6.  
  7.     call RXFuncAdd "VRLoadFuncs", "VROBJ", "VRLoadFuncs"
  8.     call VRLoadFuncs
  9.  
  10.     _VREVersion = SubWord( VRVersion( "VRObj" ), 1, 1 )
  11.     if( _VREVersion < 2.02 )then do
  12.         call VRMessage "", "This program requires VX-REXX version 2.0b to run.", "Error!"
  13.         return 32000
  14.     end
  15.  
  16.     signal on SYNTAX name _VRESyntax
  17.     signal _VREMain
  18.  
  19. _VRESyntax:
  20.     parse source . . _VRESourceSpec
  21.     call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL, "Error!"
  22.     exit 32000
  23.  
  24. _VREMain:
  25. /*:VRX         Main
  26. */
  27. Main:
  28. parse arg DatFile .
  29. /***********************************************************\
  30.  This routine converts the [Credit]...[Charge] sections in
  31.  the info.dat and number.dat files so that a CCard transaction
  32.  bears the prefix 'C' and a Bank transaction, the prefix 'B'
  33. \***********************************************************/
  34. call stream DatFile, 'c', 'open'
  35. call stream DatFile, 'c', 'seek =1'
  36. B.0 = 0     /* Bank Account */
  37. BCount = 1
  38. C.0 = 0     /* CCard Account */
  39. CCount = 1
  40. do forever
  41.     if( lines( DatFile ) = 0 )then
  42.         leave
  43.     line = linein( DatFile )
  44.     if line = '[Credit]' then do
  45.         do forever
  46.             line = linein( DatFile )
  47.             if( lines( DatFile ) = 0 )then
  48.                 leave
  49.             if( line = '' | line = '[Debit]' | line = '[Payment]' | line = '[Charge]' )then
  50.                 leave
  51.             b.bcount = 'B'line
  52.             b.0 = bcount
  53.             bcount = bcount + 1
  54.         end
  55.     end
  56.     if line = '[Debit]' then do
  57.         do forever
  58.             line = linein( DatFile )
  59.             if( lines( DatFile ) = 0 )then
  60.                 leave
  61.             if( line = '' | line = '[Credit]' | line = '[Payment]' | line = '[Charge]' )then
  62.                 leave
  63.             if( POS( 'INFO.DAT', Translate( DatFile ) ) <> 0 )then do
  64.                 parse var line info '$' amount '~' memo '^' cat
  65.                 amount = '-'||amount
  66.                 line = info'$'amount'~'memo'^'cat
  67.                 drop info amount memo cat
  68.             end
  69.             b.bcount = 'B'line
  70.             b.0 = bcount
  71.             bcount = bcount + 1
  72.         end
  73.     end
  74.     if line = '[Payment]' then do
  75.         do forever
  76.             line = linein( DatFile )
  77.             if( lines( DatFile ) = 0 )then
  78.                 leave
  79.             if( line = '' | line = '[Debit]' | line = '[Credit]' | line = '[Charge]' )then
  80.                 leave
  81.             c.ccount = 'C'line
  82.             c.0 = ccount
  83.             ccount = ccount + 1
  84.         end
  85.     end
  86.     if line = '[Charge]' then do
  87.         do forever
  88.             line = linein( DatFile )
  89.             if( lines( DatFile ) = 0 )then
  90.                 leave
  91.             if( line = '' | line = '[Credit]' | line = '[Payment]' | line = '[Debit]' )then
  92.                 leave
  93.             if( POS( 'INFO.DAT', Translate( DatFile ) ) <> 0 )then do
  94.                 parse var line info '$' amount '~' memo '^' cat
  95.                 amount = '-'||amount
  96.                 line = info'$'amount'~'memo'^'cat
  97.                 drop info amount memo cat
  98.             end
  99.             c.ccount = 'C'line
  100.             c.0 = ccount
  101.             ccount = ccount + 1
  102.         end
  103.     end
  104. end
  105. call stream DatFile, 'c', 'close'
  106. call VRDeleteFile DatFile
  107. do i = 1 to b.0
  108.     call lineout DatFile, b.i
  109. end
  110. do i = 1 to c.0
  111.     call lineout DatFile, c.i
  112. end
  113. call stream DatFile, 'c', 'close'
  114. exit
  115.  
  116.