0
download-dir: request-dir
Print ["downloading " "VStudio2008Express.iso" "..." ]
url: http://go.microsoft.com/fwlink/?LinkId=104679 
file-save: to-rebol-file rejoin [download-dir "VStudio2008Express.iso"]
request-download/to url file-save

In the end whereas the progress bar has shown the download has finished:

** Script Error: Not enough memory
** Where: append
** Near: insert tail series :value
>>

So how to correct request-download as it is a mezzanine function:

func [
    {Request a file download from the net. Show progress. Return none on error.} 
    url [url!] 
    /to "Specify local file target." local-file [file! none!] 
    /local prog lo stop data stat event-port event
][
    view/new center-face lo: layout [
        backeffect [gradient 1x1 water gray] 
        space 10x8 
        vh2 300 gold "Downloading File:" 
        vtext bold center 300 to-string url 
        prog: progress 300 
        across 
        btn 90 "Cancel" [stop: true] 
        stat: text 160x24 middle
    ] 
    stop: false 
    data: read-thru/to/progress/update url local-file func [total bytes] [
        prog/data: bytes / (max 1 total) 
        stat/text: reform [bytes "bytes"] 
        show [prog stat] 
        not stop
    ] 
    unview/only lo 
    if not stop [data]
]
Rebol Tutorial
  • 2,738
  • 2
  • 25
  • 36
  • I've never used REBOL/View, so I don't know much about it, but I have two suspicions. It's either a limitation of read-thru or a limitation of REBOL itself, which will likely be remedied with REBOL 3. – Gregory Higley Sep 13 '09 at 21:32
  • How big is the file you're trying to download? – Gregory Higley Sep 13 '09 at 21:42
  • It's 800 Mo but I have 3 Go RAM so it shouldn't have failed but it did maybe it's because it doesn't use this ? http://www.rebol.com/article/0199.html Seek mode added for random access to large files http://community.livejournal.com/rebol Copy and Checksum Large Files – Rebol Tutorial Sep 14 '09 at 18:21
  • What version of REBOL are you using (`system/version`)? – earl Sep 15 '09 at 17:34
  • >> system/version == 1.3.2.3.1 – Rebol Tutorial Sep 15 '09 at 17:44
  • I tried the same download under 2.7.6.3.1 and hit the same out-of-memory problem. I've successfully loaded larger files before (though not with request-download), so the problem cannot be that REBOL is genuinely out of memory. I've reported the problem to RAMBO: http://www.rebol.net/cgi-bin/rambo.r ticket number: 4730 – Sunanda Sep 17 '09 at 06:45

2 Answers2

3

Rebol's read functions read all the input data into memory at once and cannot be used on large datasets. You have to open a port and copy the data from it in chunks to handle large datasets.

I would think that the request-download function could be modified to use ports for both the input and output data. This thread from the Rebol Mailing List may help you:

http://www.rebol.org/ml-display-thread.r?m=rmlFQXC

You can find a fuller example on Carl's blog at http://www.rebol.com/cgi-bin/blog.r?view=0281#comments

Even using this technique there is a limit of approximately 2Gb to the size of files that can be handled in Rebol 2.

Peter W A Wood
  • 863
  • 5
  • 14
1

Try this

http://anton.wildit.net.au/rebol/util/batch-download.r

Graham Chiu
  • 4,856
  • 1
  • 23
  • 41