tnx very much for your answer,
first let me say to u that i have a struct called MyStruct and the pForm is
define like that:
MyStruct *pForm;
so as u can see it is a pointer to my structure. which is :
// form structure
typedef struct
{
char SrvCall[9]; // 8 digits + 1 NULL terminatore
char AutoDate[10]; // 10 fo full date 12/08/1979 +
// 1 NULL terminatore
Boolean statuse; // show the statuse: 1 for OPEN
// and 0 for CLOSE
char RecivedBy[20+1]; // 20 for the name long
char SrvType[15+1]; // 15 for service type
char description[40+1]; // 40 for the description first word.
// this should open a window to enter
// free text and show on the main form
// only the first line of the free text.
char PartsNeeded[18+1]; // show how much parts needed
char Conclusion[40+1]; // another free text field that show the
// first line (like the field "description")
char FromTime[dateStringLength+1]; // show thw started time - "12:45"
char ToTime[dateStringLength+1]; // does the same thing like
"FromTime"
char summery[5]; // containn the summery of the times (sub)
}
MyStruct;
secound, i see what u saying about "variable-length record", i think that
this is my mistake - i use the dmWrite to write one long string seperated by
'\0' and i'm not writing it to the record's field itself.
i think it came from the idea about the pack and unpack structure records,
but i didn't understood it much ( i do have the Oreilly book ).
so what u suggest to do? how should i write my data to the record's fields??
should i keep using the dmWrite? in what way ??
i hope to hear from u soon, u really enlighted me,
byeee :-)
"Richard M. Hartman" <[EMAIL PROTECTED]> wrote in message
news:34475@palm-dev-forum...
>
>
> Eliah NInyo wrote in message <34442@palm-dev-forum>...
> >
> >hello,
> >
> >i have an application with a database.
> >i have a form where i fill in data which i want to keep in the database
> >record.
> >
> >i creat a database and a record, and this stuff is ok.
> >
> >the problem start here:
> >
> >i get a pointer to the text of every field i have,
> >
> >hFld1 = FldGetTextHandle ( ptrToTheField );
> >// FieldPtr ptrToTheField = (FieldPtr) FrmGetObjectPtr ( ptrToTheForm,
> >resorce_id);
> >
> >CharPtr pFld1 = (CharPtr) MemHandleLock (hFld1);
> >
> >and so on to Fld2, Fld3 ...
> >( not all the fiels r text fields, one is a Ctrl field and more )
> >
> >then i set the fields values to the record,
> >
> >Err err = DmWrite ( p, offset, TextP, StrLen ( TextP ) + 1 );
> >// p is a poiter to the record,
> >// offset is a number which i change according to the string length (it
> >works good, i know it for the
> > debugging process),
>
> Remember you said this ...
>
> >// TextP is the poiter to the text of the field. actually it points to
> >pFld1...N (N fields).
> >
> >the problem start when i wand to draw Fld1, Fld2 and Fld3 in a table row
> >with the apropriate function. ( TableDrawFunc... )
> >to get the data of a fiels i call a sample function that return CharPtr,
> >
> >the_Text = GetTheFieldText ();
> >
> >GetTheFieldText is define like this -
> >
> >CharPtr GetTheFieldText ( void )
> >{
> > return (pForm -> Fld1 );
> >}
> >// pForm is a pointer to my record structure,
>
> To your -record- structure, or the form?
>
> >// Fld1 is one of the field of the structure.
> >
> >the function return the correct data for the first field. ( Fld1 is a
> >numeric field which can get 8 digit only).
> >for the secound fiels the data is not always right. if i enter to Fld1
all
> >the 8 digits then i get the right data for Fld2, but if i enter to Fld1,
> >lets say - 3 digits, i get only one or two chars from the Fld2 data. and
> >fld3 is totaly incorrect. (even when i enter 8 digits to Fld1 )
> >
> >is anyone see an error?? is anyone has an idea how to see a record
context
> >??
> >
> >
>
> I would have to see the struct you are using for pForm ... but if it
> is indeed your record struct and not the form ptr, you still have
> a problem.
>
> Remember you said you change the DmWrite offset according to the
> length of the strings you are storing? Well ... that means you have
> a variable-length record. T'ain't no struct in the world that you can
> map that onto.
>
> You need to decode the stuff in your database properly in order
> to use it.
>
> One way is to have fixed width fields.
>
>
> You can either write that directly (potentially wasteful), or keep writing
> the way you are
> now but use the struct w/ the fixed-width fields it as an intermediate
> step when reading from the database.
>
> You could also scan the db record to determine where the first
> string ends (and thus where the second string begins) and remember
> the start offsets of each string.
>
> Check the O'Reilly book for the discussion of packing & unpacking
> records. It can be found online here:
>
> http://palm.3com.com/devzone/docs/pptdg/ch06.htm#P615_35697
>
> --
> -Richard M. Hartman
> [EMAIL PROTECTED]
>
> 186,000 mi/sec: not just a good idea, it's the LAW!
>
>
>
>
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/