You sure about your offset? I usually do something like:
struct xxx {
char foo;
long goo;
char zoo[10];
} yyy;
const struct xxx *pNIL = (struct xxx *)NULL;
const long offset = (unsigned long)&(pNil->zoo);
DmWrite(ptr, offset, &yyy.zoo, 10);
Really ugly, but not really any other way to get the compiler to tell you
how it laid out the structure. (In this case the offset will be 2, not 1)
The const's help the compiler not actually allocate the variables.
LL
At 07:30 PM 12/29/99 -0600, Bryan Nystrom wrote:
>Chris,
>
>Sorry. You are correct that it is dangerous to post pseudo code. The example
>was misleading. The problem occurs with a single DmWrite of a length byte.
>The DmWrite in the example of length long was only to emphasis that similar
>calls to DmWrite of different lengths work fine. essentially, the DmWrite is
>about the only call in the function. So a better pseudo example would be:
>
>myClass::saveFieldx()
>{
> Byte m_x = 50;
> Long offset_to_x = 6;
>
> DmWrite( m_src, offset_to_x ,&m_x , sizeof( m_x));
>}
>
>... but the same function works when the type of m_x is anything other than
>Byte.
>
>I am actually stepping through the code and checking the value of v_src
>before and after the DmWrite call. If src->m_x starts out as 5, and then I
>do a DmWrite to set it to 50, the value ends up 0.
>
>Sorry, I can't post the real code. Have you actually done this with CW R6 in
>C++ member function?
>
>-----Original Message-----
>From: Chris Antos [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, December 29, 1999 5:56 PM
>To: [EMAIL PROTECTED]
>Subject: Re: DmWrite behavior.
>
>
> > Maybe this is something I missed somewhere (rtfm?), but I am finding that
>a
> > DmWrite with a size of Byte (1) fails.
>
>works for me, and i do it a LOT in my app.
>
>
> > Pseudo code:
> > {
> > ...
> > Byte level = 100;
> > Long longLevel = 100;
> >
> > DmWrite( src, offset, &level, sizeof(level) ); // Sets value to 0
> > regardless.
> > DmWrite( src, offset, &longLevel, sizeof(longlevel) ); // Works fine!
> >
> > ... // actually, level is a member variable of the class, but that
> > shouldn't matter.
> > }
>
>did you remember to increment offset after the first DmWrite?
>
>it's dangerous to post pseudo code - that can often hide the problem. how
>about posting your class definition, and also the actual function that is
>making the DmWrite calls?
>
>
>