undo gets [newbye]

undo gets [newbye]

Postby claudio.driussi » Sun Aug 26, 2007 8:18 am

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
claudio.driussi
 
Posts: 18
Joined: Fri Nov 11, 2005 4:46 pm

Postby Antonio Linares » Sun Aug 26, 2007 10:11 am

Claudio,

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

Try this:
Code: Select all  Expand view
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
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby claudio.driussi » Sun Aug 26, 2007 10:54 am

Try this:
Code: Select all  Expand view
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
claudio.driussi
 
Posts: 18
Joined: Fri Nov 11, 2005 4:46 pm

Postby Antonio Linares » Sun Aug 26, 2007 12:23 pm

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

Postby claudio.driussi » Mon Aug 27, 2007 6:55 am

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
claudio.driussi
 
Posts: 18
Joined: Fri Nov 11, 2005 4:46 pm

Postby Biel EA6DD » Mon Aug 27, 2007 8:53 am

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
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Postby Antonio Linares » Mon Aug 27, 2007 10:06 am

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

Postby claudio.driussi » Mon Aug 27, 2007 2:19 pm

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
claudio.driussi
 
Posts: 18
Joined: Fri Nov 11, 2005 4:46 pm

Postby Antonio Linares » Mon Aug 27, 2007 2:53 pm

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


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 8 guests