Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24

Thread: timer / doevents / inet problem

  1. #11
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,083
    Blog Entries
    5
    Rep Power
    725

    Re: timer / doevents / inet problem

    I like a lot how it is designed, but I must report that I never got full 10 159 378 bytes, but usually few bytes less ( each time differentely ).

    I have no problems downloading the file using Firefox3/IE7.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #12
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10

    Re: timer / doevents / inet problem

    Quote Originally Posted by Petr Schreiber
    I like a lot how it is designed, but I must report that I never got full 10 159 378 bytes, but usually few bytes less ( each time differentely ).
    It doesn't matter. Size is just computed for stat purposes.
    Important is INET_Internet_ReadFile buffer size. That will determine the finish of the download.
    Callback status function is just used to monitor going on when not inside a loop but inside a timer message. It will allow to have some sort of multi-tasking behave. I will create an example showing a possible way on how to use it, a kind of download manager.

    Quote Originally Posted by Petr Schreiber
    I have no problems downloading the file using Firefox3/IE7.
    Used API are OS integrated and not dependant from the installed browser so there should not be problems unless you are on very old OS.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  3. #13
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,083
    Blog Entries
    5
    Rep Power
    725

    Re: timer / doevents / inet problem

    Hi Eros,

    well, I have Windows XP SP2 + all updates before SP3.
    When the script reports its finished, I try to unzip downloaded file and it complains "end of signature not found" or something similar - and as I said, 2 executions, 2 different resultant file sizes.

    I will check if it is not corrupted by antivirus.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #14
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,083
    Blog Entries
    5
    Rep Power
    725

    Re: timer / doevents / inet problem

    My suspection became reality - when having NOD32 online, it finished with bad size, with AV disabled no problem.
    I think NOD32 scans any download streams coming to PC, so maybe it interfered in some way.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #15
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10

    Re: timer / doevents / inet problem

    All developed functionalities are now available on current thinBasic beta 1.7.8.0
    Some functions has a little different syntax so please refer to example in \thinBasic\SampleScripts\INet\Internet_FileDownload.tbasic

    I will create a User Interface example very soon showing a sort of Download Manager.
    I'm not sure if all needed functions are already present, maybe I will develop something more on this area

    Let me know.
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  6. #16
    Member
    Join Date
    Mar 2009
    Location
    Netherlands
    Age
    49
    Posts
    248
    Rep Power
    37

    Re: timer / doevents / inet problem

    Works great!

    But again I have a problem with reading international characters.

    In your example I replaced sURL with http://nl.wikipedia.org/wiki/Knäckebröd and then I save strData with file_save("C:\test.txt", strData)

    If I run the script and then open test.txt in NotePad, I can see the word Knäckebröd is written correctly. But if I insert this line in the script MSGBOX 0,grab$(strData,"<title>","</title>") it outputs Knäckebröd as Knäckebröd.

    I guess I must change the font, but how?

    Martin

  7. #17
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10

    Re: timer / doevents / inet problem

    Thanks martin.

    I have to investigate further on this, sorry not to have an immediate solution.

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  8. #18
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10

    Re: timer / doevents / inet problem

    I think I've got the problem and possibly found a solution thanks to a post from José Roca forum (as usual his forum is a mine of info and source code): http://www.jose.it-berater.org/smffo...php?topic=74.0

    The page you pointed for testing is UTF-8 encoded while thinBasic works on ANSI codes.
    I will release soon a new update of thinBasic beta version in which I've developed few new functions able to convert from UFT-8 to Wide to Ansi.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  9. #19
    Member
    Join Date
    Mar 2009
    Location
    Netherlands
    Age
    49
    Posts
    248
    Rep Power
    37

    Re: timer / doevents / inet problem

    Super! I really need correct output for analyzing webpages with searchresults. Thanks for your research!

  10. #20
    Member
    Join Date
    Mar 2009
    Location
    Netherlands
    Age
    49
    Posts
    248
    Rep Power
    37

    Re: timer / doevents / inet problem

    Hi Eros, I don't understand how to use the new utf8-commands. In the following script I wrote "function=UTF8ToAnsi$(strdata)" but that doesn't help to display correct characters. How should I use these new functions?

    [code=thinbasic]uses "inet"

    dim html as string
    dim title as string

    html=download("http://nl.wikipedia.org/wiki/Knäckebröd")
    title=grab$(html,"<title>","</title>")
    msgbox 0,title

    function download(sUrl as string) as string
    local hInternet,MyContext,hFile,cbBytesRead,TotalBytesRead,FileSize as dword
    local bResult,pstrBuffer,lBufferLen as long
    local strBuffer,strData AS STRING

    lBufferLen=1024

    do
    hInternet = INET_Internet_Open("test", %INTERNET_OPEN_TYPE_DIRECT)
    IF hInternet <> %NULL THEN EXIT DO
    loop

    do
    hfile=INET_Internet_OpenUrl(hInternet, sUrl, "", %INTERNET_FLAG_NO_CACHE_WRITE, MyContext)
    if hfile<>%NULL then exit do
    loop

    do
    filesize=INET_Http_QueryInfo(hFile, %HTTP_QUERY_CONTENT_LENGTH)
    if filesize<>%NULL then exit do
    loop

    strBuffer = STRING$(lBufferLen, $SPC)
    pstrBuffer = STRPTR(strBuffer)

    DO
    bResult = INET_Internet_ReadFile(hFile, pstrBuffer, len(strBuffer), cbBytesRead)
    IF bResult = 0 OR cbBytesRead = 0 THEN EXIT DO

    IF cbBytesRead = LEN(strBuffer) THEN
    strData &= strBuffer
    ELSE
    strData &= LEFT$(strBuffer, cbBytesRead)
    END IF

    TotalBytesRead += cbBytesRead

    doevents

    LOOP

    INET_Internet_CloseHandle hInternet
    INET_Internet_CloseHandle hFile

    function=UTF8ToAnsi$(strdata)
    end function[/code]

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. INET download issue
    By nrodes in forum thinBasic General
    Replies: 1
    Last Post: 03-06-2009, 22:17

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •