FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Again about scripting ... HB_CompileBuf
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Again about scripting ... HB_CompileBuf
Posted: Fri Mar 08, 2013 03:31 PM
Hi,

I think that this question is for Antonio ... :-) . It was discusion about that in earlier . You helped me in that .
The problem is that with more complicated PRG with some functions inside it's not working . So I leaved this question and now I want to wake up it now . As for a sample :

Code (fw): Select all Collapse
#include "tdolphin.ch"
#include "xbrowse.ch"
#include "fivewin.ch"

// external brw_menu2

function script_test()
local oWnd, oBrw, oQry, oCol
local cFld, cSql, cStr

cSql := "SELECT " + cFld + " FROM uzsakym WHERE db='" + cDb_id + "'"
oQry := oServ:Query( cSql )

DEFINE WINDOW oWnd MDICHILD OF wndMain()
    
@ 0, 0 XBROWSE oBrw OF oWnd DATASOURCE oQry

oBrw:nMarqueeStyle          := MARQSTYLE_HIGHLCELL
oBrw:nColDividerStyle       := LINESTYLE_BLACK
oBrw:nRowDividerStyle       := LINESTYLE_BLACK
oBrw:lColDividerComplete    := .t.

WITH OBJECT oBrw
   :bClrStd    := { || If( oBrw:KeyNo() % 2 == 0, ;
                         { CLR_BLACK, RGB( 224, 236, 255 ) }, ;
                         { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
   :bPopUp     := { || brw_menu2( oCol ) }
END

oBrw:CreateFromCode()
oWnd:oClient := oBrw

ACTIVATE WINDOW oWnd
return( NIL )

function brw_menu2( oCol )
   local oPopup
   MENU oPopup POPUP 2007
      MENUITEM "Filter ..." ACTION MsgInf( "Will be filter " )
      MENUITEM "Filter with input var ..." ACTION MsgInf( "Advanced filter" )
      SEPARATOR
      MENUITEM "Clear filters" ACTION MsgInf( "Clear filter" )
   ENDMENU
return( oPopup )


All source of prg as script is running OK without problem - query , xBrowse, mdi child . Until I press rigth mouse click on a browse ... :-)

Code (fw): Select all Collapse
   Error description: Error BASE/1001  Undefined function: BRW_MENU2
   Args:
     [   1] = U   

Stack Calls
===========
   Called from: pcode.hrb => BRW_MENU2( 0 )
   Called from: pcode.hrb => (b)UZSAK( 120 )


It seems that script can use only one function inside ... Or not ? What can you advise in this situation ?

With best regards !

Old Fwh 11.11 , Harbour 3.1 MinGW
Rimantas U.
Posts: 174
Joined: Sat Feb 23, 2013 10:04 AM
Re: Again about scripting ... HB_CompileBuf
Posted: Fri Mar 08, 2013 04:57 PM
Rimantas,

Restore:
Code (fw): Select all Collapse
// external brw_menu2



Regards
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Fri Mar 08, 2013 05:14 PM
Antonio Mart. wrote:Rimantas,
Restore:
Code (fw): Select all Collapse
// external brw_menu2


Regards


Hi Antonio !

Tried and that - the same result . I specially leave that visible .
Rimantas U.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Sat Mar 09, 2013 08:20 AM
Rimantas wrote:
Antonio Mart. wrote:Rimantas,
Restore:
Code (fw): Select all Collapse
// external brw_menu2


Regards


Hi Antonio !

Tried and that - the same result . I specially leave that visible .


Hi Antonio Linares ! I know that you are expert of Harbour ... Can you say some words in this theme ?

With best regards !
Rimantas U.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Again about scripting ... HB_CompileBuf
Posted: Sat Mar 09, 2013 01:09 PM

The code that is generated by the function hb_CompileBuf() can use any public function that is already linked to the application.

It is the programmer's responsibility to ensure that all functions used in the script are already linked, by using EXTERNAL <func> whereever necessary.

Regards



G. N. Rao.

Hyderabad, India
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Sat Mar 09, 2013 02:09 PM
nageswaragunupudi wrote:The code that is generated by the function hb_CompileBuf() can use any public function that is already *linked* to the application.

It is the programmer's responsibility to ensure that all functions used in the script are already linked, by using EXTERNAL <func> whereever necessary.


Hello Rao !

Other functions are working fine . Mine prg is more complex and I'm nothing saying about other externals functions . I did minimal simple sample . I'm asking about situation as described in the sample - define dialog/window with controls and other function IN THE SAME PRG( SCRIPT ) . I'm not sure that in all situations it will be enough to described SCRIPT in one function . At this moment I did a sample with xBrowse popup menu , in other script this can be other function .

From scrpts.prg ( script.dbf memo ) in fwh\samples . Simply do that :
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()
   local oDlg

   Test() // here was commented 

   DEFINE DIALOG oDlg TITLE "A dialog" ;
      GRADIENT { { 1, CLR_BLUE, RGB( 120, 100, 200 ) } } ;
      SIZE 500, 300

   @ 7, 18 BTNBMP PROMPT "Ok" SIZE 40, 15 ACTION oDlg:End() 2007

   ACTIVATE DIALOG oDlg CENTERED

return nil

function Test()
MsgInfo("Test" )
return NIL


I only want REALLY to know - can script to run some functions ( related to each other ) inside one script ? At this moment I'm thinking that NO ... :-) . If really that no - it will be very pitty ...

With best regards ...
Rimantas U.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Sun Mar 10, 2013 01:34 PM
Rimantas wrote:
nageswaragunupudi wrote:The code that is generated by the function hb_CompileBuf() can use any public function that is already *linked* to the application.

It is the programmer's responsibility to ensure that all functions used in the script are already linked, by using EXTERNAL <func> whereever necessary.


Hello Rao !

Other functions are working fine . Mine prg is more complex and I'm nothing saying about other externals functions . I did minimal simple sample . I'm asking about situation as described in the sample - define dialog/window with controls and other function IN THE SAME PRG( SCRIPT ) . I'm not sure that in all situations it will be enough to described SCRIPT in one function . At this moment I did a sample with xBrowse popup menu , in other script this can be other function .

From scrpts.prg ( script.dbf memo ) in fwh\samples . Simply do that :
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()
   local oDlg

   Test() // here was commented 

   DEFINE DIALOG oDlg TITLE "A dialog" ;
      GRADIENT { { 1, CLR_BLUE, RGB( 120, 100, 200 ) } } ;
      SIZE 500, 300

   @ 7, 18 BTNBMP PROMPT "Ok" SIZE 40, 15 ACTION oDlg:End() 2007

   ACTIVATE DIALOG oDlg CENTERED

return nil

function Test()
MsgInfo("Test" )
return NIL


I only want REALLY to know - can script to run some functions ( related to each other ) inside one script ? At this moment I'm thinking that NO ... :-) . If really that no - it will be very pitty ...

With best regards ...


It seems that Antonio Linares is departed .. No any comments from them .. :-)

Regards !
Rimantas U.
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: Again about scripting ... HB_CompileBuf
Posted: Sun Mar 10, 2013 08:50 PM

Sorry, Rimatas, I disagree with you as you can´t blame Antonio for Harbour issues.

Fivetech provides an extraordinary support, quick, effective and useful, which you can´t find in other xBase companies such xHarbour.com.

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Mon Mar 11, 2013 07:41 AM
lucasdebeltran wrote:Sorry, Rimatas, I disagree with you as you can´t blame Antonio for Harbour issues.

Fivetech provides an extraordinary support, quick, effective and useful, which you can´t find in other xBase companies such xHarbour.com.


Hello Lucas !

Why you are so thinking ? I know that Antonio is a good expert of Harbour and parcipicated creating Harbour . I only want to give from him advise ... 'Blame for Harbour' ... I do not have any mind of that . Sorry , if mine question and reflection raised to you such idea ...
OK , after your answer I searched and found google groups of harbour . Simply this forum is comfortable in form and very quick in answer - I love that. In the past , harbour mailing list form was very uncomfortable . Now google group it seems is more friendly form for discusion . I'll also ask in that group this question. Nothing answered in this forum - can prg as script have some working function inside ?

With best regards !
Rimantas U.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Mon Mar 11, 2013 07:59 AM

Rimantas,

I was travelling and could not answer yet.

Are you using FWH function Execute( cCode ) ? Please check that you execute your scripts the same way as FWH/samples/scripts.prg does it

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Mon Mar 11, 2013 08:16 AM
Antonio Linares wrote:Rimantas,

I was travelling and could not answer yet.

Are you using FWH function Execute( cCode ) ? Please check that you execute your scripts the same way as FWH/samples/scripts.prg does it


Wow ! Antonio ! How good is heard you ! :-) Greetings to you and thanks for the question ! :-)

