Announcement

Collapse
No announcement yet.

irun.dll - Function EXRTF2WEB()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • irun.dll - Function EXRTF2WEB()

    I'm playing with the irun.dll library, especially the EXRTF2WEB() function.

    Does anyone have an INC file for this library ?

    I have a problem most likely with her declaration, as it returns 1 to her test example (Example.rtf), not 0, which is OK. The second call to the function is followed by a boom (see test example)!

    Would you look where the problem is ?!

    I attach an example: PB_test to the archive of the latest version 1.23.

    ___
    Thanks in advance !
    Attached Files

  • #2
    Does anyone have an INC file for this library ?
    Who needs a stinkin' INC file? I found the function doc here:

    http://www.pilotltd.com/en/site/serv.../documentation

    That' a pretty easy function for which to create a DECLARE statement. and the rest of the doc tells you the values of the enums used for the call constants so you can define some PB equates.

    This is a skill you really should master if you are going to use external libraries. (Joined forum sixteen years ago).

    No I am not going to do it for you. (And yes I certainly could).

    MCM
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Originally posted by Michael Mattias View Post

      Who needs a stinkin' INC file? I found the function doc here:

      http://www.pilotltd.com/en/site/serv.../documentation

      That' a pretty easy function for which to create a DECLARE statement. and the rest of the doc tells you the values of the enums used for the call constants so you can define some PB equates.

      This is a skill you really should master if you are going to use external libraries. (Joined forum sixteen years ago).

      No I am not going to do it for you. (And yes I certainly could).

      MCM
      Apparently you haven''t looked at the attached file. He's got the enums and Declare in his .bas file but it is not performing as advertised. Since you could do it, you may like to look at his code and declare and tell us why it is returning an undocumented return value and working the first time he calls the function but crashing the second time.

      Code:
      #COMPILE EXE
      #DIM ALL
      #INCLUDE "WIN32API.INC"
      
      '--- irun.INC ---
      
      %EXO_RESULTS   = &h0001
      %EXO_INLINECSS = &h0002
      %EXO_WMF2GIF   = &h0004
      %EXO_XML       = &h0008
      %EXO_HTML      = &h0010
      %EXO_MEMORY    = &h0020
      %EXO_NOHEADER  = &h0040
      
      DECLARE FUNCTION EXRTF2WEB LIB "irun.dll" ALIAS "EXRTF2WEB"( _
          BYREF SOURCE AS ASCIIZ, _
          BYREF destination AS ASCIIZ, _
          BYVAL options AS LONG, _
          BYREF bgcolor AS ASCIIZ, _
          BYREF title AS ASCIIZ, _
          BYVAL dpi AS LONG ) AS LONG
      
      '----------------
      
      FUNCTION PBMAIN()
          LOCAL szRTF, szHTML AS ASCIIZ * %MAX_PATH, n AS LONG
          szRTF = EXE.PATH$ + "Examples\Example.rtf"
          szHTML = EXE.PATH$ + "Examples\Example.html"
      
          GOSUB MBox '1 time - WORK ?!
          GOSUB MBox '2 time - ;-(
          GOSUB MBox '...
      
          EXIT FUNCTION
      
      MBox:
          INCR n
          MSGBOX "Read RTF:" + $TAB + szRTF + $CR + _
              "Save HTML:" + $TAB + szHTML + $CR + $CR + _
              "Function return" + $TAB + "EXRTF2WEB() =" + STR$( EXRTF2WEB( szRTF, szHTML, %EXO_HTML OR %EXO_WMF2GIF, "#DDDDDD", "PB Test", 72 )) + $CR + $CR + _
              "Documentation" + $CR + _
              "... The function returns 0 if everything is OK. If error occurs the function returns negative values ???!!!",, "Calling the function EXRTF2WEB() for" + STR$( n ) + " time"
      RETURN
      
      END FUNCTION

      Comment


      • #4
        This is done, if you had looked at the example you would have seen (of course I saw the documentation).
        On the second call of the function thunders, there may be a problem in the library ?!

        Thank you for your attention !

        ... to Michael Mattias

        Comment


        • #5
          > On the second call of the function thunders, there may be a problem in the library ?!

          Being an ansi C library, probably you may need to use CDECL.
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            Thanks José !
            It didn't work .

            Comment


            • #7
              Originally posted by Plamen Chobanov View Post
              Thanks José !
              It didn't work .
              BDECL and everything BYREF appears to work.But it returns -3 on each iteration. (Cannot read source file)

              Code:
              DECLARE FUNCTION EXRTF2WEB LIB "irun.dll" ALIAS "EXRTF2WEB"( _
              BYREF SOURCE AS ASCIIZ, _
              BYREF destination AS ASCIIZ, _
              BYREF options AS LONG, _
              BYREF bgcolor AS ASCIIZ, _
              BYREF title AS ASCIIZ, _
              BYREF dpi AS LONG ) BDECL AS LONG

              Comment


              • #8
                Just realised that while no "*DECL:" or SDECL returns a positive number, it does actually do the conversion properly on the first call.

                Comment


                • #9
                  If you use Explicit Loading for the DLL you can call the function repeatedly without crashing as in this version of your test code..
                  '
                  Code:
                  #Compile Exe "PB_test2.exe"
                  #Dim All
                  
                  #Include "WIN32API.INC"
                  
                  '--- irun.INC ---
                  
                  %EXO_RESULTS   = &h0001
                  %EXO_INLINECSS = &h0002
                  %EXO_WMF2GIF   = &h0004
                  %EXO_XML       = &h0008
                  %EXO_HTML      = &h0010
                  %EXO_MEMORY    = &h0020
                  %EXO_NOHEADER  = &h0040
                  
                  Declare Function EXRTF2WEB( _
                    ByRef SOURCE As AsciiZ, _
                    ByRef destination As AsciiZ, _
                    ByVal options As Long, _
                    ByRef bgcolor As AsciiZ, _
                    ByRef title As AsciiZ, _
                    ByVal dpi As Long ) As Long
                  
                  '----------------
                  
                  Function Convert(szRTF As AsciiZ, szHTML As AsciiZ) As Long
                   Local hLib, pAddr As Dword, lRes As Long
                   Static n As Long
                  
                     hLib = LoadLibrary("irun.dll")
                     pAddr = GetProcAddress(hLib, "EXRTF2WEB")
                     If pAddr <> 0 Then
                       GoSub MBox
                     End If
                    FreeLibrary hLib
                    Exit Function
                  
                  MBox:
                    Incr n
                    Call Dword pAddr Using EXRTF2WEB( szRTF, szHTML, %EXO_HTML Or %EXO_WMF2GIF, "#DDDDDD", "PB Test", 72 ) To lRes
                    MsgBox "Read RTF:" + $Tab + szRTF + $Cr + _
                      "Save HTML:" + $Tab + szHTML + $Cr + $Cr + _
                      "Function return" + $Tab + "EXRTF2WEB() =" + Str$(lRes) + $Cr + $Cr + _
                      "Documentation" + $Cr + _
                      "... The function returns 0 if everything is OK. If error occurs the function returns negative values ???!!!",, "Calling the function EXRTF2WEB() for" + Str$( n ) + " time"
                  Return
                  
                  End Function
                  '------------------/Convert
                  
                  Function PBMain()
                   Local szRTF, szHTML As AsciiZ * %Max_Path
                    szRTF = Exe.Path$ + "Examples\Example.rtf"
                    szHTML = Exe.Path$ + "Examples\Example.html"
                  
                    Convert(szRTF, szHTML)
                    Convert(szRTF, szHTML)
                    Convert(szRTF, szHTML)
                  
                  End Function
                  '------------------/PBMain
                  The function returns negative numbers for errors as advertised (eg use DPI = 0 for a '-2' return) but it does give '1' instead of '0' when there seem to be no errors ??
                  Rgds, Dave

                  Comment


                  • #10
                    Deleted ...

                    Comment


                    • #11
                      Dave, that's my decision so far.
                      It just doesn't look clean to me and I decided to turn to the forum ....

                      Comment


                      • #12
                        The problem is solved !

                        For those who would use the library.

                        You are using Buffer based functions - not EXRTF2WEB():

                        Start a session with EXBufferOpenSession().
                        Perform converting RTFs many times.
                        Finish work with EXBufferCloseSession()

                        Do not use EXBufferOpenSession() and EXBufferCloseSession () between individual conversions - this leads to the above problem!

                        Thank you all for your time!

                        Comment


                        • #13
                          For those who would use the library.

                          You are using Buffer based functions - not EXRTF2WEB():...
                          Decided to give this a go but I'm struggling to translate their C example

                          How did you declare this function EXBufferConvert () ?
                          '
                          Code:
                          int EXBufferConvert ( HGLOBAL         sessionHandle,          // session handle
                                                unsigned char*  inputBuffer,            // input buffer
                                                int             inputBufferSize         // size of input buffer
                                                int*            outputBufferSize,       // (out) output buffer size
                                                int*            referencedObjectCount,  // (out) number of referenced objects
                                                int             options                 // an OR’ed list of options
                                                char*           bgcolor                 // HTML bgcolor
                                                char*           title                   // HTML title
                                                Int             dpi)                    // WMF-GIF conversion DPI (dots Per inch)
                           '
                          Rgds, Dave

                          Comment


                          • #14
                            Something like this?
                            Code:
                            DECLARE FUNCTION EXBufferConvert LIB "irun.dll" ALIAS "EXBufferConvert"( __
                                                 (BYVAL DWORD       sessionHandle,         _ // session handle
                                                  BYREF STRINGZ     inputBuffer,           _ // input buffer
                                                  BYVAL LONG        InputBufferSize        _ // size of input buffer
                                                  BYREF LONG        outputBufferSize,      _ // (out) output buffer size
                                                  BYREF LONG        referencedObjectCount, _ // (out) number of referenced objects
                                                  BYVAL LONG        options                _ // an OR’ed list of options
                                                  BYREF STRINGZ     bgcolor                _ // HTML bgcolor
                                                  BYREF STRINGZ     title                  _ // HTML title
                                                  BYVAL LONG        dpi)                   _ // WMF-GIF conversion DPI (dots Per inch)
                                                  AS LONG

                            Comment


                            • #15
                              Thanks Stuart,

                              Looks like this might be working.
                              Code:
                              Declare Function EXBufferConvert( SessionHandle         As Dword, _       '  session handle
                                                                ByVal inputBuffer     As Byte Ptr, _    '  input buffer "unsigned char*"
                                                                ByVal inputBufferSize As Long, _        '  size of input buffer
                                                                outputBufferSize      As Quad, _  '  (out) output buffer size
                                                                referencedObjectCount As Long, _  '  (out) number of referenced objects
                                                                ByVal options         As Long, _        '  an OR’ed list of options
                                                                bgcolor               As AsciiZ, _      '  HTML bgcolor
                                                                title                 As AsciiZ, _      '  HTML title
                                                                ByVal dpi As Long )   As Long           '  WMF-GIF conversion DPI (dots Per inch)
                              On to the next speed bump
                              Last edited by Dave Biggs; 29 Jul 2020, 10:58 AM.
                              Rgds, Dave

                              Comment


                              • #16

                                outputBufferSize As Quad, _
                                I don't know where 'QUAD' came from. An 'int' in c-speak is a 32- bit twos complement binary integer in Intel format which in PB-speak is a LONG.

                                It "works" because it's a byref argument and the function is depositing a 32-bit integer at the passed address; a QUAD may be thought of as two consecutive LONGs, least sigificant LONG at that lowest (first) address, which is the passed address.

                                With luck like this it might be a good day to buy a PowerBall lottery ticket.

                                Michael Mattias
                                Tal Systems Inc. (retired)
                                Racine WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment

                                Working...
                                X