Page 1 of 1

Return a string via MSVC (Purebasic 4.00)

Posted: Thu Jul 06, 2006 10:42 am
by MushroomHead
In Purebasic 3.94, I use the following code to return a string :-

Code: Select all

#include <windows>
#include <stdio>

extern "C"
{

	extern char *PB_StringBase;

	extern char *PB_Getit()
	{
		char *ResultString = PB_StringBase;
		int StringLength = strlen("HelloWorld!");
		
		strcpy(PB_StringBase, "HelloWorld!");
		PB_StringBase += StringLength;
		*PB_StringBase = 0;

		return ResultString;
	}
}
In Purebasic 4.00, this code crashes the compiler ... can someone show me how to correctly return strings in pb 4.00?

Thanks.

Posted: Thu Jul 06, 2006 1:17 pm
by Flype
you might be interested of the sample code provided by the purebasic team:

see here :
[...]\PureBasic\Library SDK\LccWin32\SimpleLibrary

in particular, open the StringMultiply.c source file.

Posted: Thu Jul 06, 2006 2:29 pm
by KarLKoX
You can also see this :)

Posted: Thu Jul 06, 2006 10:46 pm
by MushroomHead
Flype wrote:you might be interested of the sample code provided by the purebasic team:

see here :
[...]\PureBasic\Library SDK\LccWin32\SimpleLibrary

in particular, open the StringMultiply.c source file.
I've had a look, the problem is that code is for LCCWIN and I'm using MSVC 6.0 ... I don't know how these functions below can be coded in MSVC :-

Code: Select all

	M_PBFUNCTION int   SYS_GetParameterIndex(const TCHAR *Parameter);
	M_PBFUNCTION TCHAR *SYS_GetOutputBuffer(int Length, int PreviousPosition);
	M_PBFUNCTION TCHAR *SYS_ResolveParameter(int Index);
Correct me if I'm wrong, they appear to be compiler specific to LCCWIN? If they are in MSVC, what libraries (.LIB) to link your code to?

Posted: Mon Jul 10, 2006 9:15 am
by real
Want do you want to code? A userlib?