Hi Rebols,

I know probably everyody here is tired of
seeing newbie's troubles with FTP. But
there's no other place where I can ask for
help :)

The attached script crashes everytime
after the fourth
downloaded file and Windows issues the
following warning:

"REBOL caused an invalid page fault in
module KERNEL32.DLL at 015f:bff87eb5.
Registers:
EAX=c00300f0 CS=015f EIP=bff87eb5
EFLGS=00010212
EBX=00000000 SS=0167 ESP=0055fff4
EBP=00560060
ECX=00000000 DS=0167 ESI=815ec7e0 FS=3c1f
EDX=c00300f4 ES=0167 EDI=815ec9ec GS=0000
Bytes at CS:EIP:
53 56 57 8b 30 83 7d 10 01 8b 4e 38 89 4d
f8 75
Stack dump:"

What am I doing wrong? Can anyone test the
script for me?

Don't forget to create a folder c:\tvprog
(it's where the script dowloads the files
to)

Thank you very much

Carlos Lorenz
REBOL [
      title:   "LisTV" 
      file:    %listv.r
      date:    [10-jan-2000]
      lstupd:  [11-apr-2000]
      file:    "%listv.r"
        version: 1.0
        author:  "Carlos Lorenz" 
      email:   [EMAIL PROTECTED]
        purpose: {multiple dowloads from FTP site LisTV}
]

grids: [ 
          1 "CMT.TXT" "CMT"
          2 "CNE.TXT" "CNN Espanhol"
          3 "CNN.TXT" "CNN Int"
          4     "CUL.TXT" "CULTURA"
            5 "DWL.TXT" "DEUTSCHE WELLE"
          6 "DIK.TXT" "DISCOVERY KIDS"
            7 "DIS.TXT" "DISCOVERY"
          8 "ECO.TXT" "ECO"
          9 "EET.TXT" "E!"
         10 "ESB.TXT" "ESPN Brasil"
         11 "ESP.TXT" "ESPN Int"
         12 "EUR.TXT" "EUROCHANNEL"
         13 "BRA.TXT" "FILM & ARTS"
         14 "FOX.TXT" "FOX"
         15 "KID.TXT" "FOX KIDS"
         16 "FUT.TXT" "FUTURA"
         17 "GNT.TXT" "GNT"
         18 "HAL.TXT" "HALLMARK"
         19 "HBO.TXT" "HBO"
         20 "HB2.TXT" "HB2"
        ]

grid-search: make function! [series seek where] [
     grid: find series seek
     if where == "rec"  [ return first grid ]
     if where == "file" [ return second grid]
]

local-date: make function! [some-date [date!] ][
     months: [2 4 5 8 9 12]
     locale-months: ["-Fev-" "-Abr-" "-Mai-" "-Ago-" "-Set-" "-Dez-"]
     if found? find months some-date/month[ 
        return join some-date/day [pick locale-months 
                                   index? find months some-date/month some-date/year]
     ]
     return some-date
]

left: func [str num][copy/part str num]
right: func [str num][copy skip tail str negate num]
substr: func [str num length][copy/part at str num length]

user: "tvprog"
pass: "znerol01"

;remore server
site: to-url join "ftp://" [user ":" pass "@ftp.intermega.com.br/REBOL/Scripts/"]
sitedata: to-url join "ftp://" [user ":" pass "@ftp.intermega.com.br/REBOL/Txt/"]

; local server
;site: ftp://127.0.0.1/
;sitedata: ftp://127.0.0.1/txt/

print "^Lconnecting to FTP site TVProg"

either not exists? %../tvprog/lista.cf[

        print trim {^LAvailable TV Listings at LisTV: 

          1 CMT              10 ESPN Brasil
          2 CNN Espanhol     11 ESPN Int
          3 CNN Int          12 EUROCHANNEL
          4 CULTURA          13 FILM & ARTS
            5 DEUTSCHE WELLE   14 FOX
          6 DISCOVERY KIDS   15 FOX KIDS
            7 DISCOVERY        16 FUTURA
          8 ECO              17 GNT
          9 E!               18 HALLMARK
                             19 HBO  
                             20 HBO2 
        }              
    
        go-out: true

          print trim {Enter the code numbers of the lists you want to download 
separated by spaces.
                      For example: 05 20 24 34 78 04 and press <Enter>. 

                          In c:\tvprog\lista.cf you'll find the names of channels you 
chose.
                          To alter your selection just delete the file [lista.cf]
                    before running the script again.
                        
                    The downloaded lists will be saved in c:\tvprog\tvprog.txt.
                          }
          a: ask "Code numbers? : "

          if a == "" [quit]

        args: make block! parse a "-"
        
        print join newline ["Wait..." newline] 

        foreach arg args[
          if greater? arg "20" [
             arg: "20"
          ]
          if lesser? arg "0" [
             arg: "1"
          ]
          if equal? arg "0" [
             arg: "1"
          ]
          nfile: grid-search grids (to-integer arg) "file"   
            write/append %../tvprog/lista.cf join nfile newline
          files: make block! read %../tvprog/lista.cf 
        ]
][
        files: make block! read %../tvprog/lista.cf 
]

if error? try [write %../tvprog/tvprog.txt join read site/header.txt [newline 
newline]][
              print "^LDial-up connection error detected! Try to reconnect."   
              wait 3
              quit
]              

foreach file files [
      if (length? (to-string file)) < 7 [
          print "^LFile c:\tvprog\lista.cf corrupted!"
          print "Please delete it and run the script again."
          wait 4
          quit
      ]

      nfile: grid-search grids (to-string :file) "file"

      if error? try [arq: to-block find read sitedata/:file now/date][
            print "^/Transfer error detected. Try again."
            wait 3
            quit
      ]

      print arq

      forskip arq 4 [if (greater? second arq now/time)[
                         break
                     ]
              print arq
              wait 3
      ]
      
      break-date: local-date first arq

      if error? try[write/append %/c/tvprog/tvprog.txt join "Channel: " [nfile "^/^/" 
"Date: " break-date newline newline]][
             print "^/I/O error detected while saving file. Try again."
             wait 3
             quit
      ]

      forskip arq 4 [
           if (break-date <> local-date first arq)[
                break-date: local-date first arq
                if error? try[write/append %/c/tvprog/tvprog.txt join newline ["Date: 
" break-date newline newline]][
                   print "^/I/O error detected while saving file. Try again."
                   wait 3
                   quit
                ]
           ]      
           hra: to-string second arq
           if (equal? substr hra 2 1 ":" ) [hra: join "0" hra]
           if error? try[write/append %/c/tvprog/tvprog.txt join hra [" " third arq " 
- " fourth arq "^/"]][
               print "^/I/O error detected while saving [tvprog.txt]. Try again."
               wait 3
               quit
           ]
      ]

      if error? try[write/append %/c/tvprog/tvprog.txt 
"^/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^/^/"][
         print "^/I/O error detected while saving [tvprog.txt]. Try again."
         wait 3
         quit
      ]

      print join "^/File " [nfile " transfered."]
]

print "^LSearch for transfered lists in c:\tvprog\tvprog.txt"
wait 3
quit

Reply via email to