files off internet

For issues with communication ports, protocols, etc.
Posts: 12
Joined: Oct 14, 2005 0:29

files off internet

Postby dooglius » Feb 26, 2006 17:22

how do i get files off the web? I tried this:

Code: Select all

chdir ""
open "index.html" for input as #1
if eof(1) then
    print "File not found"
    print "File found"
end if
close #1

But it doesn't work
Posts: 997
Joined: May 27, 2005 9:06
Location: London

Postby VonGodric » Feb 26, 2006 17:25

as much as I know of this you need to use winapi with mime types. or some networkg library -try SDL_net

these functions are only for locar hdd accessing
Posts: 1525
Joined: May 27, 2005 17:18

Postby jofers » Feb 26, 2006 17:39

Doesn't quite work like that. The world wide web uses a protocol called "HTTP". To get that file, you have to:

connect to at port 80
send "get /index.html HTTP/1.1 \n Host: \n"
receive the response in chunks

To do this, you'll need a socket library such as, as VonGodric suggested, Winsock or SDL_net.
Posts: 1704
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.

Postby Sisophon2001 » Feb 27, 2006 0:51


I posted a function for downloading files from the internet using the WinAPI here:

If this is all you want to do, then it may be of use to you. I only tested this on a single file, and I know next to nothing about internet protocols, but it looked neat and tidy, so I decided to try it for myself.

Posts: 84
Joined: Nov 04, 2005 18:13
Location: UK

Postby hippy » Feb 27, 2006 17:22

I've often thought just how nice it would be if files, web pages, email and even newsgroups could be read, uploaded and downloaded over the net that easily.

When reading, the OPEN downloads the file and could throw a File Not Found or other error and then reading could come from a temporary file. Writing would be to a temporary file and on CLOSE the upload would automatically happen, and throw errors then if it fails.

I think there is an argument to be able to overload or vector OPEN and CLOSE to allow such things to be done, and while I can see the reasoning for FB having moved from OPEN "COM1:..." to OPEN COM etc, I'd much prefer to see a language which allowed the file spec to determine what needs to be done.

The argument against is that massive runtime support has to be included in an executable which more often than not isn't needed. I'm sure there would be a way to allow the user to specify what runtime support was included at compile/link time and the availability of runtime support could be checked when OPEN etc is called with minimal overhead. That would give the best of both worlds.
Posts: 1525
Joined: May 27, 2005 17:18

Postby jofers » Feb 27, 2006 17:57

You can write hooks for OPEN, so you could say, make a function that would make this:

Code: Select all

Open "INET:" For binary As #1

Open an internet site. I tried hacking in an rtlib module for "OPEN TCP", but I cancel'd it because sending and receiving through FB's virtual file system would make the other end reset the connection all the time.

See the example file "openhook.bas" that comes with FB for a quick rundown on how to hook the OPEN command, if you wish to implement this yourself.
Posts: 84
Joined: Nov 04, 2005 18:13
Location: UK

Postby hippy » Feb 27, 2006 18:44

jofers wrote:You can write hooks for OPEN

Many thanks. FB is just so powerful that there seems to be nothing it cannot do, and there is an awful lot of capability which I am not aware of !
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Postby anonymous1337 » Feb 27, 2006 18:54

Hippy: I was surprised too. Unlike most basic compilers, FB gives you the ability not commonly used in the basic world. The ability to play around with it's functions, and macroing and such helps too.

You can basically take what Fb has and manipulate it to your own advantage.

Return to “Hardware Interfaces / Communication”

Who is online

Users browsing this forum: No registered users and 3 guests