Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Clipper > Re: Tbrowse hel...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 3817 of 3903
Post > Topic >>

Re: Tbrowse help.

by sebas22 <nospam@[EMAIL PROTECTED] > Jan 13, 2008 at 08:37 AM

On Sun, 13 Jan 2008 02:36:52 GMT, "Stephen Quinn"
<stevejqNO@[EMAIL PROTECTED]
> wrote:

>
>> Function Swapcol()
<SNIP>
>> Return Nil
>> *********************************************************************
>>
>> The function is called when ever required.
>> I want to use for while condition in the above routine.
>
>What for??
>Your swapping 2 columns why would you need a while condition??

Steve, I think he wasn't speaking about the swapping but about the
tBrowsedbitself (i.e.tbrowse while the index key is a certain value,
for exemple for one customer, or for all customers in one city, or for
one product)

Mahesh, to achieve this, you need to make a custom skipblock. Make a
tbrowsenew() instead of tbrowsedb(), so you can define mb:skipblock
(see clipper'sNG or better, clipper's manuels for more help.

I've made a generic function for that purpose. See at the end of this
post. Then I call it this way

#define h_LAST	.t.	// for seek last

  // tbrowsenew() instead of tbrowseDB()
  ob := tbrowsenew( wRow(0), wCol(0), wMaxRow(), wMaxCol() )
  
 // you define all ob:addcolumn(), ob:setkey() etc...

  ob:GoTopBlock    := { || dbseek(cThisCustomert) }
  ob:SkipBlock     := { |n| MovePointer(n, cThisCustomer) }
  ob:GoBottomBlock := { ||  dbseek(cThisCustomer,, h_LAST) }

  ob:gotop()
  REPEAT
     do while nextkey() == 0 .and. ! ob:stabilize()
     enddo
  UNTIL ( ob:ApplyKey(getkey(0)) == TBR_EXIT )	
  // ob:applyKey() is from clipper 5.3, it calls all the navigation
keys, in your case is all the "case Key = ENTER" etc...
  // getkey() is my special inkey() with ol_yield()



/* -------------------------------- MovePointer 
*   Execut‚ par la methode skipblock lors d'un browse avec WHILE
(up,downn,
*   pageup, pagedown)
*   nToSkip donne le nb d'enr. … sauter (>0 ou <0), cOccurence est la
valeur
*   par laquelle on filtre (ex : "100012"), bGiveOccurence donne la
*   valeur de l'indice de l'enr courant        (normalement, on le
defini ds la proc
*   appelante par bGvOc =: &( "{|| indexkey(0)}" )
*
*   Parametres :
*   nToSkip : nb d'enr. … sauter (fourni par TBrowse)
*   cOccurence : valeur de recherche
*   bGiveKeyValue : (optionnel) l'evaluation de ce block donne la
valeur de
*   l'index de l'enr. courant  de la dbf courante . Par default,
ordkeyval()
*
*   Retour : nb d'enr. effectivement saut‚s ( = ou < … nToSkip)
*
*/

#include "hcommon.ch"                // Pour DEFAULT TO


function MovePointer(nToSkip, cOccurence, bGiveKeyValue)
local nSkipped := 0, nSens

  DEFAULT bGiveKeyValue TO {|| ordkeyval()}        // ok with rddcdx,
not with rddntx

  if nToSkip == 0
     SKIP 0

  else    // nToSkip != 0
     // Direction dans laquelle on bouge :
     nSens := nToSkip / abs(nToSkip)

     do while !eof()  .AND.  !bof()                ;
                   .AND. nSkipped != nToSkip                ;
              .AND. eval(bGiveKeyValue) = cOccurence

        SKIP nSens                // +1 ou -1
        nSkipped += nSens
     enddo


     // Cas de sortie de la zone utile :
     if eof()
        nSkipped --
        SKIP -1

     elseif bof()
        nSkipped ++
        GOTO recno()                // Pour reset du bof().

     elseif !( eval(bGiveKeyValue) = cOccurence)
        // On est sortit de l'occurence. On revient dedans.
        SKIP -nSens
        nSkipped -= nSens
     endif   Sortie de la zone utile


  endif  nToSkip == 0

RETURN nSkipped
*---- EoP MovePointer ----*



-- 
HTH,
Sebas




 4 Posts in Topic:
Tbrowse help.
vmk1508@[EMAIL PROTECTED]  2008-01-12 07:14:44 
Re: Tbrowse help.
"Stephen Quinn"  2008-01-13 02:36:52 
Re: Tbrowse help.
sebas22 <nospam@[EMAIL  2008-01-13 08:37:38 
Re: Tbrowse help.
sebas22 <nospam@[EMAIL  2008-01-13 08:41:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 2:32:43 CDT 2008.