For Programmers: Free Programming Magazines  


Home > Archive > Clipper > May 2005 > Tbrowse and the set filtere how









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Tbrowse and the set filtere how
happy

2005-05-20, 8:55 pm

set filter commands turn my record pointer to the records that meets
the condition or not ?

Im tbrowse program based on a set filter command I need every new
record to have a value from logical previous one ?
How can I do it ?

I need every new ("open_meter") to have the previous ("cls_meter")
automatically How can I do it syntaxically ?

Here down my Call :

select 4
use mete index mete2
go top

set filter to alltrim(v_me_serial)==alltrim(4->me_serial)

NTBRETVAL :=meterdbedit (8,3,23,76,4,{ || 4->me_cu_ACCt :=
V_me_ACCT,4->me_cu_name := V_me_NAME,;
4->me_start_d := V_me_START_D,4->me_end_d := V_me_END_D,4->me_serial
:= V_me_serial,;
4->me_MODEL := V_me_MODEL,V_month:=4->month,V_year:=4->year,;
4->me_type:=V_Mc_TYPE,4->me_brn:=V_Mc_brn})



* To illustarate the usage of TBrowse clipper5's *
* object - Oriented Browse *
*--------------------------------------------------------------
#include "inkey.ch"
*#include "color.ch"

FUNCTION meterdbedit(NTOP,NLFT,NBOT,NRHT,workarea
,bkeyblock,ckeyblock)

LOCAL BCOL,oCOL1,oCOL2,oCOL3,oCOL4,I,LNEWREC,C
SCR,NKEY ,total := 0
PRIVATE OBROWSE
LNEWREC:= .F.
SET CURSOR OFF
IF PCOUNT() < 4
NTOP:=1
NLFT:=5
NBOT:=22
NRHT:=74
ENDIF
OBROWSE:=TBROWSEDB(NTOP+1,NLFT+1,NBOT-1,NRHT-1)
FOR I = 1 TO FCOUNT()
*IF UPPER(FIELD(I)) == UPPER(INDEXKEY()) .or. ;
IF UPPER(FIELD(I)) == UPPER("me_cu_acct") .or. ;
UPPER(FIELD(I)) == UPPER("me_serial") .or. ;
UPPER(FIELD(I)) == UPPER("me_cu_name") .or. ;
UPPER(FIELD(I)) == UPPER("me_start_d") .or. ;
UPPER(FIELD(I)) == UPPER("me_end_d") .or. ;
UPPER(FIELD(I)) == UPPER("me_model") .or. ;
UPPER(FIELD(I)) == UPPER("prints") .or. ;
UPPER(FIELD(I)) == UPPER("me_type") .or. ;
UPPER(FIELD(I)) == UPPER("me_brn") .or. ;
UPPER(FIELD(I)) == UPPER("accumulate") .or. ;
UPPER(FIELD(I)) == UPPER("waste") .or. ;
UPPER(FIELD(I)) == UPPER("charge") .or. ;
UPPER(FIELD(I)) == UPPER("me_in_date") .or. ;
UPPER(FIELD(I)) == UPPER("month") .or. ;
UPPER(FIELD(I)) == UPPER("year") .or. ;
UPPER(FIELD(I)) == UPPER("open_meter") .or. ;
UPPER(FIELD(I)) == UPPER("cls_meter") .or. ;
UPPER(FIELD(I)) == UPPER("notes")
LOOP
ENDIF
bcol:=TBCOLUMNNEW(FIELD(I),FIELDBLOCK(FI
ELD(I)))
OBROWSE:ADDCOLUMN(bcol)
NEXT


OCOL1:=TBCOLUMNNEW('Open Meter',FIELDBLOCK('open_meter'))
OBROWSE:ADDCOLUMN(OCOL1)

OCOL2:=TBCOLUMNNEW('Close Meter',FIELDBLOCK('cls_meter'))
OBROWSE:ADDCOLUMN(OCOL2)

