I'm writing a trigger in a dbc (VFP6 SP5 + WXP).
the same trigger is for update over 250 files, with each around 200 fields.
On update, this trigger inserts a record in an other table.

All works ok, but I need to store the names of the fields from where this
trigger is run.

I have alias, dbf, working areas ; if I have field name, I can use oldval
and curval..
How can I retrieve field names ?

Thank you in advance for help

Michel (in France)

Re: wich field was updated ? by Gregory

Gregory
Tue Feb 03 07:49:37 CST 2004

Michel,

You can use GetFldState(-1) for that.

substr(GetFldState(-1), i, 1) is about field(i-1)
Dont' forget to compare oldval( field(i-1)) with eval( field(i-1) ). They
may be the same (changed and changed back) but GetFldState(-1) will mark it
as changed

Gregory
___________
"Michel Levy" <stop.michelvfplevy@yahoo.fr.nospam> wrote in message
news:%23HX1AUk6DHA.3704@tk2msftngp13.phx.gbl...
> I'm writing a trigger in a dbc (VFP6 SP5 + WXP).
> the same trigger is for update over 250 files, with each around 200
fields.
> On update, this trigger inserts a record in an other table.
>
> All works ok, but I need to store the names of the fields from where this
> trigger is run.
>
> I have alias, dbf, working areas ; if I have field name, I can use oldval
> and curval..
> How can I retrieve field names ?
>
> Thank you in advance for help
>
> Michel (in France)
>
>


Re: wich field was updated ? by Michel

Michel
Tue Feb 03 10:37:05 CST 2004

Thank you Gregory,

I'll try it. I had found getfldstate(-1), but I didn't know how I could use
it.

By the way, when I compare oldval(myfield) and curval(myfield) in that
trigger, I get the same value. Do you understand why ?

Michel

"Gregory Adam" <GregoryAdam@PleaseReplyViaNewsGroup.com> a écrit dans le
message de news:%23CcGvyl6DHA.1664@TK2MSFTNGP11.phx.gbl...
> Michel,
>
> You can use GetFldState(-1) for that.
>
> substr(GetFldState(-1), i, 1) is about field(i-1)
> Dont' forget to compare oldval( field(i-1)) with eval( field(i-1) ). They
> may be the same (changed and changed back) but GetFldState(-1) will mark
it
> as changed
>
> Gregory
> ___________
> "Michel Levy" <stop.michelvfplevy@yahoo.fr.nospam> wrote in message
> news:%23HX1AUk6DHA.3704@tk2msftngp13.phx.gbl...
> > I'm writing a trigger in a dbc (VFP6 SP5 + WXP).
> > the same trigger is for update over 250 files, with each around 200
> fields.
> > On update, this trigger inserts a record in an other table.
> >
> > All works ok, but I need to store the names of the fields from where
this
> > trigger is run.
> >
> > I have alias, dbf, working areas ; if I have field name, I can use
oldval
> > and curval..
> > How can I retrieve field names ?
> >
> > Thank you in advance for help
> >
> > Michel (in France)
> >
> >
>



Re: wich field was updated ? by Gregory

Gregory
Wed Feb 04 02:19:12 CST 2004

Michel,

The updates are not performed until the trigger successfully exits.

Help says that curval() retrieves the value directly from disk. If no one
else has updated the field in the meantime, oldval() and curval() will be
equal.

this may be useful

function FieldChanged(FieldName)

do case
case isnull(oldval(FieldName)) or Isnull(eval(FieldName))
return (isnull(oldval(FieldName)) <> Isnull(eval(FieldName)) )
otherwise
return (oldval(FieldName) <> eval(FieldName))
endcase
endfunc

