Page 1 of 1

undo gets [newbye]

Posted: Sun Aug 26, 2007 8:18 am
by claudio.driussi
I'm not very skilled in fwppc and x/harbour at all.

The dummy question is:
It is a way to restore original values of all get and other
controls of a form?

Lurking on TGet class i seen undo method, but i need a
variable to call the instance, there are a way to collect
all gets from parent window?
And how to undo other controls?

If there are no easy way to do this, the solution as usual
is to copy data to edit in temporary array but i hope in
something better.

Best Regards
Claudio Driussi

Posted: Sun Aug 26, 2007 10:11 am
by Antonio Linares
Claudio,

>
It is a way to restore original values of all get and other
controls of a form?
>

Try this:

Code: Select all

for n = 1 to Len( oWnd:aControls )
   if oWnd:aControls[ n ]:ClassName == "TGET"
      oWnd:aControls[ n ]:oGet:Undo()
      oWnd:aControls[ n ]:Refresh()
   endif
next
> And how to undo other controls?

Once their initial values have changed there is no way to undo them. It may be just available for GETs, as they contain a Harbour standard GET (like Clipper) that accepts an UnDo() method.

>
If there are no easy way to do this, the solution as usual
is to copy data to edit in temporary array but i hope in
something better.
>

Yes, that may be the only solution for all controls

Posted: Sun Aug 26, 2007 10:54 am
by claudio.driussi
Try this:

Code: Select all

for n = 1 to Len( oWnd:aControls )
   if oWnd:aControls[ n ]:ClassName == "TGET"
      oWnd:aControls[ n ]:oGet:Undo()
      oWnd:aControls[ n ]:Refresh()
   endif
next
very nice!

> And how to undo other controls?

Once their initial values have changed there is no way to undo them. It may be just available for GETs, as they contain a Harbour standard GET (like Clipper) that accepts an UnDo() method.

For now is enough, but keep in mind which will be useful to have a undo
method for oWin wich recognize the type of control and do the
relative undo.

This mean that the TControl ancestor need a var called Original and so
you need to modify the root of class tree, but may be worth for.

Many thanks
Claudio

Posted: Sun Aug 26, 2007 12:23 pm
by Antonio Linares
Claudio,

What do you need the original values for ? Just to check which ones have changed their values ?

Posted: Mon Aug 27, 2007 6:55 am
by claudio.driussi
Antonio Linares wrote: What do you need the original values for ? Just to check which ones have changed their values ?
Simply when a user edit a record if he click on cancel button i need to restore original values.

This let me edit the databese fields instead a copy of values.

Best Regards
Claudio

Posted: Mon Aug 27, 2007 8:53 am
by Biel EA6DD
Take a look to tDabase Class. I thing is a best solution for your problem.

Posted: Mon Aug 27, 2007 10:06 am
by Antonio Linares
Claudio,

FWPPC provides Class TDataBase for that purpose. Use it this way:

local oDbf

USE YourDbf
DATABASE oDbf

edit your fields using oDbf:FieldName, i.e. oDbf:First, oDbf:Last, etc.

to save the register do oDbf:Save(). If canceled, do nothing

Posted: Mon Aug 27, 2007 2:19 pm
by claudio.driussi
Antonio Linares wrote: USE YourDbf
DATABASE oDbf
edit your fields using oDbf:FieldName
to save the register do oDbf:Save(). If canceled, do nothing
I wonder, how you bind the field names to the object?

i found _obj* function, but you don't use them in your source code.

Sorry for boring you, but really, i'm not confident with Harbour,
the documentation is terrible.

Claudio

Posted: Mon Aug 27, 2007 2:53 pm
by Antonio Linares
Claudio,

> I wonder, how you bind the field names to the object?

When you do
USE YourDbf
DATABASE oDbf

A TDataBase object is created using the current workarea information and the fieldnames are binded automatically

Give it a try and you will see how easy it is :-)