OCOL3:=TBCOLUMNNEW('
Prints',{||(workarea)->prints:=((workarea)->cls_meter)-((workarea)->open_meter)})
OBROWSE:ADDCOLUMN(OCOL3)

OCOL4:=TBCOLUMNNEW(' Waste',FIELDBLOCK('waste'))
OBROWSE:ADDCOLUMN(OCOL4)

OCOL5:=TBCOLUMNNEW('
Charge',{||(workarea)->charge:=((workarea)->prints)-((workarea)->waste)})
OBROWSE:ADDCOLUMN(OCOL5)


OCOL6:=TBCOLUMNNEW('Month',FIELDBLOCK('m
onth'))
OBROWSE:ADDCOLUMN(OCOL6)

OCOL7:=TBCOLUMNNEW('Year',FIELDBLOCK('ye
ar'))
OBROWSE:ADDCOLUMN(OCOL7)

OCOL8:=TBCOLUMNNEW(' Notes',FIELDBLOCK('notes'))
OBROWSE:ADDCOLUMN(OCOL8)


ocol3:FOOTING :="Total:"+alltrim(STR(TOTALEM(),12,0))
ocol4:FOOTING :="Total:"+alltrim(STR(TOTALEM2(),12,0))
ocol5:FOOTING :="Total:"+alltrim(STR(TOTALEM3(),12,0))
OBROWSE:configure()
OBROWSE:invalidate()
OBROWSE:REFRESHALL()
OBROWSE:GOTOP()
OBROWSE:REFRESHALL()
OBROWSE:REFRESHCURRENT()

CSCR:=SAVESCREEN(NTOP,NLFT,NBOT,NRHT)

@NTOP,NLFT CLEAR TO NBOT,NRHT
@NTOP,NLFT TO NBOT,NRHT DOUBLE


obrowse:colorrect({1,1,obrowse:rowcount(
),obrowse:colcount()},{})

do while .t.

do while .not. obrowse:stabilize()


nkey := INKEY()
if NKEY <> 0
exit
endif
enddo

if obrowse:stable

if obrowse:hitbottom .and. .not. lnewrec
keyboard 24
lnewrec:=.t.
elseIF OBROWSE:HITTOP
TONE(200,1)
ENDIF
NKEY = INKEY(0)
ENDIF

IF NKEY == K_F9
IF APND()
EVAL(BKEYBLOCK)
OBROWSE:GOtop()
OBROWSE:REFRESHALL()
OBROWSE:GOtop()
colpos:=OBROWSE:getcolumn(1)
OBROWSE:GOtop()
OBROWSE:REFRESHALL()
ELSE
EXIT
ENDIF

ELSEIF NKEY == K_F10
IF RLOCK()
DELETE
OBROWSE:configure()
OBROWSE:invalidate()
OBROWSE:REFRESHCURRENT()
OBROWSE:REFRESHALL()

OBROWSE:GOTOP()
OBROWSE:REFRESHALL()
PACK
OBROWSE:configure()
OBROWSE:invalidate()
OBROWSE:REFRESHCURRENT()
OBROWSE:REFRESHALL()

ENDIF


ELSEIF NKEY == K_DOWN
OBROWSE:DOWN()

ELSEIF NKEY == K_UP
OBROWSE:UP()

ELSEIF NKEY == K_PGDN
OBROWSE:PAGEDOWN()

ELSEIF NKEY == K_PGUP
OBROWSE:PAGEup()

ELSEIF NKEY == K_CTRL_PGDN
OBROWSE:GOBOTTOM()

ELSEIF NKEY == K_CTRL_PGUP
OBROWSE:GOtop()

ELSEIF NKEY == K_RIGHT
OBROWSE:RIGHT()

ELSEIF NKEY == K_LEFT
OBROWSE:LEFT()

ELSEIF NKEY == K_HOME
OBROWSE:HOME()

ELSEIF NKEY == K_END
OBROWSE:END()

ELSEIF NKEY == K_CTRL_LEFT
OBROWSE:PANLEFT()

ELSEIF NKEY == K_CTRL_RIGHT
OBROWSE:PANRIGHT()

ELSEIF NKEY == K_CTRL_HOME
OBROWSE:PANHOME()

ELSEIF NKEY == K_CTRL_END
OBROWSE:PANEND()

ELSEIF NKEY == K_ESC
EXIT

ELSEIF NKEY == K_RETURN
IF OBROWSE:COLPOS < OBROWSE:COLCOUNT
OBROWSE:RIGHT()

ELSEIF OBROWSE:COLPOS == OBROWSE:COLCOUNT
OBROWSE:DOWN()
OBROWSE:PANHOME()
ENDIF
ELSE


KEYBOARD CHR(NKEY)
EECOLGET(OBROWSE)
OBROWSE:RIGHT()
ENDIF


ENDDO

RESTSCREEN(NTOP,NLFT,NBOT,NRHT,CSCR)
SET CURSOR ON

RETURN

FUNCTION EECOLGET(OBROWSE)
*------------------------
LOCAL NCOLGET
LOCAL OEDIT
LOCAL LREADEXIT:=READEXIT(.T.)
local xxx

DO WHILE .NOT. OBROWSE:STABILIZE()
ENDDO
SET CURSOR ON
NCOLGET:=OBROWSE:GETCOLUMN(OBROWSE:COLPO
S)
OEDIT:=GETNEW(ROW(),COL(),NCOLGET:BLOCK,
NCOLGET:HEADING)
/*IF .NOT. Rlok()
RETURN NIL
ENDIF*/
READMODAL ({OEDIT})
OBROWSE:REFRESHCURRENT()
OBROWSE:configure()
OBROWSE:invalidate()
OBROWSE:REFRESHALL()

SET CURSOR OFF
READEXIT(LREADEXIT)
IF LASTKEY() == K_UP .OR. ;
LASTKEY() == K_DOWN .OR. ;
LASTKEY() == K_PGUP .OR. ;
LASTKEY() == K_PGDN
KEYBOARD CHR(LASTKEY())
ENDIF
/////////////////////////////////////////
*if obrowse:colpos >= 4
((4)->MONTH):=((4)->(MONTH(ME_DATE)))
((4)->year):=((4)->(year(ME_DATE)))
OBROWSE:REFRESHCURRENT()
OBROWSE:REFRESHALL()

xxx := totalem()
NCOLGET:=OBROWSE:GETCOLUMN(4)
ncolget:FOOTING := 'Total:' + alltrim(str( xxx, 12, 0 ))
OBROWSE:configure()
OBROWSE:invalidate()
OBROWSE:REFRESHCURRENT()
OBROWSE:REFRESHALL()
*OBROWSE:GOTOP()

xxx := totalem2()
NCOLGET:=OBROWSE:GETCOLUMN(5)
ncolget:FOOTING := 'Total:' + alltrim(str( xxx, 12, 0 ))
OBROWSE:configure()
OBROWSE:invalidate()
OBROWSE:REFRESHCURRENT()
OBROWSE:REFRESHALL()
*OBROWSE:GOTOP()

xxx := totalem3()
NCOLGET:=OBROWSE:GETCOLUMN(6)
ncolget:FOOTING := 'Total:' + alltrim(str( xxx, 12, 0 ))
OBROWSE:configure()
OBROWSE:invalidate()
OBROWSE:REFRESHCURRENT()
OBROWSE:REFRESHALL()
*OBROWSE:GOTOP()


*endif
/////////////////////////////////////////

IF LASTKEY() == K_RETURN .AND. OBROWSE:COLPOS < OBROWSE:COLCOUNT
OBROWSE:RIGHT()
ELSEIF LASTKEY() == K_RETURN .AND. OBROWSE:COLPOS ==
OBROWSE:COLCOUNT
OBROWSE:DOWN()
OBROWSE:PANHOME()
ENDIF

RETURN NIL


/*FUNCTION TOTALEM(bwhile)
*-------------------

LOCAL NTOTAL:=0
local nsaverecno := 4->( recno() )
OBROWSE:GOBOTTOM(bwhile)
do while .t. .and. !(4->(bof())) .and. !(4->(eof()))
ntotal:=ntotal+((4->cls_meter)-(4->open_meter))
IF (4->(open_meter))==0
exit
endif
skip -1
enddo
4->(dbgoto( nsaverecno ) )
RETURN NTOTAL*/

FUNCTION TOTALEM()
*-------------------

LOCAL NTOTAL:=0
local nrecno := 4->( recno() )
SUM 4->PRINTS TO NTOTAL
4->(dbgoto( nrecno ) )

RETURN NTOTAL


FUNCTION TOTALEM2()
*-------------------

LOCAL NTOTAL:=0
local nrecno := 4->( recno() )
SUM 4->waste TO NTOTAL
4->(dbgoto( nrecno ) )

RETURN NTOTAL

FUNCTION TOTALEM3()
*-------------------

LOCAL NTOTAL:=0
local nrecno := 4->( recno() )
SUM 4->charge TO NTOTAL
4->(dbgoto( nrecno ) )

RETURN NTOTAL

sali

2005-05-21, 8:55 am

"happy" <ehab_aziz2001@yahoo.com> wrote in message
news:1116625816.948389.218720@g43g2000cwa.googlegroups.com...
> set filter commands turn my record pointer to the records that meets
> the condition or not ?
>
> Im tbrowse program based on a set filter command I need every new
> record to have a value from logical previous one ?
> How can I do it ?
>
> I need every new ("open_meter") to have the previous ("cls_meter")
> automatically How can I do it syntaxically ?
>
> Here down my Call :
>
> select 4
> use mete index mete2
> go top
>
> set filter to alltrim(v_me_serial)==alltrim(4->me_serial)


not sure for the long program you sent, but for a filter to immediatelly to
became active you need one
"go top" after each "set filter to" command.
otherwise, filter is not activated and may be confusing you!


Stephen Quinn

2005-05-22, 3:55 am

Ehab

oTB:GoBottom()
PrevMeterClose := CLS_METER
DBAppend()
Open_Meter := PrevMeterClose

I'll leave you to do the error checking side.

The above presumes that the LAST meter reading is in the CURRENT Filter scope.

HTH
Steve


happy

2005-05-23, 3:55 am

It picks a meduim value not the one in the bottom of filter scope Why
this I used a different index the same result !!Any Suggestions .

Stephen Quinn

2005-05-23, 8:55 am

Ehab

Sorry no - I did say the it code presumes the last entry was in scope, if t's
not then you need to be sure it is.

If the last entry is in scope then you need to look at your code in the debugger
to find out WHY your not getting the right data.
ie when you do do the oTB:gobottom() is it on the last record in the scope or
not
a possible modification is change it to
DBF->( DBGoBottom() )
instead - move in the database and forget about the TBrowse.

HTH
Steve


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com