Below is the tbrowse code i'm testing but when i edit a cell the change is lost when i press enter. How do i keep the changes so i can the data later to a postgres table.
#include "
inkey.ch"
PROCEDURE Main()
LOCAL lContinue := .T. ,;
nKeyPressed := 0,;
nArryRowNo := 1
LOCAL nTBrWTop := 5,; // TBrowse Window Top
nTBrWLeft := 18,; // TBrowse Window Left
nTBrWBott := 20,; // TBrowse Window Bottom
nTBrWRigt := 62 // TBrowse Window Right
SetMode( 25, 80 )
CLS
SETCOLOR( "W/GB+", "+GB/W" )
aAgenda := { { "Alvarez", "Alberto", "543-7898" } ,;
{ "Pradon", "Alejandra", "???-????" } ,;
{ "Gonzalez", "Ambo", "437-8473" } ,;
{ "Vinazzi", "Amigo", "394-5983" } ,;
{ "Samarbide", "Armando", "854-7873" } ,;
{ "Barriga", "Carlos", "394-9654" } ,;
{ "Pedemonti", "Flavio", "534-7984" } ,;
{ "Mulder", "Fox", "324-6432" } ,;
{ "Batistuta", "Gol", "485-2843" } ,;
{ "Simpson", "Homer", "555-5555" } ,;
{ "Kirk", "James", "346-9873" } ,;
{ "Borges", "Javier", "326-9430" } ,;
{ "Smith", "John", "123-1234" } ,;
{ "Gomez", "Juan", "583-4832" } ,;
{ "Smart", "Max", "432-5892" } ,;
{ "Reyes", "Monica", "432-5836" } ,;
{ "Flanders", "Ned", "435-3211" } ,;
{ "Grillo", "Pepe", "894-2332" } ,;
{ "Fernandez", "Raul", "321-4332" } }
nAgenSize := LEN( aAgenda )
* Draw a box around Browse window
DISPBOX( nTBrWTop-1, nTBrWLeft-1, nTBrWBott+1, nTBrWRigt+1 )
* Define a new TBrowse object
oBrowse := TBrowseNew( nTBrWTop, nTBrWLeft, nTBrWBott, nTBrWRigt )
* Define navigation rules between browse's rows
oBrowse:SkipBlock := { | nSkip | TbrASkipper( nSkip, @nArryRowNo ) }
oBrowse:HeadSep := 'ÄÂÄ' // Header Seperator
oBrowse:ColSep := ' ³ ' // Column Seperator
* Define columns with TBColumn and add them to the TBrowse object
oBrowse:AddColumn( TBColumnNew( "Surname", ;
{ || PADR( @aAgenda[ nArryRowNo, 1 ], 15 ) } ))
oBrowse:AddColumn( TBColumnNew( "Name", ;
{ || PADR( @aAgenda[ nArryRowNo, 2 ], 10 ) } ))
oBrowse:AddColumn( TBColumnNew( "Tlf", ;
{ || PADR( @aAgenda[ nArryRowNo, 3 ], 10 ) } ))
WHILE lContinue // Browse's loop
WHILE .NOT. oBrowse:stabilize() ; ENDDO // Stabilizing loop
nKeyPressed := INKEY(0)
lContinue := TBrApplyKey( oBrowse, nKeyPressed )
oBrowse:refreshAll()
ENDDO
USE
SETPOS( 23, 0 )
WAIT "EOF TBrowseArr"
RETURN // TBRowseArr-Main()
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
Navigation rules between browse's rows
*/
FUNCTION TbrASkipper( nToSkip, nArryRowNo )
IF nToSkip > 0
IF ( nToSkip + nArryRowNo ) > nAgenSize
nToSkip := nAgenSize - nArryRowNo
ENDIF
ELSE
IF ( nToSkip + nArryRowNo ) < 1
nToSkip := 1 - nArryRowNo
ENDIF
ENDIF
nArryRowNo += nToSkip
RETURN nToSkip // TbrASkipper()
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
Handle the (some) keystrokes of user
*/
FUNCTION TBrApplyKey( oBrowse, nKey )
LOCAL lRVal := .T.
DO CASE
CASE nKey == K_UP
oBrowse:Up()
CASE nKey == K_LEFT
oBrowse:lEFT()
CASE nKey == K_RIGHT
oBrowse:Right()
CASE nKey == K_DOWN
oBrowse:down()
CASE nKey == K_HOME
oBrowse:home()
CASE nKey == K_END
oBrowse:end()
CASE nKey == K_PGUP
oBrowse:pageUp()
CASE nKey == K_PGDN
oBrowse:pageDown()
CASE nKey == K_CTRL_PGDN
oBrowse:goBottom()
CASE nKey == K_CTRL_PGUP
oBrowse:goTop()
CASE nKey == K_ESC
// End of Browse and program
lRVal := .F.
CASE nKey == K_RETURN && Enable date entry on RETURN.
GetIt(oBrowse)
ENDCASE
RETURN lRVal // TBrApplyKey()
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* A function to provide data entry for the browse.
FUNCTION GETIT (oBrowse) && Object is passed as a parameter.
LOCAL nGetCol && GET Column.
LOCAL oGet && GET object.
/* Get teh particulars on the column (cell) to edit and crate
a GET object to use for the entry. */
nGetCol := oBrowse:GetColumn(oBrowse:colpos)
oGet := GetNew(Row(), Col(), nGetCol:block, nGetCol:heading)
SET CURSOR ON &&hide the editing cusor and
ReadModal({oGet}) && do the READ.
oBrowse:refreshCurrent() && Update the current row of teh
&& browse.
SET CURSOR OFF && Hide the editing cursor again.
IF LastKey() == K_UP .OR. ; && Detemine if one of these
LastKey() == K_DOWN .OR. ; && keystroke was used to
LastKey() == K_PGUP .OR. ; && terminate the READ. If so
LastKey() == K_PGDN .OR. ; && put the key back into the
LastKey() == K_ESC && keyboard buffer.
KEYBOARD Chr(LastKey())
ENDIF
RETURN .T. && Terminate the GetIt () function.
*end function