VALID in ADD COLUMN don't work.

VALID in ADD COLUMN don't work.

Postby biro2000 » Mon Nov 20, 2006 5:12 pm

Hi,

I'm using Fivewin 2.7 for Harbour - April 2006 release + xHarbour Builder - October 2006 release + WinXP.

The problem is:

I got this code on Fivewin Samples Folder and changed last line.

ADD COLUMN TO BROWSE oBrw ;
DATA FieldWBlock("BAKIYE", Select("Stok")) ;
HEADER "Bakiye" ;
PICTURE "###,###.##" ;
EDITABLE ;
WIDTH 70 PIXELS ;
VALID {|o| MyFunction( o:varGet() ) }


When MyFunction() returns FALSE, the browse advances to the next field or get and it should stay in the same get.

The same code, when compiled in Clipper 5.2e + Fivewin 2.4 works fine!

I tried this way too:

VALID IF MyFunction( o )

But the problem persist!

Thank's

Luciano
Luciano Iuri Pereira
Birô 2000 Serviços Integrados S/A
E-mail: lucianoiuri@biro2000.com.br
biro2000
 
Posts: 4
Joined: Mon Nov 20, 2006 1:07 pm
Location: Indaiatuba-SP - Brazil

Postby Armando » Mon Nov 20, 2006 5:23 pm

Luciano:

pls try this way

oBrw:aColumns[ 1 ]:bValid := { | uVar | MyFunction(uVar) }

Best regards, Armando
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3095
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

VALID in ADD COLUMN don't work.

Postby biro2000 » Mon Nov 20, 2006 5:42 pm

Armando,

Thank you for your help.

I tried your sugestion

oBrw:aColumns[ 1 ]:bValid := { | uVar | MyFunction(uVar) }

But the problem happened again.

Have you any other idea?

Thank's
Luciano Iuri Pereira
Birô 2000 Serviços Integrados S/A
E-mail: lucianoiuri@biro2000.com.br
biro2000
 
Posts: 4
Joined: Mon Nov 20, 2006 1:07 pm
Location: Indaiatuba-SP - Brazil

Postby Armando » Mon Nov 20, 2006 6:41 pm

Luciano:

it woks fine to me, perhaps the problem is in your valid FUNCTION

Pls, show a little part of you code. (Column code and valid function)

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3095
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Postby biro2000 » Wed Nov 22, 2006 12:10 pm

Armando,

I am using a piece of \FWH\Samples\TestTcBr.prg as example. I just changed:

ADD COLUMN TO BROWSE oBrw ;
DATA FieldWBlock("BAKIYE", Select("Stok")) ;
HEADER "Bakiye" ;
PICTURE "###,###.##" ;
EDITABLE ;
WIDTH 70 PIXELS ;
VALID {|o| MyFunction( o:varGet() ) }

My code is:

#include "fivewin.ch"
#include "TCBrowse.ch"

// always put TCBrowse.ch AFTER filewin.ch

Static MainWnd

Function Main()
Local hBWCC

Set Date Format "dd/mm/yyyy"

SET _3DLOOK ON

hBWCC := LoadLibrary( "BWCC32.DLL" )
SET RESOURCES TO "TCBR32.DLL" // Our stored screens
BWCCRegister( GetResources() )

DEFINE WINDOW MainWnd FROM 1, 1 TO 22, 75 ;
TITLE "Test SAMPLE TESTCBR.PRG 08/11/2006" ;
MENU BuildMenu()

SET MESSAGE OF MainWnd TO "Great idea by Salim Anter" CENTERED

USE Stok
IF ! ( File("StokName.NTX") .and. File("MaliYet.NTX") )
INDEX ON Stok->MaliYet TO MaliYet
INDEX ON Stok->StokName TO StokName
ELSE
SET INDEX TO StokName, MaliYet
ENDIF

ACTIVATE WINDOW MainWnd MAXIMIZED

SET RESOURCES TO

Return( NIL )

Function BuildMenu
local oMenu

MENU oMenu
MENUITEM OemToAnsi( "&Create" ) ;
ACTION NewBrowse( )
ENDMENU

Return( oMenu )

#define OBM_CLOSE 32754
#define OBM_UPARROW 32753
#define OBM_DNARROW 32752
#define OBM_CHECKBOXES 32759
#define OBM_CHECK 32760
#define OCR_NORMAL 32512
#define OCR_CROSS 32515

Function NewBrowse( )
Static aX
Local oDlg, oBrw, oCol, oFont, oSay

Local _hOn := LoadBitMap(0, OBM_CHECK) // Use OEM system resources
Local _hOff := Chr(160) // This will be treated as if it were bitmap

if aX == nil

aX := Array(3)
aX[1] := LoadBitMap( GetResources(), "Z_Green_X")
aX[2] := LoadBitMap( GetResources(), "Z_Red_X")
aX[3] := LoadBitMap( GetResources(), "Z_Blank")

endif

DEFINE FONT oFont NAME "System" SIZE 8, 16 BOLD // 6, 15

DEFINE DIALOG oDlg of MainWnd NAME "Aktivite"

REDEFINE BROWSE oBrw ID 999 OF oDlg ;
MESSAGE "You may open multi-copies, DblCkick to edit, "+ ;
"1st column frozen" FONT oFont ;
ON RIGHT CLICK MsgInfo( "RightClick" ) ;
ON CHANGE MsgBeep()

