Download from Internet to Memory

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
KatSeiko
New User
New User
Posts: 7
Joined: Thu Sep 25, 2008 12:47 am
Location: Between keyboard and chair

Download from Internet to Memory

Post by KatSeiko »

The features of .NET allow you to load any file through HTTP (Stream) as if it is on your local drive. With PureBasic, I have to either download the file to disc and then check if the download was successful, then load the file and delete that temporary file - or I have to program something using direct network controls to receive the file content in small blocks and load everything into memory.

I would love to be able to shortcut this whole nightmare in the future, allowing for maybe this code:

Code: Select all

$URL = "http://www.example.org/example.xml"
*buffer = AllocateMemory(5000)
If Length.i = ReceiveHTTPStream($URL, *buffer) // 0 means "Could not download", anything else is the length of the file received..
  If XML = CatchXML(#PB_Any, *buffer, Length)
    Messagerequester("Success", "Loaded XML File from Internet")
  EndIf
EndIf
What do you think?