Quote: "Returning a string isn't the problem, it's getting the string into the function. And yes, I know it sends a pointer, not the string to a function."
Just to clarify when dbpro calls a plugin function that returns a string it sends a pointer to an old string followed by the rest of the parameters specified in the string table.
So if you where to try to use a function like this
Public Shared Function function(ByVal test As String) As String
MessageBox.Show(test)
Return "a string"
End Function
The string will appear to be lost as dbpro is actully calling the function as
function(pOldString, test)
Your function will then have the value of pOldString instead of what it was expecting. If the dbpro exe has just started an no other strings have been returned the pOldString is probely just pointing to an empty string.
What you should actually use is something like this
Public Shared Function function(ByVal pOldString As Integer,ByVal test As String) As Int
`use dbpro memory managment funtions to delete pOldString if required and create a new string
Return dword pointer to new string
End Function
As per the example in the TPC docs
DWORD ReverseString( DWORD pOldString, DWORD pStringIn )
{
// Delete old string
if(pOldString) g_pGlob->CreateDeleteString ( (DWORD*)&pOldString, 0 );
// Return string pointer
LPSTR pReturnString=NULL;
// If input string valid
if(pStringIn)
{
// Create a new string and copy input string to it
DWORD dwSize=strlen( (LPSTR)pStringIn );
g_pGlob->CreateDeleteString ( (DWORD*)&pReturnString, dwSize+1 );
strcpy(pReturnString, (LPSTR)pStringIn);
// Reverse the new string
strrev(pReturnString);
}
// Return new string pointer
return (DWORD)pReturnString;
}
Quote: "this is not a quote"