Convert C++ code to PB
Posted: Fri Mar 02, 2012 12:46 am
Hello!
I have such a code in C++, which I try to convert to PB, but something isn't right:
...
...
My version in PB is:
I get result, which tells that invalid argument passed to function (not Problem waiting for attachment). Any idea why?
Thank you.
I have such a code in C++, which I try to convert to PB, but something isn't right:
...
Code: Select all
CPhidgetTemperatureSensorHandle temp = 0;
CPhidgetTemperatureSensor_create(&temp);
CPhidget_open((CPhidgetHandle)temp, -1);
if((result = CPhidget_waitForAttachment((CPhidgetHandle)temp, 2000)))
{
printf("Problem waiting for attachment:\n");
return 0;
}
My version in PB is:
Code: Select all
If OpenLibrary(0,"phidget21.dll")
*tmp = AllocateMemory(1024)
*CPhidgetTemperatureSensor_create = GetFunction(0, "CPhidgetTemperatureSensor_create")
If *CPhidgetTemperatureSensor_create
CallFunctionFast(*CPhidgetTemperatureSensor_create, *tmp)
*CPhidget_open = GetFunction(0, "CPhidget_open")
If *CPhidget_open
CallFunctionFast(*CPhidget_open, tmp, -1)
*CPhidget_waitForAttachment = GetFunction(0, "CPhidget_waitForAttachment")
If *CPhidget_waitForAttachment
Result.i = CallFunctionFast(*CPhidget_waitForAttachment, tmp, 10000)
If Result <> 0
MessageRequester("ERROR", Str(Result))
EndIf
EndIf
EndIf
EndIf
CloseLibrary(0)
EndIf
Thank you.