Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Cannot perform string cast on type TEMPn error

Author
Message
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 22nd Jun 2007 21:04 Edited at: 22nd Jun 2007 21:11
Hi, i'm still pluggung away at making a DBP DLL and I'm stuck again..

Trying to return a string, well a DWORD to one at least but I think I'm doing something wrong a the DBP end as i can't seem to get the value into a string$

b$ = DF_ReturnString()

always get this error

"Cannot perform string cast on type TEMP0 "

i've tried putting pionter * all over the show

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 22nd Jun 2007 21:18 Edited at: 22nd Jun 2007 21:22
I've tried this, but it don't work, so how do I get my DWORD back into string?

Ptr as DWORD
Ptr=DF_ReturnString()
`*Ptr=DF_ReturnString()
`b$ = Ptr
PRINT Ptr

the above just prints some numbers instead of "hello"

Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 23rd Jun 2007 02:15
I answered this question in your wip encryption thread.

Who needs a signature?
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 23rd Jun 2007 02:18
Thanx, i'll just copy the answer here incase it's of use to anyone else in the future (but i wont have time to test it until tomorrow)...


main.cpp
+ Code Snippet
#define DBPCMD extern "C" __declspec ( dllexport )
typedef unsigned int uint;

char* str = "hello world";
DBPCMD uint ReturnString( )
{
return (uint)str;
}


stringtable.rc
+ Code Snippet
STRINGTABLE
BEGIN
1 "RETURN STRING[%S%ReturnString"
END


DBP code
+ Code Snippet
str as string
str = return string()
print str
wait key

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Jun 2007 14:22
No. That's the DBC way of returning strings and it's wrong for DBPro.



That should be enough to get you returning strings properly. Oh, and make sure you read the technical document on third-party commands before you do more - it's available on the main page of the DBPro help.

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 23rd Jun 2007 23:35
argh why can't making a DLL be easy

I guess C++ string don't sit neatly into DWORDS.

Thanx for the heads up.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Jun 2007 15:04
They do actually - they are the same size datatype - there's just no point in doing so, and can let bugs creep into your code if you are not careful.

The only data type that you *must* cast is the float, and even that can be gotten around by returning a double and setting the resource string to return a double float too.

Login to post a reply

Server time is: 2024-11-22 21:47:01
Your offset time is: 2024-11-22 21:47:01