Frontier DLL programming problem with xOdbDefined

Brian Andresen brian at techsoln.com
Thu Jan 17 09:21:53 PST 2002


On 1/17/2002 7:27 AM, Steven Manschot <steven at manschot.net> wrote:

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

>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.

>BTW what is the purpose of the "\x12" in front of "scratchpad.testvalue"?

This is called a Pascal string; a leading byte gives the length of the 
string that follows it.  [ Actually, Mr. Spolsky has a different name for 
this particular format... 
<http://www.joelonsoftware.com/articles/fog0000000319.html> ;-) ]

Note that "user.myextdllvalue" has 0x12 characters, but 
"scratchpad.testvalue" has 0x14.  So change that \x12 to a \x14.


If you're running a MacOS-hosted compiler, you should be able to use the 
magic character '\p', which makes the compiler do the tedious work of 
counting characters in the string literal that follows.  For example:

>		if ((*(proctable->xOdbDefined)) (odb, "\pscratchpad.testvalue")) 

or

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

An added benefit is that you don't have to remember to correct the length 
byte whenever you change that name.  But, your mail client says that 
you're probably coding on Windows, and I don't recall whether CodeWarrior 
on Win32 supports this feature.  You'll be able to find that out much 
quicker than I will.

-Brian




More information about the Frontier-Users mailing list