speed of browse

Post Reply
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

speed of browse

Post by plantenkennis »

Hello,

I have browse where I show a table and some values of other tables. The main table is 8000 rec. When I click on a record I get a new window that shows the details of the record. When I scroll down the table and click on a record, the detail window takes a few seconds to open. When I close this window this also takes a few seconds. Is there a way to speed up things

Code: Select all

FUNCTION Main()

    PUBLIC oWnd, oBrw           && the window and browse
    PUBLIC aDatabases[0][8]     && hold all databases
    PUBLIC aIndexFiles[0][2]    && holds alle indexfiles and indexkeys
    PUBLIC aPlanttype[0]        && alle planttypes
    PUBLIC aFamilie[0]          && alle families
    PUBLIC aWinter[21]
    PUBLIC aWinterKort[21]
    PUBLIC aNachtvorst[13]
    PUBLIC aGegevenSoort[0]
    
    PUBLIC cPath := Path()
    PUBLIC leigen := .T.
    PUBLIC lPro := .T.
    PUBLIC lEtiket := .F.
    PUBLIC cDataBasePad := cPath + "/databases/"
    PUBLIC cIconsPad := cPath + "/iconen/"
    PUBLIC oBrw
   
    SET DELETED ON
*   SET LANGUAGE TO DUTCH

    RK_FillArrays()
    RK_BestandsControle()
    RK_OpenTables()

SELECT Latnaam
SET ORDER TO 2

DEFINE WINDOW oWnd TITLE "Plantenkennis,  het meest uitgebreide planteninformatie programma" ;
    FROM 0, 0 TO ScreenHeight(), 1000

    RK_BuildMenu()
    RK_BuildBar()
    RK_BuildBrowse()
    
    DEFINE MSGBAR OF oWnd

    @ 0, 10 SAY "A FiveMac MsgBar" OF oWnd SIZE 150, 20 RAISED
  


ACTIVATE WINDOW oWnd ;

RETURN NIL

*************************************************

FUNCTION RK_BuildMenu()

    local oMenu
    
    MENU oMenu
        MENUITEM "Bestand"
        MENU
            MENUITEM "Over Plantenkennis" ACTION RK_
            MENUITEM "Item 2"
            SEPARATOR
            MENUITEM "Afsluiten" ACTION oWnd:End()
        ENDMENU
        MENUITEM "zoeken"
        MENU
            MENUITEM "zoeken op plantkode"
        ENDMENU
        
    ENDMENU
 
RETURN oMenu

*************************************************

FUNCTION RK_BuildBar()

LOCAL nZoeken := " "
LOCAL nRow := 250
LOCAL nShift := 28
LOCAL oBtn3, oBtn4, oBtn5, oBtn6

@ Screenheight()-130, 10 SAY "Snelzoeken:" OF oWnd
@ Screenheight()-125, 100 GET nZoeken PICTURE "@!" OF oWnd TOOLTIP "snel zoeken" SIZE 150, 25

@ Screenheight()-130, nRow BUTTON oBtn3 OF oWnd FILENAME "foto.bmp" ; 
    ACTION MsgInfo("hallo") SIZE 30, 30 STYLE 4
    nRow := nRow + nShift
@ Screenheight()-130, nRow BUTTON oBtn4 OF oWnd FILENAME "foto.bmp" ; 
    ACTION MsgInfo("hallo") SIZE 30, 30 STYLE 2
    nRow := nRow + nShift
@ Screenheight()-130, nRow BUTTON oBtn5 OF oWnd FILENAME "foto.bmp" ; 
    ACTION MsgInfo("hallo") SIZE 30, 30 STYLE 3
    nRow := nRow + nShift
@ Screenheight()-130, nRow BUTTON oBtn6 OF oWnd FILENAME "foto.bmp" ; 
    ACTION MsgInfo("hallo") SIZE 30, 30 STYLE 4


RETURN NIL

*************************************************

FUNCTION RK_BuildBrowse()

@ 20, 10 BROWSE oBrw ;
    FIELDS RK_GetFoto(plantnum), Latnaam->Plantkode, Latnaam->Naam, RK_GetNederNaam(plantnum), RK_GetPlanttype(plantnum);
    HEADERS "", "Plantkode", "Latijnse naam", "Nederlandse naam", "Planttype" ;
    OF oWnd SIZE 950, ScreenHeight()-150 ALIAS Alias()
      
oBrw:SetColBmp( 1 )
oBrw:SetColWidth( 1, 20 )
oBrw:SetColWidth( 2, 100 )
oBrw:SetColWidth( 3, 350 )
oBrw:SetColWidth( 4, 250 )
oBrw:SetColWidth( 5, 150 )
oBrw:SetColEditable( 1, .F. )
oBrw:SetColEditable( 2, .F. )
oBrw:SetColEditable( 3, .F. )
oBrw:SetColEditable( 4, .F. )
oBrw:SetColEditable( 5, .F. )
oBrw:SetColor( OwnClrGreen, OwnClrYellow )
oBrw:SetRowHeight( 20 )
oBrw:SetFont( "Geneva", 14 )

