Best use of aSelected in Xbrowse

Best use of aSelected in Xbrowse

Postby Marc Venken » Tue May 14, 2024 10:11 am

Momentary i'm using both ways of processing aSelected in Xbrowse :

Code: Select all  Expand view

      if msgyesno("Bereken het verschil tussen Bruto en New Bruto")
         if webshop->(flock())
           FOR I = 1 TO LEN(oBRWT2:aSELECTED)  
             webshop->(dbgoto(oBRWT2:aSELECTED[I]))
             replace webshop->new_diff with (((webshop->new_bruto-webshop->bruto)/webshop->bruto)*100)
           next
           webshop->(dbunlock())
         endif
      endif

 


and afther some post of Mr. Rao I went to : Using Xbrowse DATA

Code: Select all  Expand view

      if msgyesno("Bereken het verschil tussen Bruto en New Bruto")
           FOR I = 1 TO LEN(oBRWT2:aSELECTED)  
             webshop->(dbgoto(oBRWT2:aSELECTED[I]))
              oBrwT2:supertxt:varput(arttemp->foldertxt)
           next
      endif
 


Some questions :

In case of 1000 selected record, code A will do a FLock and code B will use Xbrowse and I suppose a RLock each record. Better use A for large selections ?

In case that changing a value in the loop that will also change a other value based on the changed value, in Code A we need to program it but in Code B Xbrowse will handle also the change in other field, so less code

In large selections, It seems that code A can freeze ? (or just bad coding :D ) How can I show a Timer or visual reccount in Xbrowse (Somewhere in footer ?)

I use this a lot !!! but i learned about oDbf or Hashes

replace webshop->new_diff with (((webshop->new_bruto-webshop->bruto)/webshop->bruto)*100)

This will go to the DBF and take new_bruto, than bruto etc... Will it always effectively read the dbf or take the buffer data ?

Best option for this kind of process ? oDbf or Hash ?

This will give me some idea of updating some program code. Thanks.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1356
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Best use of aSelected in Xbrowse

Postby nageswaragunupudi » Tue May 14, 2024 6:41 pm

In case of 1000 selected record, code A will do a FLock and code B will use Xbrowse and I suppose a RLock each record. Better use A for large selections ?

Yes, you are right.
Code A is efficient and Code B is very inefficient for bulk operations.

In case that changing a value in the loop that will also change a other value based on the changed value, in Code A we need to program it but in Code B Xbrowse will handle also the change in other field, so less code

True. For a few records this is better.
But for bulk operations, Code-A is better and we can handle the consequential changes in our code programmatically.

In large selections, It seems that code A can freeze ? (or just bad coding :D ) How can I show a Timer or visual reccount in Xbrowse


You may use:
1.
Code: Select all  Expand view
CursorWait()
<operation>
CursorArrow()

OR
2.
Code: Select all  Expand view
MsgRun( cMessage, cTitle, { || <operation> } )


Showing meter/progress reduces the speed very much.

oDbf

No. This is slower than direct operations on the DBF
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10299
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 48 guests