Page 1 of 1

Clearing Gets

Posted: Tue Feb 26, 2013 2:49 am
by Colin Haig
Hi Antonio

I have created a window with two gets and a combobox - I can add the first record okay ,
but when I try to add a new record as below

@ 2,01 SAY "Enter Job Number " SIZE 120,14 of oWnd1
@ 15,140 GET oGet VAR oSample:jbno SIZE 75,20 PIXEL OF oWnd1 UPDATE picture '@!'
@ 2,22 SAY "Client " SIZE 50,14 of oWnd1
@ 15,290 GET oGet1 VAR oSample:client SIZE 200 ,20 PIXEL OF oWnd1 UPDATE picture '@'


@50,15 BUTTON "New" of oWnd1 ;
SIZE 60,30 ;
ACTION(oSample:blank(),lNew := TRUE,oWnd1:Update(),oWnd1:Refresh(),oGet:SetFocus())

The gets and combobox are not refreshed - if I check a database field as below the database field is empty

ACTION(oSample:blank(),MsgInfo(oSample:jbno),lNew := TRUE,oWnd1:Update(),oWnd1:Refresh(),oGet:SetFocus())

I compiled and linked in the window program from source and checked the following

METHOD Update() INLINE ;
AEval( ::aControls, { |o| If( o:lUpdate, (MsgInfo('u'),o:Refresh()),) } )

The MsgInfo is shown - so I presume the oWnd1:Update() is working - also I presume o: is the window object
and refresh method is called

METHOD Refresh() INLINE MsgInfo('refresh'),WndRefresh( ::hWnd ) once again the MsgInfo is shown.

I cant WndRefresh method.

Cheers

Colin

Re: Clearing Gets

Posted: Wed Feb 27, 2013 8:46 am
by Antonio Linares
Colin,

This line had to be changed in source/classes/get.prg:

METHOD Refresh() INLINE ::SetText( cValToChar( Eval( ::bSetGet ) ) )

With such change, this example is working fine:

colin.prg

Code: Select all

#include "FiveLinux.ch"

//----------------------------------------------------------------------------//

function Main()

   local oForm1, oGet1, cGet1 := "hello", oGet2, cGet2 := "world", oGet3, cGet3 := Space( 20 ), oBtn1, oBtn2

   DEFINE DIALOG oForm1 TITLE "Form1" ;
      SIZE 522, 314

   @  91, 111 GET oGet1 VAR cGet1 SIZE 200,  29 PIXEL OF oForm1 UPDATE

   @ 127, 113 GET oGet2 VAR cGet2 SIZE 200,  29 PIXEL OF oForm1 UPDATE

   @ 162, 114 GET oGet3 VAR cGet3 SIZE 200,  24 PIXEL OF oForm1 UPDATE

   @ 251, 174 BUTTON oBtn1 PROMPT "Clear" ;
      SIZE 80, 30 PIXEL OF oForm1 ;
      ACTION ( cGet1 := cGet2 := cGet3 := Space( 20 ), oForm1:Update() )

   @ 250, 277 BUTTON oBtn2 PROMPT "Button" ;
      SIZE 80, 30 PIXEL OF oForm1 ;
      ACTION oForm1:End()

   ACTIVATE DIALOG oForm1 CENTERED

return oForm1

//----------------------------------------------------------------------------//
 

Re: Clearing Gets

Posted: Wed Feb 27, 2013 8:58 am
by Antonio Linares
Much better if we apply such change in control.prg so the combobox issue gets solved too :-)

colin.prg

Code: Select all

#include "FiveLinux.ch"

//----------------------------------------------------------------------------//

function Main()

   local oForm1, oGet1, cGet1 := "hello", oGet2, cGet2 := "world", oGet3, cGet3 := Space( 20 ), oBtn1, oBtn2
   local oCbx1, cCbx1, aItems := { "one", "two", "three" }

   DEFINE DIALOG oForm1 TITLE "Form1" ;
      SIZE 522, 314

   @  91, 111 GET oGet1 VAR cGet1 SIZE 200,  29 PIXEL OF oForm1 UPDATE

   @ 127, 113 GET oGet2 VAR cGet2 SIZE 200,  29 PIXEL OF oForm1 UPDATE

   @ 162, 114 GET oGet3 VAR cGet3 SIZE 200,  24 PIXEL OF oForm1 UPDATE

   @ 197, 114 COMBOBOX oCbx1 VAR cCbx1 ITEMS aItems SIZE 200, 24 PIXEL OF oForm1 UPDATE

   @ 251, 174 BUTTON oBtn1 PROMPT "Clear" ;
      SIZE 80, 30 PIXEL OF oForm1 ;
      ACTION ( cGet1 := cGet2 := cGet3 := cCbx1 := Space( 20 ), oForm1:Update(), oGet1:SetFocus() )

   @ 250, 277 BUTTON oBtn2 PROMPT "End" ;
      SIZE 80, 30 PIXEL OF oForm1 ;
      ACTION oForm1:End()

   ACTIVATE DIALOG oForm1 CENTERED

