Announcement

Collapse
No announcement yet.

Cliff Nichols' USB and Network code

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

  • Cliff Nichols' USB and Network code

    The USB and Network code, as posted by Cliff Nichols in the Source Code forum (http://www.powerbasic.com/support/pb...ad.php?t=39661) does not compile. The error is: Missing declaration for GetUdtDeviceEvent.

    Version problem? I'm still using PBWin 8.4.

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    Code Edited

    Sorry about that. I forgot PB9 lets you get away with not declaring a function, so I never caught that I missed one.

    Code in source code forum has now been edited to include
    Code:
    DECLARE FUNCTION GetUdtDeviceEvent( _
                                  DeviceBroadCastHeader AS DEV_BROADCAST_HDR, _
                                  DeviceBroadCastOem AS DEV_BROADCAST_OEM, _
                                  DeviceBroadCasteDevNode AS DEV_BROADCAST_DEVNODE, _
                                  DeviceBroadCastVolume AS DEV_BROADCAST_VOLUME, _
                                  DeviceBroadCastPort AS DEV_BROADCAST_PORT, _
                                  DeviceBroadCastNet AS DEV_BROADCAST_NET, _
                                  DeviceBroadCastDeviceInterface AS DEV_BROADCAST_DEVICEINTERFACE, _
                                  DeviceBroadCastHandle AS DEV_BROADCAST_HANDLE, _
                                  BYVAL lParam AS LONG _
                             )AS STRING
    Hmmmm....makes me wonder if there is a compiler directive to still force me to declare all subs and functions, or if I am at the mercy of my own mind to double-triple check that I got them all???
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

    Comment


    • #3
      Didn't help very much. Apparently there's more that needs to be declared. Now I ran into an "undefined type" error for DEV_BROADCAST_HDR.

      A further remark: declarations for functions inside an Include-file need to be done before the #INCLUDE metastatement, so this is the correct order:
      Code:
      #COMPILE EXE
      #DIM ALL
      GLOBAL hDlg  AS DWORD
      
      '------------------------------------------------------------------------------
      '   ** Constants **
      '------------------------------------------------------------------------------
      %IDD_DIALOG1 = 101
      %TxtDeviceNotify = 102
      '------------------------------------------------------------------------------
      
      '------------------------------------------------------------------------------
      '   ** Declarations **
      '------------------------------------------------------------------------------
      DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
      DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
      DECLARE FUNCTION GetUdtDeviceEvent( _
                                    DeviceBroadCastHeader AS DEV_BROADCAST_HDR, _
                                    DeviceBroadCastOem AS DEV_BROADCAST_OEM, _
                                    DeviceBroadCasteDevNode AS DEV_BROADCAST_DEVNODE, _
                                    DeviceBroadCastVolume AS DEV_BROADCAST_VOLUME, _
                                    DeviceBroadCastPort AS DEV_BROADCAST_PORT, _
                                    DeviceBroadCastNet AS DEV_BROADCAST_NET, _
                                    DeviceBroadCastDeviceInterface AS DEV_BROADCAST_DEVICEINTERFACE, _
                                    DeviceBroadCastHandle AS DEV_BROADCAST_HANDLE, _
                                    BYVAL lParam AS LONG _
                               )AS STRING
      '------------------------------------------------------------------------------
      
      '------------------------------------------------------------------------------
      '   ** Includes **
      '------------------------------------------------------------------------------
      #IF NOT %DEF(%WINAPI)
          #INCLUDE "WIN32API.INC"
      #ENDIF
      #IF NOT %DEF(%DEVICENOTIFY)
           #INCLUDE "DeviceNotify.INC"
      #ENDIF
      '------------------------------------------------------------------------------

      Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
      http://zijlema.basicguru.eu
      *** Opinions expressed here are not necessarily untrue ***

      Comment


      • #4
        Now I ran into an "undefined type" error for DEV_BROADCAST_HDR.
        ??????

        I went back and checked and re-checked, and no problem with 8.04 and up, and then I tried moving the declarations like you showed. and THAT is when the error occurs because Declaring Functions that use types before the type is defined will cause the error.

        Which is why the Declares are Declared where they are.
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

        Comment


        • #5
          Cliff,

          I get either the first mentioned error or the other one when changing "the order of appearance" in the demo-file. To be honest, I get the feeling that the code as posted is incomplete. Can you please post a zip attachment of the code that worked under PBWin 8.04?

          Thanks,

          Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
          http://zijlema.basicguru.eu
          *** Opinions expressed here are not necessarily untrue ***

          Comment


          • #6
            Updated Source Code Forum and included a .zip of the exe compiled with PB 8.04
            http://www.powerbasic.com/support/pb...ad.php?t=39661

            Engineer's Motto: If it aint broke take it apart and fix it

            "If at 1st you don't succeed... call it version 1.0"

            "Half of Programming is coding"....."The other 90% is DEBUGGING"

            "Document my code????" .... "WHYYY??? do you think they call it CODE? "

            Comment

            Working...
            X