oBrw:lLogicDrop := .t. // use crazy logic dropbox
oBrw:lNoHScroll := .t. // don't use that pesky horiz scroll bar
oBrw:nAdjColumn := 3 // expand this column to flush table right
oBrw:nFreeze := 3 // 0 disables freezing 1 is leftmost
oBrw:hBmpCursor := LoadBitmap( GetResources(), "Z_Triangle" )

oBrw:bLDblClick := { | nRow, nCol | EditCell( oBrw, nRow, nCol ) }

ADD COLUMN TO oBrw DATA "" SIZE 15 // blank cursor colm

//ADD COLUMN TO oBrw NOBAR ;
// BITMAP DATA If ( Stok->FATURA > Stok->BAKIYE , aX[1] , ;
// If ( Stok -> FATURA < Stok->BAKIYE , aX[2], aX[3] ) )

//ADD COLUMN TO BROWSE oBrw ;
// DATA OemToAnsi( Stok ->STOKNAME ) TAG StokName ;
// HEADER "Stok" SIZE 100

ADD COLUMN TO BROWSE oBrw ;
DATA FieldWBlock("BAKIYE", Select("Stok")) ; // we can edit it
HEADER "Bakiye" OEM ALIGN RIGHT ;
PICTURE "###,###.##" EDITABLE WIDTH 70 PIXELS ;
COLOR If( Stok->BAKIYE < 0, CLR_RED, CLR_BLACK), {||CLR_GREEN } ;
MESSAGE "Enter a negative number" ;
VALID {|o| MyFunction( o:varGet() ) }
ERROR MESSAGE "Value must be"+CRLF+"positive or 0"

ADD COLUMN TO BROWSE oBrw ;
DATA FieldWBlock("BAKIYE", Select("Stok")) ; // we can edit it
HEADER "Bakiye" OEM ALIGN RIGHT ;
PICTURE "###,###.##" EDITABLE WIDTH 70 PIXELS ;
COLOR If( Stok->BAKIYE < 0, CLR_RED, CLR_BLACK), {||CLR_GREEN } ;
MESSAGE "Enter a negative number" ;
VALID IF ValCampo( x ) ;
ERROR MESSAGE "Value must be"+CRLF+"positive or 0"

oBrw:AddColumn( TCColumn( ):New( OemToAnsi( "Fatura" ) , ;
FieldWBlock("Fatura", Select("Stok")), ;
"###,###.##" , nil, nil, DT_RIGHT, 90 , nil, .t.) )

DEFINE COLUMN oCol ;
DATA If ( Stok->FATURA > Stok->BAKIYE , _hOn , _hOff) BITMAP;
NOHILITE SIZE 15 COLOR "N/R" CENTER

oBrw:AddColumn( oCol )

//ADD COLUMN TO oBrw ALIGN RIGHT TAG "MaliYet" SIZE 100 ;
// DATA Stok -> MALIYET PICTURE "##,###,###" ;
// HEAD "Maliyet"

//ADD COLUMN TO oBrw ALIGN RIGHT ;
// HEAD "Ciro" DATA FieldBlock("CIRO") ;
// PICT "@Z #,###,###.##" SIZE 90 ;
// EDIT VALID {|o| o:varGet() < 0} ;
// MESSAGE "Current data causes lots of errors" ;
// ERROR MESSAGE "Value Must be"+CRLF+"Less than 0"

// ADD COLUMN TO BROWSE oBrw ;
// HEADER "Devirtarih" ALIGN CENTER ;
// DATA FieldBlock("Devirtarih") PICTURE "@D" EDIT

// ADD COLUMN TO oBrw TITLE "L" PICT "Y" SIZE 15 ;
// DATA Stok->FATURA > Stok->BAKIYE EDITABLE // but not savable

REDEFINE BUTTON ID IDOK OF oDlg ACTION oDlg:End( ) ;
MESSAGE "Get outta here"

REDEFINE SAY oSay VAR oBrw:cSeek ID 211 OF oDlg ;
COLORS CLR_WHITE, CLR_CYAN

oBrw:bSeekChange := {|| oSay:Refresh() }

REDEFINE BUTTON ID 101 OF oDlg ;
ACTION oBrw:SwitchCols(5, 9):Exchange(3, 6) ;
MESSAGE "Switch columns 5 and 9, exchange columns 3 and 6"

REDEFINE BUTTON ID 102 OF oDlg ;
ACTION ( If(oBrw:oCtx != Nil, oBrw:oCtx:Display(), nil ), ;
oBrw:SetFocus() ) MESSAGE "Display Context"

REDEFINE BUTTON ID 103 OF oDlg ;
ACTION oBrw:Report() ;
MESSAGE "Print a Report"

ACTIVATE DIALOG oDlg CENTERED NOWAIT

Return( NIL )


DLL FUNCTION BWCCRegister( hInst AS LONG ) AS LONG PASCAL ;
LIB "BWCC32.DLL"

procedure AppSys // XBase++ requirement

return

////////////////////////////////////////////////////////////////////////////////////
function MyFunction( valnum )

local retorno := .t.

if valnum >= 500
retorno := .t.
else
retorno := .f.
? "return: FALSE"
endif

return( retorno )

Thank you,

Luciano
Luciano Iuri Pereira
Birô 2000 Serviços Integrados S/A
E-mail: lucianoiuri@biro2000.com.br
biro2000
 
Posts: 4
Joined: Mon Nov 20, 2006 1:07 pm
Location: Indaiatuba-SP - Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Ari, Google [Bot] and 132 guests