I was not used Execute( cCode ) . Mine last run ( I tried some versions, but without execute ) :

Code (fw): Select all Collapse
function Run_prg( cPrg )
local oHrb, cResult
if !db_conn()
   return( NIL )
endif
if !file( cPrg + ".prg" )
   MsgAlert( "Nera tokio failo: " + cPrg + ".prg !" )
   return( NIL )
endif

FReOpen_Stderr( "run_prg.log", "w" )
HB_Compile( "", cPrg + ".prg", "/n", "/gh", "-ID:\A\fwh\include", "-ID:\A\hrbg\include" )
oHrb = HB_HRBLOAD( cPrg + ".hrb" )
HB_HRBDO( oHrb )
HB_HRBUNLOAD( oHrb )
oHrb = NIL
return( NIL )


I'll try execute and let know to you ...

With best regards !

ADDED :

Copied piece of source from scripts.prg :

FReOpen_Stderr( "run_prg.log", "w" )
oHrb := HB_CompileFromBuf( memoread( cPrg + ".prg" ), "-n", "-ID:\A\fwh\include", "-ID:\A\hrb\include" )
if ! Empty( oHrb )
hb_HrbRun( oHrb )
endif

Sorry , but other function in the same scripts return error : Error description: Error BASE/1001 Undefined function: MOD_PAS .

