Announcement

Collapse
No announcement yet.

USB interface via Windows HID and PBdll6.0

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

  • USB interface via Windows HID and PBdll6.0

    Hi All,

    I am attempting to write the API calls and interface software to access the USB port via a dll. Attempts to use some of the API calls in PBdll has caused various problems with the compiler reporting 'Variable expected' and 'Previously defined variable' etc. For instance, it seems that the word 'Handle' is a keyword in PBdll, but is also used in several API calls, hence the 'Variable expected' report. Also, some of the Function declarations are normally defined as 'Boolean', which is not available as such (I have tried 'As long' for now).

    Has anyone managed to write a HID interface in PBdll 6.0, or have any advice please?

    Many thanks!

    Terry

  • #2
    It's possible to recognize reserved words by blue color.
    But I don't see problems with reserved words.
    When you Declare Function/Sub name of variable is not important
    (important AS ...)
    If function(sub) has "reserved name" it's also not a problem, because important Alias "..." and you can, for example, describe
    Declare Function MyPrint Lib "...." Alias "Print".

    There is only one not comfortable moment: unlike VB, it's not possible to use different names for functions/subs with the same Alias (I mean Declare Function MyPrint1 Lib "...." Alias "Print" and Declare Function MyPrint2 Lib "...." Alias "Print")

    ------------------

    Comment


    • #3
      HANDLE is a reserved keyword - see OPEN HANDLE for more information.

      BOOL types usually translate to a LONG in PB, but C code for very recent compilers may use BYTE instead (according to others on this BBS - I've not seen this myself). In general, use LONG and if it does not work, try BYTE.

      Also, be sure to check out www.lvr.com for information and possibly even example code for USB.

      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        Clarification on Booleans: in C, unlike PowerBASIC, symbols are case-sensitive. This means you need to take uppercase/lowercase distinctions into account when translating between the two languages. This is an issue with Boolean types in particular, because there are two distinct Boolean types involved in C and Windows programming, "BOOL" and "bool".

        The "BOOL" type is defined by the Windows API headers. This is the most common Boolean type you'll run across. It translates to a PowerBASIC "LONG" value.

        The "bool" type is intrinsic to later versions of Microsoft C. It's a non-traditional C type, and you probably won't see it used very often. It translates to a PowerBASIC "BYTE" value.

        Note that intrinsic C types may vary in size from one vendor to another and one machine to another, so "bool" may not always be translated as a "BYTE". However, as the "BOOL" definition is part of the standard Windows headers, you can rely on it being a "LONG"... at least until Microsoft gets serious about a 64-bit version of Windows!

        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment


        • #5
          Any chance of a BOOL data type added to the compiler sometime?

          ------------------
          Kev G Peel
          KGP Software
          Bridgwater, UK.
          mailto:[email protected][email protected]</A>

          Comment


          • #6
            Doubtful. Like C, PowerBASIC is fully capable of treating any integer value as a Boolean type, so adding a separate Boolean type wouldn't add any functionality to the compiler. Of course, if we get enough requests for it...

            ------------------
            Tom Hanlin
            PowerBASIC Staff

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