Frontier DLL programming problem with xOdbDefined

Andre Radke lists at spicynoodles.net
Thu Jan 17 09:25:48 PST 2002


At 16:27h +0100 17.01.2002, Steven Manschot wrote:
>I've made a test dll with a function called MagickTest3:
>
>odbBool CALLBACK MagickTest3 (tydllparamblock * data, XDLLProcTable 
>* proctable) {
>	odbRef odb;
>
>	odb = (*(proctable->xOdbGetCurrentRoot)) ();
>
>	if (odb != NULL) {
>		if ((*(proctable->xOdbDefined)) (odb, "\x12" 
>"scratchpad.testvalue")) {	// <-- Fails
>			return(TRUE);
>		}
>	}
>
>	return (FALSE);
>}
>
>In the scratchpad table, in the Radio.root odb, I created a number 
>called "testvalue".
>The function returns FALSE and I have no idea why...
>
>In the examples for writing a DLL there's a function called 
>"Counter" with sets a value called "user.myextdllvalue". This one
>works fine with the xOdbDefined function. Is it because it creates 
>the value itself instead?
>
>BTW what is the purpose of the "\x12" in front of "scratchpad.testvalue"?

That's the root cause of your problem. For historic reasons, the DLL 
interface uses pascal strings where the first byte indicates the 
length of the string. In your case, the length of 
"scratchpad.testvalue" is 20 bytes (14 in hex), so the call to 
xOdbDefined should look as follows:

(*(proctable->xOdbDefined)) (odb, "\x14" "scratchpad.testvalue")

The reason why xOdbDefined seemed to return the wrong result for you 
is that you actually asked Frontier whether "scratchpad.testval" was 
defined -- I presume it wasn't.

On the Mac, C compilers let you indicate that a literal string is to 
be treated as a pascal string at compile time by setting the first 
character of the string to \p, i.e. in your case you could just write 
"\pscratchpad.testvalue" and the compiler would insert the correct 
length byte. Unfortunately, this convention does not seem to be 
supported by Visual Studio.

-Andre




More information about the Frontier-Users mailing list