grid can handle how many records

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
koshal_ag
Posts: 2
Joined: Wed Apr 17, 2019 4:56 am
DBs Used: DBF
Location: Muzaffarnagar,UP,India
Contact:

grid can handle how many records

Post by koshal_ag »

I have started just now with HMG and written a small prog to show filtered record from a database but it get hangs when i click on search
here is my code
databas xpbook contains about 12000 records
#include "hmg.ch"
Function Main
OpenTables()
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 800 HEIGHT 600 ;
TITLE 'Library Book Search' ;
MAIN //MAXIMIZE
@ 10 ,10 LABEL LABEL_1 VALUE "BOOK/AUTHOR/PUBLISHER" width 200
@ 10 ,200 TEXTBOX TEXT_1 width 400
@ 10 ,700 BUTTON BUTTON_1 CAPTION 'SEARCH' ACTION FILEFILT()
@ 100,10 GRID Grid_1 ;
WIDTH 1200 ;
HEIGHT 600 ;
HEADERS { 'Book Name' , 'Author','Publisher','Subject','Location'} ;
WIDTHS { 250 , 150,150,150,150} ;
ROWSOURCE "book" ;
COLUMNFIELDS { 'Name' , 'auth','publ','subj','Loca' } ;

END WINDOW
CENTER WINDOW Win_1
ACTIVATE WINDOW Win_1
Return Nil
Procedure OpenTables()
sele 1
Use xpbook
copy stru to book
sele 2
use book
* set filt to "CHAND" $ UPPE(name)
* Win_1.Browse_1.Value := RecNo()
Return Nil
Procedure CloseTables()
sele 1
Use
sele 2
use
Return Nil
Procedure filefilt()
win_1.GRID_1.hide
sele book
use
SELE xpBOOK
if len(WIN_1.TEXT_1.VALUE)#0
copy TO book for UPPE(WIN_1.TEXT_1.VALUE) $ UPPE(NAME+auth+publ+subj)
else
copy to book for recno()>0
endi
sele 2
use book
coun to kk
@ 10 ,1000 LABEL LABEL_2 VALUE "Total books shorted "+str(kk,5,0) width 300
go top
win_1.GRID_1.show
Return Nil

please also guide to release memory or it automatically releases after closing programe
thanks in advance
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: grid can handle how many records

Post by andyglezl »

Ya probaste este ejemplo ?
*--------------------------------
Have you tried this example?

\HMG\3.4.4\SAMPLES\Controls\Grid\GRID_32\demo.prg
Andrés González López
Desde Guadalajara, Jalisco. México.
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: grid can handle how many records

Post by franco »

I like to use temporary index instead of filters.
At start of my main function I create a temporary folder. This folder will always be available throughout program.
You do not have to remove the folder at end of program.
Main
createfolder("c:\mytemp")
Now you only need one table. Use xpbook
In procedure create temp index. You can index on any of the fields in the table that are in the grid. The grid order will be by that index.
The grid will use exbook table.
Procedure filefilt()
select exbook
if len(WIN_1.TEXT_1.VALUE)#0
index on name to c:\mytemp\temp for UPPE(WIN_1.TEXT_1.VALUE) $ UPPE(NAME+auth+publ+subj)
else
index on subj to c:\mytemp\temp
endi
go top
return
I have not tested but this should work. very fast on network .
Also I still use browse instead of grid for viewing or pick from tables, much faster.
I use grid for working with tables, usually the indexed tables are smaller.
Franco
All The Best,
Franco
Canada
koshal_ag
Posts: 2
Joined: Wed Apr 17, 2019 4:56 am
DBs Used: DBF
Location: Muzaffarnagar,UP,India
Contact:

Re: grid can handle how many records

Post by koshal_ag »

thanx a lot franco i was missing win1_grid_1.refresh i used it and my grid is showing the thing OK now pls can u let me know the replacement of maxrow() and maxcol() here so that i can initialize my prog screen to open in a full screen mode .
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: grid can handle how many records

Post by franco »

Try
WIDTH GetdesktopWidth() - 50 ; Can try different minus amounts
HEIGHT GetdesktopHeight() -50 ;
NOSIZE ;
There may be other ways, my display knowledge is slim
Franco
All The Best,
Franco
Canada
Post Reply