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

47506Re: [LIBERTYBASIC] liberty basic translation

Expand Messages
  • Stefan Pendl
    May 5, 2014
      Am 05.05.2014 17:49, schrieb Jeff Lehman:
      > Thanks for your response.
      > In regards to trying to read the input bit values, they give and example
      > for using c / c+
      > int cbDIn (int BoardNum, int PortNum, unsigned short *DataValue)
      > seeing as how their software can read data from up to 99 units, the
      > boardnum represents which unit (in this case, board 1), the portnum is
      > which 8 bit port to use (the unit has 3), and I assume that the
      > DataValue is the returning information at the the byte input (0-255).
      > Would you have an idea as how to translate the "c" version into
      > something that liberty basic would understand?

      See below.

      Since the DataValue variable is passed by reference (notice the
      asterisk), you need to use a structure, so the API function can fill in
      the value.

      The return value is an integer and not a void (nothing), so the VB
      translation used that to ignore the value, but that should not be used
      with LB.

      '---code start (watch for line wraps)

      struct DataValue, value as word

      calldll #cbw32, "cbDIn", _
      BoardNum as long, _
      PortNum as long, _
      DataValue as struct, _
      result as long

      print DataValue.value.struct

      '---code end

      Stefan Pendl

      LB 4.04 Pro ... http://www.libertybasic.com/assist.html
      LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

      LB Community Wiki .............. http://basic.wikispaces.com/
      LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
      LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

      Books at http://www.lulu.com/ and http://www.amazon.com/
      Alyce Watson ... APIs for Liberty BASIC
      Carl Gundel .... Beginning Programming with Liberty BASIC

      Windows 7 Home Premium 64-bit SP1
      AMD Turion X2 RM-70 2GHz, 4GB RAM
    • Show all 4 messages in this topic