Silverfrost Forums

Welcome to our forums

Reading files stored on the web

24 Jul 2008 3:29 #3535

Is it possible to simply 'open(unit=n,file='http://...' a file stored at a particular web adress and read/write the data as though it was a local file?

Regards

Ian

24 Jul 2008 5:26 #3540

Probably not but there is a routine called READ_URL@ that should do the trick. It is in the help file.

25 Jul 2008 7:21 #3555

Thanks Paul,

I tried adding that but the read_url@ returned ierror=1.

Code below, please specify a url and file of your own that will work.

Thanks

Ian

winapp
  include <windows.ins>
  character*80 url,file,line
  integer*4    imode,ierror,ios,i,ii
  url  = 'http://.............'
  file = 'c:\\temp_file.txt'
  imode=1
  call read_url@(url,file,imode,ierror)
  print *,'ierror=',ierror
  if(ierror .eq. 0)then
    open(unit=10,file=file,status='readonly',iostat=ios)
    if(ios .eq. 0)then
      do i=1,1000
        ii=i
        read(10,1000,end=999,err=888)line
 1000   format(a)
        print *,trim(line)
      enddo
      print *,'Finished            ii=',ii
      stop
 888  continue
      print *,'terminated on error ii=',ii
      stop
 999  continue
      print *,'terminated on end   ii=',ii
      stop
    else
      print *,'ios=',ios
    endif
  endif
  end
25 Jul 2008 12:10 #3563

The read_url works like charm.

I used it for stock trading code almost a half-decade ago for gathering data in real time from several dozen of websites... then was some text manipulation and html parsing and finally displaying all that data in a click on a multi-monitor screen. All done in FTN95 & Clearwin+ only

And often made jokes, that loading data from internet can be done just in one fortran line. Like this (Copyrighted 😄 ):

use clrwin;k=0;dowhile(k==0);call READ_URL@('http://forums.silverfrost.com/index.php','res.htm',0,i);call sleep@(10.);enddo;end

Don't use this code on Silverfrost website with small sleep time 😃

One more line will call the browser and display the URL Where you will find fortran compiler which can do that ???? 😄

28 Jul 2008 4:01 #3609

Dan,

You are right, it works like a dream, even my program did, but it needs to be on a decent machine, unlike the one I tried it on.

The moral of the story is 'Don't by a HP/Compaq'

Ian

29 Jul 2008 11:26 #3620

and I think writing several such examples for everyone use would be killing applications. Specifically if all will be done in true Windows fashion using Visual Clearwin like latest SDK for iPhone is working. That is just a dream. And if the next Clearwin will look and make applications like that... http://au.youtube.com/watch?v=kYgV2GlsufI&feature=related

Please login to reply.