C++ Conversion Question

Everything else that doesn't fall into one of the other PB categories.
Worm
User
User
Posts: 20
Joined: Wed Apr 14, 2004 2:32 am
Location: Grand Rapids, MI
Contact:

C++ Conversion Question

Post 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.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

it look like this
foo.l(szBuff.s, *pnBuffSize.l, lpszInfo.s)
~Dreglor
Worm
User
User
Posts: 20
Joined: Wed Apr 14, 2004 2:32 am
Location: Grand Rapids, MI
Contact:

Post 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;
	}
}
Worm
User
User
Posts: 20
Joined: Wed Apr 14, 2004 2:32 am
Location: Grand Rapids, MI
Contact:

Post 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 :D
Post Reply