Gregory
_____________
"Michel Levy" <stop.michelvfplevy@yahoo.fr.nospam> wrote in message
news:OAyPrPn6DHA.2404@TK2MSFTNGP11.phx.gbl...
> Thank you Gregory,
>
> I'll try it. I had found getfldstate(-1), but I didn't know how I could
use
> it.
>
> By the way, when I compare oldval(myfield) and curval(myfield) in that
> trigger, I get the same value. Do you understand why ?
>
> Michel
>
> "Gregory Adam" <GregoryAdam@PleaseReplyViaNewsGroup.com> a écrit dans le
> message de news:%23CcGvyl6DHA.1664@TK2MSFTNGP11.phx.gbl...
> > Michel,
> >
> > You can use GetFldState(-1) for that.
> >
> > substr(GetFldState(-1), i, 1) is about field(i-1)
> > Dont' forget to compare oldval( field(i-1)) with eval( field(i-1) ).
They
> > may be the same (changed and changed back) but GetFldState(-1) will mark
> it
> > as changed
> >
> > Gregory
> > ___________
> > "Michel Levy" <stop.michelvfplevy@yahoo.fr.nospam> wrote in message
> > news:%23HX1AUk6DHA.3704@tk2msftngp13.phx.gbl...
> > > I'm writing a trigger in a dbc (VFP6 SP5 + WXP).
> > > the same trigger is for update over 250 files, with each around 200
> > fields.
> > > On update, this trigger inserts a record in an other table.
> > >
> > > All works ok, but I need to store the names of the fields from where
> this
> > > trigger is run.
> > >
> > > I have alias, dbf, working areas ; if I have field name, I can use
> oldval
> > > and curval..
> > > How can I retrieve field names ?
> > >
> > > Thank you in advance for help
> > >
> > > Michel (in France)
> > >
> > >
> >
>
>


Re: wich field was updated ? by Michel

Michel
Wed Feb 04 07:35:53 CST 2004

Thank you, Gregory

getfldstate(-1 ) is exactly that I needed, the trigger run as I want.
Of course, you are right : inside the trigger, oldval and curval are equal,
but oldval and eval are different (when they are...)

Michel

____________
"Gregory Adam" <GregoryAdam@PleaseReplyViaNewsGroup.com> a écrit dans le
message de news:OjUssev6DHA.1672@TK2MSFTNGP12.phx.gbl...
> Michel,
>
> The updates are not performed until the trigger successfully exits.
>
> Help says that curval() retrieves the value directly from disk. If no one
> else has updated the field in the meantime, oldval() and curval() will be
> equal.
>
> this may be useful
>
> function FieldChanged(FieldName)
>
> do case
> case isnull(oldval(FieldName)) or Isnull(eval(FieldName))
> return (isnull(oldval(FieldName)) <> Isnull(eval(FieldName)) )
> otherwise
> return (oldval(FieldName) <> eval(FieldName))
> endcase
> endfunc
>
> Gregory
> _____________
> "Michel Levy" <stop.michelvfplevy@yahoo.fr.nospam> wrote in message
> news:OAyPrPn6DHA.2404@TK2MSFTNGP11.phx.gbl...
> > Thank you Gregory,
> >
> > I'll try it. I had found getfldstate(-1), but I didn't know how I could
> use
> > it.
> >
> > By the way, when I compare oldval(myfield) and curval(myfield) in that
> > trigger, I get the same value. Do you understand why ?
> >
> > Michel
> >
> > "Gregory Adam" <GregoryAdam@PleaseReplyViaNewsGroup.com> a écrit dans le
> > message de news:%23CcGvyl6DHA.1664@TK2MSFTNGP11.phx.gbl...
> > > Michel,
> > >
> > > You can use GetFldState(-1) for that.
> > >
> > > substr(GetFldState(-1), i, 1) is about field(i-1)
> > > Dont' forget to compare oldval( field(i-1)) with eval( field(i-1) ).
> They
> > > may be the same (changed and changed back) but GetFldState(-1) will
mark
> > it
> > > as changed
> > >
> > > Gregory
> > > ___________
> > > "Michel Levy" <stop.michelvfplevy@yahoo.fr.nospam> wrote in message
> > > news:%23HX1AUk6DHA.3704@tk2msftngp13.phx.gbl...
> > > > I'm writing a trigger in a dbc (VFP6 SP5 + WXP).
> > > > the same trigger is for update over 250 files, with each around 200
> > > fields.
> > > > On update, this trigger inserts a record in an other table.
> > > >
> > > > All works ok, but I need to store the names of the fields from where
> > this
> > > > trigger is run.
> > > >
> > > > I have alias, dbf, working areas ; if I have field name, I can use
> > oldval
> > > > and curval..
> > > > How can I retrieve field names ?
> > > >
> > > > Thank you in advance for help
> > > >
> > > > Michel (in France)
> > > >
> > > >
> > >
> >
> >
>