we have reports that we run for the period 2 months ago. This was working fine until the new year. I am missing something in the logic.
 Code:
$home = "K:\"
;$home = "c:\Reports\"
$setup = "\\server1\folder1\folder2\setup3.txt"
$source = "\\server2\folder21\folder22\folder23\folder24\"

;open txt file with file and folder names 
IF Open(1, "$setup") = 0
  $drfile = ReadLine(1)
  ELSE
  BEEP
  ? "setup3 file not opened, error code: [" + @ERROR + "]"
  sleep 5
  EXIT
ENDIF

$thismo = @monthno -2
IF $thismo = 0
  $month = "11" 
ELSE
  IF $thismo > 9
    $month = CSTR($thismo)
  ELSE
    $month = "0" + CSTR($thismo)
  ENDIF
ENDIF
$year = IIf(@MONTHNO = 1, @YEAR -1, @YEAR)

;open log file
IF Open(2, "\\server1\folder1\folder2\log$month.txt",5) = 0
  $w = WriteLine( 2 , "rpts3.kix started at " +@DATE + @TIME + Chr(13) + Chr(10) )
  ELSE
  BEEP
  ? "Error opening log file: [" + @ERROR + "]"
  sleep 5
  EXIT
ENDIF

;main program loop
WHILE $readerr = 0
$x = ReadLine(1)
$readerr = @ERROR
$file = SUBSTR($x, 1, INSTR($x, ",")-1)
$x = SUBSTR($x, INSTR($x, ",")+1, LEN($x) - INSTR($x, ","))
$directory = SUBSTR($x, 1, INSTR($x, ",")-1)
$x = SUBSTR($x, INSTR($x, ",")+1, LEN($x) - INSTR($x, ","))
$folder = SUBSTR($x, 1, LEN($x) - INSTR($x, ","))

;MD "$home$directory$folder\$year-$month"

sleep 1

IF Exist("$source$file.pdf")
   IF $folder <> ""
   copy "$source$file.pdf" "$home$directory$folder\$year-$month\$file.pdf"
   ENDIF
ENDIF

LOOP

$w = WriteLine( 2 , "rpts3.kix finished at " +@DATE + @TIME + Chr(13) + Chr(10) )

$ = Close (1)
$ = Close (2)




Last month - 2016-12, I ran the reports for october and they were placed correctly.
My logic for the new year has to off somewhere, because nothing is generating. This is the modified to run for November. The only change I made was to
 Code:
$thismo = @monthno -2
IF $thismo = 0
  $month = "11" ;; last month this was 12 and ran october reports.


Thanks!


Edited by Karon (2017-01-06 08:42 PM)