Home Forums HTBasic Forum HTBDDE dll Reply To: HTBDDE dll

#9277
ZeRider
Participant

    Hi PatB,
    my test results with HTBasic 2021 are not better. The program stops and closes without an error message. According to my displays this happens while it tries to read the values on line 64 but the column seems more random…
    Well anyway, I’m going to use the alternative method recommended by Ralph which works whatever the HTBasic version.
    I put here my code using EXCEL reading which is defective

          CONFIGURE LONGFILENAMES ON
          DLL UNLOAD ALL
          OPTION BASE 1
          !
          CLEAR SCREEN
          KEY LABELS OFF
          !
          DIM C$[200]
          DIM Return$[50]
          DIM Data$(1:200,1:259)[20]
          DIM Disque1$[80],Disque2$[80],Disque3$[80]
          DIM Htb_version$[80]
          !
          LONG Hconvexcel! Excel conversation handle
          LONG Retval    ! Return value for the DLL functions
          !
          !------------------------------------------------
          ! Computers configuration
          !------------------------------------------------
          Htb_version$=SYSTEM$("VERSION:HTB")
          Htb_version$=TRIM$(Htb_version$)
          !
          SELECT Htb_version$
          !
          CASE "Windows Release 10.0.3"
               Disque1$="C:\Program Files (x86)\HTBwin10\DLL Toolkit\Samples\HTBDde"   ! 22/01/2009 13:32 => Runtime Error : L64C32 (16379)
               Disque2$="C:\Program Files (x86)\Microsoft Office\root\Office16"        ! EXCEL 2010
               Disque3$="C:\HP_progs\Progs"
               !
          CASE "Windows Release 10.1.3"
               Disque1$="C:\Program Files (x86)\HTBwin 10.1\DLL Toolkit\Samples\HTBDde"! 22/01/2009 13:32 => Runtime Error : L64C32
              !Disque1$="C:\Program Files (x86)\HTBasic 2021\DLL Toolkit\Samples\HTBDde"   ! 14/11/2020 09:44 => Runtime Error : L64C32
               Disque2$="C:\Program Files (x86)\Microsoft Office\root\Office16"        ! EXCEL 2010
               Disque3$="C:\HP_progs\Progs"
               !
          CASE "Windows Release 21.1.009"
               Disque1$="C:\Program Files (x86)\HTBasic 2021\DLL Toolkit\Samples\HTBDde"! 14/11/2020 09:44 => HTBasic Close : L64C...
              !Disque1$="C:\Program Files (x86)\HTBwin 10.1\DLL Toolkit\Samples\HTBDde"    ! 22/01/2009 13:32 => HTBasic Close : L64C...
               Disque2$="C:\Program Files (x86)\Microsoft Office\root\Office16"        ! EXCEL 2010
               Disque3$="C:\HP_progs\Progs"
               !
          END SELECT
          !
          PRINT Htb_version$
          PRINT Disque1$
          PRINT Disque2$
          PRINT Disque3$
          PRINT
          !
          !------------------------------------------------
          ! HTBDDE dll
          !------------------------------------------------
          MASS STORAGE IS Disque1$  ! Go to DDE Directory
          !
          DLL LOAD "HTBDDE"
          DLL GET "LONG HTBDDE:Ddeconnect"
          DLL GET "SHORT HTBDDE:Ddeterminate"
          DLL GET "LONG HTBDDE:Ddetimeout"
          DLL GET "SHORT HTBDDE:Ddeexecute"
          DLL GET "SHORT HTBDDE:Ddepoke"
          DLL GET "CHARPTR HTBDDE:Dderequest"
          DLL GET "SHORT HTBDDE:Runexe"
          !
          MASS STORAGE IS Disque3$  ! Return to my Directory
          !
          LIST DLL
          !
          !-------------------------------------------
          ! Connect to the EXCEL System topic
          !-------------------------------------------
          Hconvexcel=0
          Hconvexcel=FNDdeconnect("Excel","System")
          !
          IF Hconvexcel=0 THEN
             !
             ! If we couldn't connect, lauch EXCEL and try again
             !
             C$=Disque2$&"\Excel.exe"
             C$=TRIM$(C$)
             !
             Retval=0
             Retval=FNRunexe(C$,1)
             !
             PAUSE      ! Very long !!! I prefer to WAIT and [CONTINUE] manually
             !              ! when EXCEL is open
             !
             Hconvexcel=0
             WHILE Hconvexcel=0
                   Hconvexcel=FNDdeconnect("Excel","System")
                   WAIT .1
             END WHILE
             !
          ELSE
             !
             GOTO Exit
             !
          END IF
          !
          !-------------------------------------------
          ! OPEN selected workbook in DDE Directory
          !-------------------------------------------
          Fich$="sample.xlsx"
          !
          C$=Disque1$&"\"&Fich$
          C$="[OPEN("""&C$&""")]"
          C$=TRIM$(C$)
          !
          Retval=0
          Retval=FNDdeexecute(Hconvexcel,C$)
          !
          !--------------------------------------------
          ! Connexion on the selected Sheet
          !--------------------------------------------
          Hconvexcel=0
          Hconvexcel=FNDdeconnect("Excel","Sheet1")
          !
          !--------------------------------------------
          ! Read EXCEL Datas
          !--------------------------------------------
          ! => Error after 16379 read (L64C62) ???
          !--------------------------------------------
          Row$="L"
          Line_max=200
          Column_max=259
          !
          Total=0
          FOR Line=1 TO Line_max
              FOR Column=1 TO Column_max
                  !
                  C$=""
                  C$=Row$&VAL$(Line)&"C"&VAL$(Column)
                  C$=TRIM$(C$)
                  Return$=""
                  Return$=FNDderequest$(Hconvexcel,C$)
                  !
                  Total=Total+1
                  Data$(Line,Column)=Return$
                  PRINT Total,C$,Data$(Line,Column)
                  !
                 !C$="[SELECT("""&C$&""")]"
                 !C$=TRIM$(C$)
                 !Retval=0
                 !Retval=FNDdeexecute(Hconvexcel,C$)
                  !
              NEXT Column
          NEXT Line
          !
          !
               !--------------------------------------------
               ! Terminate the connection with EXCEL
               !--------------------------------------------
     Exit:     IF Hconvexcel=1 THEN
                  Retval=0
                  Retval=FNDdeterminate(Hconvexcel)! Terminate EXCEL DDE conversation
               END IF
               !
               DLL UNLOAD "HTBDDE"                ! Unload DDE dll
               PRINT "Finished"
               KEY LABELS ON
          !
          END
    Scroll to Top
    HTB icon

    Please Sign In