undo gets [newbye]

Post Reply
User avatar
claudio.driussi
Posts: 18
Joined: Fri Nov 11, 2005 4:46 pm

undo gets [newbye]

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
claudio.driussi
Posts: 18
Joined: Fri Nov 11, 2005 4:46 pm

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Claudio,

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

Antonio Linares
www.fivetechsoft.com
User avatar
claudio.driussi
Posts: 18
Joined: Fri Nov 11, 2005 4:46 pm

Post 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
User avatar
Biel EA6DD
Posts: 680
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca
Contact:

Post by Biel EA6DD »

Take a look to tDabase Class. I thing is a best solution for your problem.
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
claudio.driussi
Posts: 18
Joined: Fri Nov 11, 2005 4:46 pm

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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 :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply