FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Internet file
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Internet file
Posted: Tue Aug 27, 2013 07:39 AM

is there a function to take one file ( csv) from a website ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Internet file
Posted: Tue Aug 27, 2013 08:02 AM
Code (fw): Select all Collapse
FUNCTION MAIN()
        
LOCAL cFile :=  "ciao_silvio.csv" 

GETURL( "http://www.ipsys.it" ,  cFile )

RETURN NIL

FUNCTION GETURL( cUrl , cFile )

    LOCAL oUrl, oCli

    LOCAL lOk := .F.
    BEGIN SEQUENCE
        oUrl = TUrl():New( cUrl + "/" + cFile )

        IF EMPTY( oUrl )
            BREAK
        ENDIF

        oCli = TIPClientHttp():New( oUrl )

        IF EMPTY( oCli )
           BREAK
        ENDIF

        IF !oCli:Open( oUrl )
           BREAK
        ENDIF

        cStringa := oCli:Read()


        oCli:Close()
    END SEQUENCE

    creafile( cFile , cStringa ) 

    RETURN lOk
                                              

FUNCTION Creafile( cFile, cStringa )
  LOCAL nHandle := FCreate( cFile )
  LOCAL cLeggiTest
  LOCAL lRitorna

  IF FError() <> 0
     RETURN .F.
  ENDIF
  FWrite( nHandle, cStringa, Len(cStringa) )
  FClose( nHandle )

  cLeggiTest := MEMOREAD( cFile )

  lRitorna := ( FError() == 0 ) .AND. ( cStringa = cLeggiTest )

 RETURN lRitorna
Marco Boschi
info@marcoboschi.it
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Internet file
Posted: Tue Aug 27, 2013 08:14 AM

sorry but
[1]:iLink32.Exe -Gn -aa -Tpe -s @test.bcl
Turbo Incremental Link 5.69 Copyright (c) 1997-2005 Borland
Error: Unresolved external '_HB_FUN_TURL' referenced from C:\WORK\ERRORI\CVS\OBJ\TEST.OBJ
Error: Unresolved external '_HB_FUN_TIPCLIENTHTTP' referenced from C:\WORK\ERRORI\CVS\OBJ\TEST.OBJ

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Internet file
Posted: Tue Aug 27, 2013 05:12 PM

I insert tip.lib as Emg sad but I try to load a file and it not run

FUNCTION Main()
LOCAL cFile := "estrazionidellotto.csv"
GETURL( "http://www.estrazionidellotto.com" , cFile )
return nil

cstringa is empty I not Know why

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Internet file
Posted: Tue Aug 27, 2013 06:10 PM

Maybe a firewall issue?

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Internet file
Posted: Tue Aug 27, 2013 08:09 PM
Sylvio,

I use this function :
Code (fw): Select all Collapse
URLDownloadToFile(0,"http://www.test.com/test.csv","c:\download\test.csv",0,0)

DLL Function URLDownloadToFile(pCaller AS LONG, szURL AS STRING, szFileName AS STRING, dwReserved AS LONG, lpfnCB AS LONG) AS LONG PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"
It's working very well.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Internet file
Posted: Wed Aug 28, 2013 12:18 PM

good this run ok on w7

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Internet file
Posted: Wed Aug 28, 2013 01:35 PM

Is it about my suggestion you say it's ok in W7?
It runs fine in Windows XP, Vista en 8 too.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion