Page 1 of 1
C++ Conversion Question
Posted: Sun Feb 11, 2007 1:28 pm
by Worm
I have the source to a C++ SDK that I'd like to try convert to PB. Would someone be kind enough to point me in the right direction on how to convert the parameters to the correct variable types.
example C++:
int foo(char* szBuff, int* pnBuffSize, char* lpszInfo)
Thanks.
Posted: Sun Feb 11, 2007 1:39 pm
by Trond
If you want to call it from PB:
String, Long and String
If you want to remake the function in PB:
String, *Pointer.Long and String
Posted: Sun Feb 11, 2007 9:07 pm
by Dreglor
it look like this
foo.l(szBuff.s, *pnBuffSize.l, lpszInfo.s)
Posted: Mon Feb 12, 2007 12:46 am
by Worm
Thanks... I've tried the methods described, and many different variations of my own, and having very little luck. I think its my bad understanding of how a pointer is used in PB thats knocking me down.
Here's the function I'm trying to convert. szBuffer is a pointer to a character buffer that will receive the value of szOName. pnBSize will bring in/take out the length of szBuffer.
Code: Select all
char szOName[] = "Sample";
int GetName(char* szBuffer, int* pnBSize)
{
int nLength = lstrlen(szOName);
if(*pnBSize < nLength)
{
*pnBSize = nLength;
return -1;
} else
{
memset(szBuffer,0,*pnBSize);
lstrcpy(szBuffer,szOName);
return nLength;
}
}
Posted: Mon Feb 12, 2007 2:06 am
by Worm
Got it... thanks to all.
I have browsed the help file many-a-time and missed the blurb on pointer needing the * in front of them all the time.
Feels good
