FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Best use of aSelected in Xbrowse
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Best use of aSelected in Xbrowse
Posted: Tue May 14, 2024 10:11 AM
Momentary i'm using both ways of processing aSelected in Xbrowse :
Code (fw): Select all Collapse
      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 (fw): Select all Collapse
      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.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Best use of aSelected in Xbrowse
Posted: Tue May 14, 2024 06: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 (fw): Select all Collapse
CursorWait()
<operation>
CursorArrow()
OR
2.
Code (fw): Select all Collapse
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

Continue the discussion