Silverfrost Forums

Welcome to our forums

write_url@

11 Apr 2018 3:29 #21795

Hello,

sorry, but I have not found the contrary of read_url@. I want to write to a ftp-server or put a file to a ftp-server. Are there any functions? Thank you for your help

Hartmut

11 Apr 2018 3:57 #21796

No. There is no routine to write a file nor to upload a file at the moment.

read_url@ and download@ call upon InternetReadFile. We don't have any routines that call upon InternetWriteFile at the moment.

12 Apr 2018 10:34 #21802

I have tried to use the functions of wininet.dll (c:\windows\SysWOW64\wininet.dll)under 64bit, but Plato says:

***c:\windows\SysWOW64\wininet.dll is not an x64 DLL file

Where can I find a correct wininet.dll ?

Thanks Hartmut

12 Apr 2018 11:28 #21803

An oddity of the Windows conventions is that SysWow64 is for 32-bit DLLS, whereas System32 is for 64-bit DLLs. You may want to check %PATH%.

12 Apr 2018 2:02 #21805

I have tested both, system32 and syswow64. The error message is the same. Hartmut

12 Apr 2018 2:05 #21806

Here is an extract from the notes on 64 bit programming...

SLINK64 automatically scans commonly used Windows DLLs. If a Windows function located in (say) xxx.dll is reported as missing then the DLL should be loaded by using a script command of the form

lo C:\Windows\Sysnative\xxx.dll

where C:\Windows illustrates the value of the %windir% environment variable.

12 Apr 2018 2:35 #21807

In the meanwhile, I have found a working wininet.dll in the web (dll-files.com). Normaly I use the dll's added by Reference to the Plato Project Explorer. This is easy to handle. Thanks Hartmut

12 Apr 2018 3:49 #21809

The Problem of writing to a ftp-server is solved: Usind the following Wininet-function as C_EXTERNAL, I can read and write a file to ftp:

  C_EXTERNAL InetOpen 'InternetOpenA' (REF,VAL,REF,REF,VAL) : INTEGER*4
  C_EXTERNAL InetConnect 'InternetConnectA' (VAL,STRING,VAL,String,String,VAL,VAL,VAL) : INTEGER*4
C_EXTERNAL SetDir 'FtpSetCurrentDirectoryA' (VAL,STRING) : LOGICAL
C_EXTERNAL GetFile 'FtpGetFileA' (VAL,STRING,STRING,VAL,VAL,VAL,VAL) : LOGICAL
C_EXTERNAL PutFile 'FtpPutFileA' (Val,STRING,STRING,VAL, VAL) : LOGICAL
  C_EXTERNAL InetClose 'InternetCloseHandle' (VAL) : LOGICAL

For more Information about the Wininet-Functions see:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa385483(v=vs.85).aspx

Hartmut

12 Apr 2018 5:31 #21811

Hartmut

If you are able to send me your code, I might be able to include this in the library alongside the existing routines.

12 Apr 2018 9:57 #21818

The Wininet adopted for this compiler in friendly for Fortran definitions (with given self-explanatory names and parameters instead of REF, REF, STRING, VAL, VAL, VAL) is what FTN95 is missing for a long time. I think Intel Fortran has done this right way.

13 Apr 2018 8:46 #21822

Paul, here is my code:

  winapp 

  program writeftp
  use mswin
  implicit none

integer*2 errorcode 
  integer*4 inetopenhandle,inetconnecthandle,sglocal,ierror
  integer*4 INTERNET_DEFAULT_FTP_PORT,INTERNET_SERVICE_FTP
  integer*4 INTERNET_OPEN_TYPE_DIRECT,INTERNET_FLAG_RELOAD
integer*4 FTP_TRANSFER_TYPE_ASCII

logical bool,bfail

  character*80 lpszagent,server,user,password,subdir,remotefile,localfile
  
  C_EXTERNAL InetOpen 'InternetOpenA' (REF,VAL,REF,REF,VAL) : INTEGER*4
  C_EXTERNAL InetConnect 'InternetConnectA' (VAL,STRING,VAL,String,String,VAL,VAL,VAL) : INTEGER*4
C_EXTERNAL SetDir 'FtpSetCurrentDirectoryA' (VAL,STRING) : LOGICAL
C_EXTERNAL GetFile 'FtpGetFileA' (VAL,STRING,STRING,VAL,VAL,VAL,VAL) : LOGICAL
C_EXTERNAL PutFile 'FtpPutFileA' (Val,STRING,STRING,VAL, VAL) : LOGICAL
  C_EXTERNAL InetClose 'InternetCloseHandle' (VAL) : LOGICAL
C_EXTERNAL Lasterror 'GetLastError' () : Integer*4

  lpszagent='agent name'
inetconnecthandle=0
  inetopenhandle=0      
sglocal=12
ierror=0

server=''
  user=''
  password=''
subdir=''
remotefile=''
localfile='Test.txt'

  bool=.false.
bfail=.false.

  INTERNET_DEFAULT_FTP_PORT=21
  INTERNET_DEFAULT_FTP_PORT=0
  INTERNET_OPEN_TYPE_DIRECT=1
INTERNET_SERVICE_FTP=1
INTERNET_FLAG_RELOAD=Z'80000000'
FTP_TRANSFER_TYPE_ASCII=Z'1'

  inetopenhandle=InetOpen(lpszagent,INTERNET_OPEN_TYPE_DIRECT,0,0,0)
if (inetopenhandle.eq.0) then
  ierror=Lasterror()
  goto 99
  endif

inetconnecthandle=InetConnect(inetopenhandle,server,INTERNET_DEFAULT_FTP_PORT,user,password, &
 &  INTERNET_SERVICE_FTP,0,0)
if (inetconnecthandle.eq.0) then
  ierror=Lasterror()
  goto 99
  endif

bool=SetDir(inetconnecthandle,subdir)
if (.not.bool) then
  ierror=Lasterror()
  goto 99
  endif

bool=GetFile(inetconnecthandle,remotefile,localfile,bfail,INTERNET_FLAG_RELOAD, &
 &  FTP_TRANSFER_TYPE_ASCII,0)
if (.not.bool) then
  ierror=Lasterror()
  goto 99
  endif

open(sglocal,file=localfile,access='append')
write(sglocal,*) 'this is a new line'
  close(sglocal)

bool=PutFile(inetconnecthandle,localfile,remotefile,FTP_TRANSFER_TYPE_ASCII,0)
if (.not.bool) then
  ierror=Lasterror()
  goto 99
  endif

call erase@(localfile,errorcode)

bool=InetClose(inetconnecthandle)
bool=InetClose(inetopenhandle)

99 continue if (ierror.eq.0) then write(,) 'ok' else write(,) 'Error = ',ierror endif

  end

The program reads a (ascii)file from a subdirectory of the ftpserver, modifies the file by adding a new line and saves it back to the ftpserver.

Hartmut

13 Apr 2018 9:54 #21823

Thank you.

Please login to reply.