return oForm1

//----------------------------------------------------------------------------//
 

Re: Clearing Gets

Posted: Wed Feb 27, 2013 9:06 am
by Colin Haig
Hi Antonio

The get is cleared but when you type something into the empty get - the old value is still there.

I downloaded your sample and it doe the same.

Regards

Colin

Re: Clearing Gets

Posted: Wed Feb 27, 2013 9:37 am
by Antonio Linares
Colin,

This change was also missing in source/classes/get.prg

METHOD SetText( cText ) INLINE GetSetText( ::hWnd, cText ), ::oGet:buffer := cText

Now it seems to be fine :-)

Re: Clearing Gets

Posted: Wed Feb 27, 2013 9:51 am
by Colin Haig
Hi Antonio

The gets are working great - I could not see a refresh method in the control
program should I add METHOD Refresh() INLINE ::SetText( cValToChar( Eval( ::bSetGet ) ) )
so the combobox is cleared as well.

Cheers

Colin

Re: Clearing Gets

Posted: Wed Feb 27, 2013 10:10 am
by Colin Haig
Hi Antonio

Here is a sample of my code - I can add , save skip forward and back and the gets work fine but the combobox does
not update when I am skipping back and forward.

Code: Select all

static function fnSingle()
local oWnd1,aItems := {'A','B','C','D','E','NA'},oCombo1,oGet,oGet1,;
      lExit := FALSE,oSample,lNew := FALSE


oSample := tdatabase():new(,cPath+ "sample",,TRUE)
oSample:Open()
if oSample:used()
  
else
   MsgInfo('Cannot Open Sample Database')
endif   
if oSample:reccount == 0
  lNew := TRUE
  oSample:blank()
endif

   

   DEFINE WINDOW oWnd1 ;
   TITLE 'Single Hoist Service Sheet' ;
   SIZE 850,550 
     
   @ 2,01 SAY "Enter Job Number  "  SIZE 120,14 of oWnd1
   @ 15,140 GET oGet VAR  oSample:jbno SIZE 75,20 PIXEL OF oWnd1 UPDATE picture '@!'
   @ 2,22 SAY "Client " SIZE 50,14  of oWnd1
   @ 15,290 GET oGet1 VAR oSample:client SIZE 200 ,20 PIXEL OF oWnd1 UPDATE picture '@'
      
   @ 5,01 SAY 'Item 1 ' SIZE  75,10 of oWnd1   
   @ 5,10 SAY 'Item 2 ' SIZE  75,10 of oWnd1


   @ 7,02 COMBOBOX oCombo1 VAR oSample:item1 ITEMS aItems SIZE 55,25 OF oWnd1 UPDATE     
      
   @50,5 BUTTON "Exit" of oWnd1 ;
      SIZE 60,30 ;   
      ACTION(oSample:Close(),lExit := TRUE,oWnd1:End())
   
    @50,15 BUTTON "New" of oWnd1 ;
        SIZE 60,30 ;
        ACTION(oSample:blank(),lNew := TRUE,oWnd1:Update(),oWnd1:Refresh(),oGet:SetFocus())

    @50,25 BUTTON "Save" of oWnd1 ;
        SIZE 60,30 ;
        ACTION(if(lNew,(oSample:append(),oSample:save()),oSample:save()))
       
       @50,35 BUTTON "Next" of oWnd1 ;
        SIZE 60,30 ;
        ACTION(if(! oSample:eof(),oSample:skip(),),oWnd1:Update())
       
       @50,45 BUTTON "Previous" of oWnd1 ;
        SIZE 60,30 ;
        ACTION(if(! oSample:bof(),oSample:skip(-1),),oWnd1:Update())
       
   ACTIVATE WINDOW oWnd1 CENTERED ;
         VALID(lExit)
   
     
return(nil) 
//----------------------------------------------------------------------------------------------------//

Thanks for your help

Cheers

Colin























 

Re: Clearing Gets

Posted: Wed Feb 27, 2013 11:32 am
by Antonio Linares
Colin,

You have to implement it in control.prg

METHOD Refresh() INLINE ::SetText( cValToChar( Eval( ::bSetGet ) ) )