Here I simply add addidtional check for one field :

:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( if( mod_pas( aMod, xVal ), ( oQry:preke := xVal, oQry:Save() ), ) ) ) }

Also tried and that :
:bPopUp := { |oCol| brw_menu3( oCol ) }

function brw_menu3( oCol )
local oPopup
MsgInfo( "second function inside script ..." )
MENU oPopup POPUP 2007
MENUITEM if( cLg == "L", "Filtruoti ...", "Filter ..." ) ACTION MsgInf( "filtruosim 1 " )
MENUITEM if( cLg == "L", "Filtruoti įvedant reikšmę ...", "Filter with input var ..." ) ACTION MsgInf( "filtruosim 2 " )
SEPARATOR
MENUITEM if( cLg == "L", "Pašalinti filtrus", "Clear filters" ) ACTION MsgInf( "salinsim " )
ENDMENU
return( oPopup )

Undefined function ... :-) .
Rimantas U.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Mon Mar 11, 2013 05:09 PM
Antonio Linares wrote:Rimantas,

I was travelling and could not answer yet.
Are you using FWH function Execute( cCode ) ? Please check that you execute your scripts the same way as FWH/samples/scripts.prg does it


Antonio, I'm waiting for your word ... :-)

Did as in scripts.prg , but second function in the same prg "Undefined ..."

Regards !
Rimantas U.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Mon Mar 11, 2013 09:22 PM
Rimantas,

Please try this example from FWH/samples/scripts.prg:

Here it is working fine. Please ty to provide me a simple example like this one that reproduces your error, thanks

Code (fw): Select all Collapse
function One()

   MsgInfo( "one" )
   Two()

return nil

function Two()

   MsgInfo( "two" )
   Three()

return nil

function Three()

   MsgInfo( "Three" )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Tue Mar 12, 2013 05:49 PM
Antonio Linares wrote:Please try this example from FWH/samples/scripts.prg:
Here it is working fine. Please ty to provide me a simple example like this one that reproduces your error, thanks
Code (fw): Select all Collapse
function One()
   MsgInfo( "one" )
   Two()
return nil

function Two()
   MsgInfo( "two" )
   Three()
return nil

function Three()
   MsgInfo( "Three" )
return nil


Hello Antonio ! Tried your sample ( scripts .prg ) . I simply changed one line : oHrb = HB_CompileFromBuf( memoread( "testxbr4.prg" ), "-n", "-I\a\fwh\include", "-I\a\hb32\include" ) . Testxbr4.prg changed too :

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "xbrowse.ch"

function xbr4()
   local oDlg, oBrw
   DEFINE DIALOG oDlg SIZE 300, 200
   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY { { "one","two","three" } } AUTOCOLS
      
   oBrw:CreateFromCode() 
   oBrw:bKeyDown = { || oDlg:SetText( Str( oBrw:nColSel ) ) }  
   oBrw:bPopUp    := { |o| ColMenu( o ) }
      
   ACTIVATE DIALOG oDlg CENTER ON INIT ( oDlg:oClient := oBrw, oDlg:Resize() )
return nil

static function ColMenu( ocol )
   local oPop
   MENU oPop POPUP 2007
      MENUITEM "Left Align" ACTION MsgInfo( "Left" )
      MENUITEM "Center Align" ACTION MsgInfo( "Center" )
      MENUITEM "Right Align" ACTION MsgInfo( "Right" )
   ENDMENU
return oPop


Works very fine ! The other function in this simple sample is working . Now problems with mine code ... With mine source other functions inside prg are not working . Maybe I want too much and such code can't be run as script... :-) I'm copying source :

Code (fw): Select all Collapse
#include "fivewin.ch"
#include "xbrowse.ch"
#include "tdolphin.ch"
#include "dtpicker.ch"

FUNCTION uzsak()
local oWnd, oBrw, oQry, oCol, oBar, oPopup
local aDgr, aCol, aHdr, aPct, aWnd
local cFld, cSql, cStr
local cTbl := "uzsakym"
local cWnd := "uzsakym"
local nL_g := if( cLg == "L", 2, 3 )
local cYs  := padr( msgId( "cTaip", cLg ), 4 )
local cNo  := padr( msgId( "cNe"  , cLg ), 4 )
local lEdt := .t.
local u    := 0
local aMod := {}

local aGrd := { ;
{ "uzsak"         , "Užsak.ID"           , "Order.ID"         , 150, "@!"      }, ;
{ "telkinys"      , "Telkinys"           , "Pool"             ,  80, "@!K"     }, ;
{ "preke"         , "Prekės ID"          , "Item ID"          , 150, "@!K"     }, ;
{ "uzs_kiekis"    , "Kiekis"             , "Qty."             ,  75, "@999999" }, ;
{ "svarbus"       , "Svarbus"            , "Important"        ,  50, ""        }, ;
{ "specai"        , "Spec"               , "Spec"             ,  50, ""        }, ;
{ "mazi"          , "Mazi"               , "Smalls"           ,  50, ""        }, ;
{ "uzs_spalv"     , "Užsak.spalvos"      , "Ord.colors"       , 100, "@!K"     }, ;
{ "uzs_data"      , "Užs.data"           , "Ord.date"         , 100, "@D"      }, ;
{ "uzs_sav"       , "Užs.sav."           , "Ord.week"         ,  75, ""        }, ;
{ "graz_data"     , "Grąž.data"          , "Ret.date"         , 100, "@D"      }, ;
{ "graz_sav"      , "Grąž.sav."          , "Ret.week"         ,  75, ""        }, ;
{ "fakt_data"     , "Fakt.data"          , "Fact.date"        , 100, "@D"      }, ;
{ "fakt_sav"      , "Fakt.sav."          , "Fact.week"        ,  75, ""        }, ;
{ "pastabos_ord"  , "Ord.pastaba"        , "Ord.note"         , 180, "@!"      }, ;
{ "zymos"         , "Žymos"              , "Notes"            ,  80, "@!"      }, ;
{ "kerpa"         , "Kerpa"              , "Cutting"          , 100, ""        }, ;
{ "sukirp_lap"    , "Suk.lapas"          , "Cut.page"         ,  80, "@!K"     }, ;
{ "etiketes"      , "Etiketės"           , "Labels"           ,  40, "@!K"     }, ;
{ "gav_data"      , "Gavim.data"         , "Recv.date"        , 100, "@D"      }, ;
{ "subrang"       , "Subrangovas"        , "Subcontr."        , 100, ""        }, ;
{ "aud_nuras"     , "Aud.nur."           , "Mater.off"        ,  60, ""        }, ;
{ "frn_nuras"     , "Furn.nur."          , "Furnit.off"       ,  60, ""        }, ;
{ "invc_nuras"    , "Sąsk.nur."          , "Invoice off"      ,  60, ""        }, ;
{ "nav_nuras"     , "NAV nur."           , "NAV off"          ,  60, ""        }, ;
{ "pasel_prad"    , "Pasel.prad."        , "Mak.begin"        ,  60, ""        }, ;
{ "pokav_prad"    , "Pokav.prad."        , "Pack.begin"       ,  60, ""        }, ;
{ "prilyg_mod"    , "Prilyg.modelis"     , "Equat.model"      , 150, "@!K"     }, ;
{ "prilyg_kiekis" , "Prilyg.kiekis"      , "Eq.qty"           ,  75, "@999999" }, ;
{ "pastabos_buh"  , "Pastabos buh."      , "Account notes"    , 180, "@!"      }, ;
{ "buh_specas"    , "Buh.spec"           , "Buh.spec"         ,  60, ""        }, ;
{ "pastabos_zs"   , "Pastabos Zarasu"    , "Notes of Zarasai" , 180, "@!"      }, ;
{ "pok_lap_mod"   , "Pokav.lapo modelis" , "Pack.list model"  , 150, "@!K"     } }


aWnd := wnd_rest( cWnd )
if len( aWnd ) == 0
   aWnd := { 20, 20, 500, 800, .f. }
endif

aDgr := brw_rest( cTbl, aGrd, cLg )
cFld := aDgr[ 1 ]
aCol := aDgr[ 2 ]
aHdr := aDgr[ 3 ]
aPct := aDgr[ 7 ]

cStr := if(  cLg == "L", "pav_lt", "pav_en" )
aMod := qry_arr( "SELECT preke," + cStr + " FROM prekes WHERE prek_tipas = 'Gaminys' AND db='" + cDb_id + "' ORDER BY preke", { "preke", cStr } )

cSql := "SELECT " + cFld + " FROM uzsakym WHERE db='" + cDb_id + "'"
oQry := oServ:Query( cSql )

DEFINE WINDOW oWnd MDICHILD OF wndMain() TITLE "Užsakymai" PIXEL FROM aWnd[ 1 ], aWnd[ 2 ] TO aWnd[ 3 ], aWnd[ 4 ]
if aWnd[ 5 ] == .f.
   oWnd:Move( aWnd[ 1 ], aWnd[ 2 ], aWnd[ 4 ], aWnd[ 3 ], .t. )
  else
   oWnd:Maximize()
endif
Ikona( oWnd )
oWnd:Hide()
oWnd:Cargo := cWnd
    
@ 0, 0 XBROWSE oBrw OF oWnd DATASOURCE oQry COLUMNS aCol HEADERS aHdr PICTURES aPct AUTOSORT

oBrw:nMarqueeStyle          := MARQSTYLE_HIGHLROWMS
oBrw:nColDividerStyle       := LINESTYLE_BLACK
oBrw:nRowDividerStyle       := LINESTYLE_BLACK
oBrw:lColDividerComplete    := .t.

brw_col( oBrw, aCol )

oCol := oBrw:aCols[ ascan( aCol, "uzsak" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:uzsak }
   :bEditValid      := { | oGet, oCol | var_not_exist( "uzsakym", oCol:cExpr, oGet:Value(), "ut" ) }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,, ( oQry:uzsak := xVal, oQry:Save(), if( oQry:lAppend == .t., oQry:lAppend := .f., ) ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "telkinys" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:telkinys }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:telkinys := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "preke" ) ]
WITH OBJECT oCol
   :bEditValue      := { || oQry:preke }
   :nEditType       := if( lEdt, EDIT_GET_BUTTON, EDIT_NONE )
   :bEditBlock      := { | nRow, nCol, oCol | brw_arr( "Pasirinkite !", { "Modelis", "Model.pavadinimas" }, aMod, oCol:Value ) }
   :bEditValid      := { | oGet, oCol | mod_pas( aMod, oCol:Value ) }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:preke := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "prilyg_mod" ) ]
WITH OBJECT oCol
   :bEditValue      := { || oQry:prilyg_mod }
   :nEditType       := if( lEdt, EDIT_GET_BUTTON, EDIT_NONE )
   :bEditBlock      := { | nRow, nCol, oCol | brw_arr( "Pasirinkite !", { "Modelis", "Model.pavadinimas" }, aMod, oCol:Value ) }
   :bEditValid      := { | oGet, oCol | mod_pas( aMod, oCol:Value ) }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:prilyg_mod := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "uzs_kiekis" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:uzs_kiekis }
   :bEditValid      := { | oGet, oCol | oCol:Value > 0 }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:uzs_kiekis := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "prilyg_kiekis" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:prilyg_kiekis }
   :bEditValid      := { | oGet, oCol | oCol:Value >= 0 }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:prilyg_kiekis := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "svarbus" ) ]
WITH OBJECT oCol
   :AddBitmap( cProgr_pict + "on.bmp"  )
   :AddBitmap( cProgr_pict + "off.bmp" )
   :bEditValue      := { || oQry:svarbus }
   :bBmpData        := { || if( oQry:svarbus == .t., 1, 2 ) }
   if lEdt 
      :bStrData        := { || if( oQry:svarbus == .t., cYs, cNo ) }   
      :nEditType       := EDIT_LISTBOX
      :aEditListTxt    := { cYs, cNo }
      :aEditListBound  := { .t., .f. }  
      :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:svarbus := xVal, oQry:Save() ) ) }
   endif
END

oCol := oBrw:aCols[ ascan( aCol, "specai" ) ]
WITH OBJECT oCol
   :AddBitmap( cProgr_pict + "on.bmp"  )
   :AddBitmap( cProgr_pict + "off.bmp" )
   :bEditValue      := { || oQry:specai }
   :bBmpData        := { || if( oQry:specai == .t., 1, 2 ) }
   if lEdt 
      :bStrData        := { || if( oQry:specai == .t., cYs, cNo ) }   
      :nEditType       := EDIT_LISTBOX
      :aEditListTxt    := { cYs, cNo }
      :aEditListBound  := { .t., .f. }  
      :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:specai := xVal, oQry:Save() ) ) }
   endif
END

oCol := oBrw:aCols[ ascan( aCol, "mazi" ) ]
WITH OBJECT oCol
   :AddBitmap( cProgr_pict + "on.bmp"  )
   :AddBitmap( cProgr_pict + "off.bmp" )
   :bEditValue      := { || oQry:mazi }
   :bBmpData        := { || if( oQry:mazi == .t., 1, 2 ) }
   if lEdt 
      :bStrData        := { || if( oQry:mazi == .t., cYs, cNo ) }   
      :nEditType       := EDIT_LISTBOX
      :aEditListTxt    := { cYs, cNo }
      :aEditListBound  := { .t., .f. }  
      :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:mazi := xVal, oQry:Save() ) ) }
   endif   
END

oCol := oBrw:aCols[ ascan( aCol, "buh_specas" ) ]
WITH OBJECT oCol
   :AddBitmap( cProgr_pict + "on.bmp"  )
   :AddBitmap( cProgr_pict + "off.bmp" )
   :bEditValue      := { || oQry:buh_specas }
   :bBmpData        := { || if( oQry:buh_specas == .t., 1, 2 ) }
   if lEdt 
      :bStrData        := { || if( oQry:buh_specas == .t., cYs, cNo ) }   
      :nEditType       := EDIT_LISTBOX
      :aEditListTxt    := { cYs, cNo }
      :aEditListBound  := { .t., .f. }  
      :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:buh_specas := xVal, oQry:Save() ) ) }
   endif   
END

oCol := oBrw:aCols[ ascan( aCol, "uzs_spalv" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:uzs_spalv }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:uzs_spalv := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "uzs_data" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_DATE, EDIT_NONE )
   :bEditValue      := { || oQry:uzs_data }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:uzs_data := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "uzs_sav" ) ]
WITH OBJECT oCol
   :nEditType       := EDIT_NONE
   :bEditValue      := { || oQry:uzs_sav }
END

oCol := oBrw:aCols[ ascan( aCol, "graz_data" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_DATE, EDIT_NONE )
   :bEditValue      := { || oQry:graz_data }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:graz_data := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "graz_sav" ) ]
WITH OBJECT oCol
   :nEditType       := EDIT_NONE
   :bEditValue      := { || oQry:graz_sav }
END

oCol := oBrw:aCols[ ascan( aCol, "fakt_data" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_DATE, EDIT_NONE )
   :bEditValue      := { || oQry:fakt_data }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:fakt_data := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "fakt_sav" ) ]
WITH OBJECT oCol
   :nEditType       := EDIT_NONE
   :bEditValue      := { || oQry:fakt_sav }
END

oCol := oBrw:aCols[ ascan( aCol, "pastabos_ord" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:pastabos_ord }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:pastabos_ord := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "zymos" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:zymos }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:zymos := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "sukirp_lap" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:sukirp_lap }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:sukirp_lap := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "etiketes" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:etiketes }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:etiketes := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "gav_data" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_DATE, EDIT_NONE )
   :bEditValue      := { || oQry:gav_data }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:gav_data := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "kerpa" ) ]
WITH OBJECT oCol
   :bEditValue      := { || oQry:kerpa }
   :nEditType       := if( lEdt, EDIT_LISTBOX, EDIT_NONE )
   :aEditListTxt    := { padr( "Danija", 10 ), padr( "Zarasai", 10 ) }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:kerpa := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "subrang" ) ]
WITH OBJECT oCol
   :bEditValue      := { || oQry:subrang }
   :nEditType       := if( lEdt, EDIT_LISTBOX, EDIT_NONE )
   :aEditListTxt    := { padr( "UT", 10 ), padr( "BR", 10 ) }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:subrang := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "aud_nuras" ) ]
WITH OBJECT oCol
   :AddBitmap( cProgr_pict + "on.bmp"  )
   :AddBitmap( cProgr_pict + "off.bmp" )
   :bEditValue      := { || oQry:aud_nuras }
   :bBmpData        := { || if( oQry:aud_nuras == .t., 1, 2 ) }
   :bStrData        := { || NIL }
   :nEditType       := EDIT_NONE
END

oCol := oBrw:aCols[ ascan( aCol, "frn_nuras" ) ]
WITH OBJECT oCol
   :AddBitmap( cProgr_pict + "on.bmp"  )
   :AddBitmap( cProgr_pict + "off.bmp" )
   :bEditValue      := { || oQry:frn_nuras }
   :bBmpData        := { || if( oQry:frn_nuras == .t., 1, 2 ) }
   :nEditType       := EDIT_NONE
   :bStrData        := { || NIL }
END

oCol := oBrw:aCols[ ascan( aCol, "invc_nuras" ) ]
WITH OBJECT oCol
   :AddBitmap( cProgr_pict + "on.bmp"  )
   :AddBitmap( cProgr_pict + "off.bmp" )
   :bEditValue      := { || oQry:invc_nuras }
   :bBmpData        := { || if( oQry:invc_nuras == .t., 1, 2 ) }
   :nEditType       := EDIT_NONE
   :bStrData        := { || NIL }
END

oCol := oBrw:aCols[ ascan( aCol, "nav_nuras" ) ]
WITH OBJECT oCol
   :AddBitmap( cProgr_pict + "on.bmp"  )
   :AddBitmap( cProgr_pict + "off.bmp" )
   :bEditValue      := { || oQry:nav_nuras }
   :bBmpData        := { || if( oQry:nav_nuras == .t., 1, 2 ) }
   :nEditType       := EDIT_NONE
   :bStrData        := { || NIL }
END

oCol := oBrw:aCols[ ascan( aCol, "pasel_prad" ) ]
WITH OBJECT oCol
   :AddBitmap( cProgr_pict + "on.bmp"  )
   :AddBitmap( cProgr_pict + "off.bmp" )
   :bEditValue      := { || oQry:pasel_prad }
   :bBmpData        := { || if( oQry:pasel_prad == .t., 1, 2 ) }
   :nEditType       := EDIT_NONE
   :bStrData        := { || NIL }
END

oCol := oBrw:aCols[ ascan( aCol, "pokav_prad" ) ]
WITH OBJECT oCol
   :AddBitmap( cProgr_pict + "on.bmp"  )
   :AddBitmap( cProgr_pict + "off.bmp" )
   :bEditValue      := { || oQry:pokav_prad }
   :bBmpData        := { || if( oQry:pokav_prad == .t., 1, 2 ) }
   :nEditType       := EDIT_NONE
   :bStrData        := { || NIL }
END

oCol := oBrw:aCols[ ascan( aCol, "pastabos_buh" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:pastabos_buh }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:pastabos_buh := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "pastabos_zs" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:pastabos_zs }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:pastabos_zs := xVal, oQry:Save() ) ) }
END

oCol := oBrw:aCols[ ascan( aCol, "pok_lap_mod" ) ]
WITH OBJECT oCol
   :nEditType       := if( lEdt, EDIT_GET, EDIT_NONE )
   :bEditValue      := { || oQry:pok_lap_mod }
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:pok_lap_mod := xVal, oQry:Save() ) ) }
END

WITH OBJECT oBrw
   :bClrStd       := { || If( oBrw:KeyNo() % 2 == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
   :bPopUp        := { |oCol| brw_menu( oCol ) }
   :lRecordSelector := .t.
END

if len( aDgr ) > 0
   for u := 1 to len( oBrw:aCols )
      oBrw:aCols[ u ]:nWidth := aDgr[ 5, u ]
      oBrw:aCols[ u ]:lHide  := aDgr[ 6, u ]
   next
endif

SetBalloon( .T. )

DEFINE BUTTONBAR oBar OF oWnd SIZE 60, 60 2007

MENU oPopup POPUP
   MENUITEM "Naujas įrašas" ACTION newRec( oBrw, oQry, 1 )
   MENUITEM "Nauji įrašai iš Excel failo" ACTION newRec( oBrw, oQry, 2 )
   MENUITEM "Nauji įrašai iš Sukirpimo failo" ACTION newRec( oBrw, oQry, 3 )
ENDMENU

DEFINE BUTTON OF oBar ACTION newRec( oBrw, oQry ) FILENAME cProgr_pict + "Bar\New.bmp" MENU oPopup PROMPT if( cLg == "L", 'Naujas', 'New' ) TOOLTIP if( cLg == "L", 'Nauji įrašai', 'New records' )
DEFINE BUTTON OF oBar ACTION delRec( oBrw, oQry ) FILENAME cProgr_pict + "Bar\Delete.bmp" PROMPT if( cLg == "L", 'Šalinti', 'Delete' ) TOOLTIP if( cLg == "L", 'Šalinti įrašus', 'Delete records' )
DEFINE BUTTON OF oBar ACTION excRec( oBrw, oQry ) FILENAME cProgr_pict + "Bar\Doc-Excel.bmp" GROUP PROMPT if( cLg == "L", 'Excelis', 'Excel' ) TOOLTIP if( cLg == "L", 'Eskportas į Excelį', 'Export to Excel' )

oBrw:CreateFromCode()
oWnd:oClient := oBrw

ACTIVATE WINDOW oWnd ON INIT ( oBrw:GoBottom(), oBrw:SetFocus(), if( aWnd[ 5 ] == .t., oWnd:Maximize(), ) ) VALID ( brw_save( oBrw, cTbl ), wnd_save( oWnd, cWnd ), wnd_end( oBrw, oQry ), .t. ) 

return( NIL )

function mod_pas( aMod, cMod )
if empty( cMod )
   return .f.
endif
return( if( ascan( aMod, { |x| x[ 1 ] == cMod } ) <> 0, .t., .f. ) )

function newRec( oBrw, oQry, nRez )
MsgInfo( "naujas irasas ! " + str( nRez ) )
return( NIL )

function delRec( oBrw, oQry )
MsgInfo( "delete record !" )
return( NIL )

function excRec( oBrw, oQry )
MsgInfo( "eksportas i Exceli !" )
return( NIL )


All this outside functions ( mod_pas, newRec, delRec and excRec ) are "Undefined ..." :-) . All this complex browse window works fine ! It let me go crazy ( :-) ) , why this other functions in scripts are not working .

ADDED : I'm suspecting , that this can be related with settings for app.build . Here is mine hbp :

Code (fw): Select all Collapse
-inc
-incpath=\a\fwh\include
-incpath=\a\hb32\include

-L\A\hb32\comp\mingw\lib 
-L\A\hb32\lib\win\mingw 
-L\a\fwh\lib
-lfivehg 
-lfivehgc 
-llibmysqlm
-ldolphin
-lgtgui 
-luser32 
-lwinspool 
-lkernel32 
-lcomctl32 
-lcomdlg32 
-lgdi32 
-lgdiplus 
-lole32 
-loleaut32 
-lpsapi 
-loledlg 
-lmfcuia32 
-lmsimg32 
-lwin32k 
-lstdc++ 
-lversion 
-luuid 
-lwinmm 
-lvfw32 
-lwsock32 
-lhbcommon 
-lhbcpage 
-lhbcplr 
-lhbct 
-lhbhsx 
-lhblang 
-lhbmacro 
-lhbmainstd 
-lhbmzip 
-lodbc32 
-lhbpcre 
-lhbpp 
-lhbrdd 
-lhbrtl 
-lhbsix 
-lhbtip 
-lhbusrrdd 
-lhbvm 
-lhbwin 
-lhbzlib 
-lrddcdx 
-lrddfpt 
-lrddntx 
-lxhb 
-lpng 

-oengel.exe
-icon=engel.ico

-gui
-w3 -es0
-ldflag=-Wl,--allow-multiple-definition

engel.prg
func.prg
func_brw.prg
func_dsg.prg
func_dt.prg
tarray.prg
engel.rc


With best regards !
Rimantas U.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Again about scripting ... HB_CompileBuf
Posted: Tue Mar 12, 2013 07:41 PM
All this outside functions ( mod_pas, newRec, delRec and excRec ) are "Undefined ..."


Have you declared them as extern ?
regards, saludos

Antonio Linares
www.fivetechsoft.com