General program technique : on init()

General program technique : on init()

Postby Marc Venken » Thu Oct 24, 2024 9:04 am

I was looking into my program and discovered that i think I do thinks wrong :

Short description :


DEFINE DIALOG oDlg FROM 60,0 to 750,1900 PIXEL TRUEPIXEL TITLE cTitle GRADIENT aGrad

@ 0, 0 FOLDEREX oFld SIZE oDlg:nWidth, oDlg:nHeight ;
PROMPT "Basis","Historiek","Art. Foto's","Leveranciers","Webshop Basis","Webshop Prijzen","Webshop Groepen","Webshop Staffel","Webshop Teksten","Webshop Kleuren","Ean","Archief","PrijsHistoriek","Upload";
....
oFld:aEnable = { .T., .T., .T.,.T.,.T.,.T.,.T.,.T.,.T.,.T.,.T.,.t.,.t.,.t. }
oFld:SetOption( 1 )
oFld:Show()
oFld:bAction := { || (FolderActions("ARTIKEL",oBrw,oFld)) }

make several Xbrowsres
oBrw[1] = getXBrowser("ARTIKEL",oFld:aDialogs[FOL_BASIS])
oBrw[1]:bChange := { || showpicture("ARTIKEL") }
oBrw[1]:Aankoop:bOnChange = { |oCol,uOldVal| change_art_aankoop(oBrw[1]:aankoop:value,oBrw[1]:bruto:value,"ARTIKEL","AANKOOPVELD",oBrw[1]) }
......
oBrw[3] = getXBrowser("ARTIKEL_FOTOS",oFld:aDialogs[FOL_ART_FOTOS])
oBrw[4] = getXBrowser("NOFOTO",oFld:aDialogs[4])
....
until 9 xbrowser's

ACTIVATE DIALOG oDlg CENTERED

The getxbrowser collect all settings for xbrowse in dbf and generate it. (the needed dbfs for xbrwsers are in the dbf and are opened in the getxbrowser function also.

So I have 9 folders in folderex.

What I see is that when startup the program, ALL 9 xbrowsers are processed and also all the filters are setup.
I was thinking that folder 1 was processed and all others only when they are called (selected from the folderex)

Does this have to do with not using on init clause or so ?

Maybe it is ment to be so ?

My question is esspacialy around the on init() clause or any function that will process a function ONLY when needed.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: General program technique : on init()

Postby karinha » Thu Oct 24, 2024 12:35 pm

Good morning Marc, it is almost impossible to understand what you want. Is it possible to make a complete example and make it available for download?

Buenos días Marc, es casi imposible entender lo que quieres. ¿Es posible hacer un ejemplo completo y ponerlo a disposición para descargar?

Gracias, tks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: General program technique : on init()

Postby Marc Venken » Thu Oct 24, 2024 1:38 pm

I wanted to proof myself wrong... and i did.

The way I programmed is wrong. Like the sample above, ALL xbrowse are executed before I see a dialog.

Putting them insite the folderactions function only the browse insite that TAB in de folder is executed because folderactions is only executed when we click on a TAB.

Code: Select all  Expand view

oFld:bAction := { || (FolderActions("ARTIKEL",oBrw,oFld)) }

function FolderActions(cData,oBrw,oFld)
  local cDbf1
  FIELD brwnaam
  oText[1]:hide()

  do case
    case cData = "KLANTEN"  // all folders in this DoCase
       if oFld:nOption=2
         if empty(oBrw[2])
            oBrw[2] = getXBrowser("KLANTDOCUMENTEN",oFld:aDialogs[2])
            oBrw[2]:bChange    := { || Scope("factinfo","document","factart","factart"),oBrw22:refresh() }
         endif
         Scope("klant","klant_nr","factinfo","docklantda")
         oBrw[2]:refresh()
         Scope("factinfo","document","factart","factart")
      endif
endcase
return NIL
 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 83 guests

cron