Loading ...
Sorry, an error occurred while loading the content.

WinInet.dll and downloading from the internet....

Expand Messages
  • Ken
    Hi again, I have been very busy the past few months but I have managed to do some interesting coding in the down time. IQPDF - the PDF search engine written
    Message 1 of 2 , Apr 7 2:21 AM
    • 0 Attachment
      Hi again,
      I have been very busy the past few months but I have managed to do some interesting coding in the down time. IQPDF - the PDF search engine written in LB finally made it out of BETA and then almost immediately went back into revision when I found a better way of manipulating multiple files. (Forget Base 10 math - go Base 100) Anyway you can get this new version now from IQPDF.COM - all free and the new version even indexes new PDFs on the fly on start up. Try it - get the runtime and the Works of Shakespeare and the Bible to play with (same download section). You will be amazed what LB can do when pushed reasonably hard.....

      But the main reason I am posting is that I have a need in the work version (which is why it got written initially - my work manuals for the B777 are contained in 21 PDFs totaling some 3 million words in 14689 pages that change every month.), to automatically collect PDF manual updates from the 'cloud', so I needed to include some FTP routines.

      What a sod of a job. I tried everything, and eventually made it work, rather less than tidily, using Windows embedded FTP and some fancy BATch work - all controlled by LB and largely invisible to the user, but sort of messy to my mind.

      Anyway I have been hacking away at the core of this problem and the best DLL is Windows own WININET.DLL. Trouble is there are some nasty sharp corners to work around in LB. But I have got there and you may find the results instructive.

      I have uploaded the source of a set of routines under WININET Routines in the file section and the whole thing runs and shows you a directory of a section of the IQPDF site that has a set of files in it to display a directory of etc.

      The download routine works fine - just add the filenames as per the program. The thing to remember is that all strings passed to these dll routines need to have a chr$(0) appended to them as they need to be null terminated to conform with 'C' protocols.

      A spin off from IQPDF is a LB rehash of my 25 year old program to do technical quizzes that now has a dynamic help function that reads the question displayed and then finds the correct page from the manuals to show the correct answer. This is a little gem, as the manuals change frequently and using a static reference for help pages is a total no no. This is now a fully functional program that has helped graduate some 40 B777 pilots in the past few months. I am busy on the IPAD version now...

      I would make a copy of the Quiz package available for you all to play with - I know you would be impressed, but there are IP issues with the associated manuals that are not easily solved. However the IQPDF version as above is very slick and you will see the speed - 0.8 of a second for any multiple, out of order word search in the 750000 words of Shakespeare. Try a single file search and note the reconfiguring keyboard etc. It is configured for a tablet type screen, but you can unlock the reader and re-position it as required.

      When I get the time I will release some of that code - it is quite instructive.

      The other little program that is having great success is the LB version of FieldFinder the interactive Google Maps Nav Route trainer - all free and easy to use - get it at NZAR.NET as a compiled package or the actual code is in the same folder as the WININET stuff.

      The FF code is messy and is a straight quick and dirty conversion from the original TRS-80 version of some 30 years back. No apologies there, but it explains the lousy short and cryptic variable names. The datafile attached is for NZ airfields - make your own for your area. The instructions are reasonably clear.

      Enjoy

      Ken
    • Ken
      Update ... Having got the WININET routines working well in LB I put them through RT Russel s LB Booster compiler. And a real nightmare of failures with WIN32
      Message 2 of 2 , Apr 9 3:21 PM
      • 0 Attachment
        Update ...

        Having got the WININET routines working well in LB I put them through RT Russel's LB Booster compiler. And a real nightmare of failures with WIN32 calls etc.

        Unfortunately LBB does not have a trace or debug mode so it was a case of using 'wait' to find out just what was doing what...

        Anyway here is an interesting little feature / problem when calling DLLs using structures. If that DLL is using 'C' protocols and you have to append chr$(0) as a terminator for strings, then you may have to do the same for struct[ures] also.

        LB does not seem to mind and probably handles that nicely internally, but for WININET calls do this : (Notice the t$ = chr$(0) appended)

        This is the charm and all is compiling nicely now.

        function InetGetNextFile(DirHandle)
        ' Win32FindData Structure for Dir call
        t$ = chr$(0) ' terminator for struct
        struct Win32FindData, _
        FileAttributes as ulong, _
        CreationTime.LowDateTime as ulong, _
        CreationTime.HighDateTime as ulong, _
        LastAccessTime.LowDateTime as ulong, _
        LastAccessTime.HighDateTime as ulong, _
        LastWriteTime.LowDateTime as ulong, _
        LastWriteTime.HighDateTime as ulong, _
        FileSizeHigh as ulong, _
        FileSizeLow as ulong, _
        Reserved0 as ulong, _
        Reserved1 as ulong, _
        FileName$ as char[260], _
        AlternateFileName$ as char[14],_
        t$ as ptr
        ' end of structure define
        calldll #inet, "InternetFindNextFileA",_
        DirHandle as ulong,_ ' The FTP session handle
        Win32FindData as struct,_
        ret as ulong
        InetGetNextFile = ret
        FileNameResult$ = Win32FindData.FileName$.struct
        FileSizeResult = Win32FindData.FileSizeHigh.struct * 4294967295 + Win32FindData.FileSizeLow.struct
        FileAttrib = Win32FindData.FileAttributes.struct
        end function
        ' --------------------------------------
        function InetGetFirstFile(wildcard$) ' Use null for all
        wildcard$ = " " + chr$(0) ' null terminate
        t$ = chr$(0) ' terminator for struct
        ' Win32FindData Structure for Dir call
        struct Win32FindData, _
        FileAttributes as ulong, _
        CreationTime.LowDateTime as ulong, _
        CreationTime.HighDateTime as ulong, _
        LastAccessTime.LowDateTime as ulong, _
        LastAccessTime.HighDateTime as ulong, _
        LastWriteTime.LowDateTime as ulong, _
        LastWriteTime.HighDateTime as ulong, _
        FileSizeHigh as ulong, _
        FileSizeLow as ulong, _
        Reserved0 as ulong, _
        Reserved1 as ulong, _
        FileName$ as char[260], _
        AlternateFileName$ as char[14],_
        t$ as ptr
        ' end of structure define
        calldll #inet, "FtpFindFirstFileA",_
        FTPHandle as ulong,_ ' The FTP session handle
        wildcard$ as ptr,_
        Win32FindData as struct,_
        0 as ulong,_
        0 as ulong,_
        ret as ulong
        InetGetFirstFile = ret ' return a file handle for this sequence
        FileNameResult$ = Win32FindData.FileName$.struct
        FileSizeResult = Win32FindData.FileSizeHigh.struct * 4294967295 + Win32FindData.FileSizeLow.struct
        FileAttrib = Win32FindData.FileAttributes.struct
        end function

        Hope this saves someone else a headache ...

        Ken



        --- In libertybasic@yahoogroups.com, "Ken" <ken.b.smith@...> wrote:
        >
        > Hi again,
        > I have been very busy the past few months but I have managed to do some interesting coding in the down time. IQPDF - the PDF search engine written in LB finally made it out of BETA and then almost immediately went back into revision when I found a better way of manipulating multiple files. (Forget Base 10 math - go Base 100) Anyway you can get this new version now from IQPDF.COM - all free and the new version even indexes new PDFs on the fly on start up. Try it - get the runtime and the Works of Shakespeare and the Bible to play with (same download section). You will be amazed what LB can do when pushed reasonably hard.....
        >
        > But the main reason I am posting is that I have a need in the work version (which is why it got written initially - my work manuals for the B777 are contained in 21 PDFs totaling some 3 million words in 14689 pages that change every month.), to automatically collect PDF manual updates from the 'cloud', so I needed to include some FTP routines.
        >
        > What a sod of a job. I tried everything, and eventually made it work, rather less than tidily, using Windows embedded FTP and some fancy BATch work - all controlled by LB and largely invisible to the user, but sort of messy to my mind.
        >
        > Anyway I have been hacking away at the core of this problem and the best DLL is Windows own WININET.DLL. Trouble is there are some nasty sharp corners to work around in LB. But I have got there and you may find the results instructive.
        >
        > I have uploaded the source of a set of routines under WININET Routines in the file section and the whole thing runs and shows you a directory of a section of the IQPDF site that has a set of files in it to display a directory of etc.
        >
        > The download routine works fine - just add the filenames as per the program. The thing to remember is that all strings passed to these dll routines need to have a chr$(0) appended to them as they need to be null terminated to conform with 'C' protocols.
        >
        > A spin off from IQPDF is a LB rehash of my 25 year old program to do technical quizzes that now has a dynamic help function that reads the question displayed and then finds the correct page from the manuals to show the correct answer. This is a little gem, as the manuals change frequently and using a static reference for help pages is a total no no. This is now a fully functional program that has helped graduate some 40 B777 pilots in the past few months. I am busy on the IPAD version now...
        >
        > I would make a copy of the Quiz package available for you all to play with - I know you would be impressed, but there are IP issues with the associated manuals that are not easily solved. However the IQPDF version as above is very slick and you will see the speed - 0.8 of a second for any multiple, out of order word search in the 750000 words of Shakespeare. Try a single file search and note the reconfiguring keyboard etc. It is configured for a tablet type screen, but you can unlock the reader and re-position it as required.
        >
        > When I get the time I will release some of that code - it is quite instructive.
        >
        > The other little program that is having great success is the LB version of FieldFinder the interactive Google Maps Nav Route trainer - all free and easy to use - get it at NZAR.NET as a compiled package or the actual code is in the same folder as the WININET stuff.
        >
        > The FF code is messy and is a straight quick and dirty conversion from the original TRS-80 version of some 30 years back. No apologies there, but it explains the lousy short and cryptic variable names. The datafile attached is for NZ airfields - make your own for your area. The instructions are reasonably clear.
        >
        > Enjoy
        >
        > Ken
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.