oBrw:bClrText = { | pColumn, nRowIndex | ColorFromNRGB( If( SUBSTR(STR(plantnum),-1,1) == '1', OwnClrLightGreen , OwnClrGreen ) ) }
*oBrw:bAction = { || RK_ShowDetail(plantnum) } 
   oBrw:bAction := { | obj , nindex|  RK_ShowDetail(plantnum) } 
oBrw:SetFocus()

RETURN NIL

*************************************************

FUNCTION RK_ShowDetail(nPlantnum)

LOCAL oDlg
LOCAL oFld, oBrw1, oBrw2
LOCAL oGetNaam, oGetAanteken
LOCAL oImg
LOCAL cLatijnNaam   := RK_GetLatijnseNaam(nPlantnum)
LOCAL aGegevens     := RK_CollectGegevens(nPlantnum)
LOCAL aKenmerken    := RK_CollectKenmerken(nPlantnum)
LOCAL cText         := ''
LOCAL cSnoei        := RK_GetSnoei(nPlantnum)
LOCAL aFotoNaam     := RK_CollectFoto(nPlantnum)
LOCAL nRow          := 260
LOCAL nKolom        := 10
LOCAL nFoto         := 1

DEFINE DIALOG oDlg TITLE "Detailscherm" ;
    FROM 0, 0 TO 500, 720

    @ 450, 10 GET oGetNaam VAR cLatijnNaam OF oDlg SIZE 700, 40
    
    oGetNaam:SetFont( "Geneva", 28 )
    oGetNaam:SetColor( OwnClrGreen, OwnClrYellow )
    
    @ 40, 10 FOLDER oFld SIZE 700, 400 OF oDlg ;
        PAGES "Gegevens", "Kenmerken", "Aantekeningen", "Fotos", "Snoei"
/*     
*eerste tabblad, gegevens
    @ 0, 0 BROWSE oBrw1 FIELDS "", "" ;
        HEADERS "", "" ;
        OF oFld:aDialogs[ 1 ] SIZE 680, 350

    oBrw1:SetArray( aGegevens )
    oBrw1:bLine = { | nRow | IF( nRow <= Len( aGegevens ), aGegevens[ nRow ], { "", "" } ) }
    oBrw1:SetColWidth( 1, 150 )
    oBrw1:SetColWidth( 2, 500 )
    oBrw1:SetColor( OwnClrGreen, OwnClrYellow )
    oBrw1:SetFocus()
    
*tweede tabblad, kenmerken
    @ 0, 0 BROWSE oBrw2 FIELDS "", "" ;
        HEADERS "", "" ;
        OF oFld:aDialogs[ 2 ] SIZE 680, 350

    oBrw2:SetArray( aKenmerken )
    oBrw2:bLine = { | nRow | If( nRow <= Len( aKenmerken ), aKenmerken[ nRow ], { "", "" } ) }
    oBrw2:SetColWidth( 1, 150 )
    oBrw2:SetColWidth( 2, 500 )
    oBrw2:SetColor( OwnClrGreen, OwnClrYellow )
    oBrw2:SetFocus()

*derde tabblad, aantekeningen  
   @ 0, 0 GET oGetAanteken VAR cText MEMO OF oFld:aDialogs[ 3 ] SIZE 680, 400
  
    oGetAanteken:SetRichText(.T.)
    oGetAanteken:SetImportGraf(.T.)
*   oGetAanteken:AddHRuler()
    oGetAanteken:SetUndo(.T.)
    oGetAanteken:SetFocus()
    oGetAanteken:SetEditable(.F.)
    cText := RK_GetAanteken(nPlantnum)
    oGetAanteken:SetAttributedString(cText)
    oGetAanteken:GoTop()

*vierde tabblad, foto's
    FOR r = 1 TO 3
        FOR k = 1 TO 5
            @ nRow, nKolom IMAGE oImg OF oFld:aDialogs[ 4 ] SIZE 110, 110 FILENAME aFotoNaam[nFoto]
            nKolom := nKolom + 120
            nFoto++
        NEXT
        nKolom := 10
        nRow := nRow - 120
    NEXT
   *    oImg:Click()

*vijfde tabblad, snoei
   @ 0, 0 GET oGetSnoei VAR cSnoei MEMO OF oFld:aDialogs[ 5 ] SIZE 680, 400
   
*   oGetSnoei:SetRichText(.T.)
*   oGetSnoei:SetImportGraf(.T.)
*   oGetSnoei:AddHRuler()
*   oGetSnoei:SetUndo(.T.)
    oGetSnoei:SetFocus()
*   cSnoei := RK_GetSnoei(nPlantnum)
*   oGetSnoei:SetAttributedString(cSnoei)
*   oGetSnoei:GoTop()
*/           
    @ 10, 10 BUTTON "OK" OF oDlg ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTERED
oBrw:SetFocus()

RETURN NIL
 

Rene
Kind regards,

René Koot
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: speed of browse

Post by Antonio Linares »

Rene,

Please email me your PRGs so I can run your app here, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply