Return a string via MSVC (Purebasic 4.00)

Just starting out? Need help? Post your questions and find answers here.
MushroomHead
User
User
Posts: 15
Joined: Wed Apr 27, 2005 2:55 pm

Return a string via MSVC (Purebasic 4.00)

Post 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.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post 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.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

You can also see this :)
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
MushroomHead
User
User
Posts: 15
Joined: Wed Apr 27, 2005 2:55 pm

Post 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?
real
User
User
Posts: 49
Joined: Fri Oct 08, 2004 5:17 am

Post by real »

Want do you want to code? A userlib?
Post Reply