Hello all,
I have a lib that has a function that from the header file returns the following:
Returns: UINT16_T ver_info High byte is major version number
Low byte is minor version number
A couple of questions:
If this function takes no parametes, what would the declare look like (I am trying to use Import .. EndImport?
What type would I use for the return value and how would I be able to get the high byte vs the low byte?
Thanks.
Chris
Import question
Re: Import question
You might post that piece of code please?cseymour wrote:Hello all,
I have a lib that has a function that from the header file returns the following:
Returns: UINT16_T ver_info High byte is major version number
Low byte is minor version number
UINT16 means an unsigned 16bit variable. 16bit Variables in PB are 'word' ones, but as in PB variables are handled as signed ones in general you can use a 'long' as receiving following by an "& $FFFF" to receive the unsigned word value.
So in the C/C++ Code
Code: Select all
UINT16 ver_info(void) {
return versNumber;
}(as you only need the high/low-bytes (8bits each) its enough to use a PB 'word' .w)
UnsignedLowByte.w = ver_info() & $FF
UnsignedHighByte.w = ver_info() >> 8 & $FF
Last edited by inc. on Fri Aug 04, 2006 4:40 pm, edited 1 time in total.
Check out OOP support for PB here!
Here is the code from the header file:
/****************************************************************************
tkcmdsetUSB_get_dll_version()
Returns the current version number of this software.
Inputs: None
Outputs: None
Returns: UINT16_T ver_info High byte is major version number
Low byte is minor version number
****************************************************************************/
PM3USB_API UINT16_T tkcmdsetUSB_get_dll_version(void);
I have this in my PB code:
ImportC "RPPM3USB.lib"
tkcmdsetUSB_get_dll_version.l()
EndImport
LonVar.l = tkcmdsetUSB_get_dll_version() & $FFFF
MessageRequester("Test","DLL version is " + Str(LonVar.l))
Am I on the right track?
Thanks.
Chris
/****************************************************************************
tkcmdsetUSB_get_dll_version()
Returns the current version number of this software.
Inputs: None
Outputs: None
Returns: UINT16_T ver_info High byte is major version number
Low byte is minor version number
****************************************************************************/
PM3USB_API UINT16_T tkcmdsetUSB_get_dll_version(void);
I have this in my PB code:
ImportC "RPPM3USB.lib"
tkcmdsetUSB_get_dll_version.l()
EndImport
LonVar.l = tkcmdsetUSB_get_dll_version() & $FFFF
MessageRequester("Test","DLL version is " + Str(LonVar.l))
Am I on the right track?
Thanks.
Chris
This above is not a codesniplet but a Library API descripton 
As its a lib - if needed do also link with the msvcrt library:
Both minor and major numbers are shown in their unsigned values.

As its a lib - if needed do also link with the msvcrt library:
Code: Select all
Import "msvcrt.ib"
Endimport
ImportC "RPPM3USB.lib"
tkcmdsetUSB_get_dll_version.l()
EndImport
result.w = tkcmdsetUSB_get_dll_version() ; // store 'unsigned 16bit' integer in 'result.w'
minorVersNumber.w = result & $FF
majorVersNumber.w = result >> 8 & $FFNope, not right on track in your case as using '& $FFFF' on a Long (in PB a signed 32bit integer) will give you the unsigned lowWord, but you need the low and the high bytes from the resulting unsigned 16bit integeronVar.l = tkcmdsetUSB_get_dll_version() & $FFFF
Check out OOP support for PB here!

