Startup function
- Enrico Maria Giordano
- Posts: 8728
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Startup function
Dear friends,
The MAIN() function is the startup function in Harbour and xHarbour. But in xHarbour the function MAIN() is the startup function only when its module is the first linked in. Do you know a way to specify a startup function in xHarbour that is not in the first linked module?
The MAIN() function is the startup function in Harbour and xHarbour. But in xHarbour the function MAIN() is the startup function only when its module is the first linked in. Do you know a way to specify a startup function in xHarbour that is not in the first linked module?
- Antonio Linares
- Site Admin
- Posts: 42256
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Startup function
Dear Enrico,
See this in source/vm/hvm.c
See this in source/vm/hvm.c
/* if first char is '@' then start procedure were set by
* programmer explicitly and should have the highest priority
* in other case it's the name of first public function in
* first linked moudule which is used if there is no
* HARBOUR_START_PROCEDURE in code
- Enrico Maria Giordano
- Posts: 8728
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Startup function
Dear Antonio,
Can you explain, please? I don't understand how to set a specific startup function in xHarbour, if it is possible.
Can you explain, please? I don't understand how to set a specific startup function in xHarbour, if it is possible.
- Antonio Linares
- Site Admin
- Posts: 42256
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Startup function
Dear Enrico,
I am not sure about it, either. I am just showing you what I found. Look for HARBOUR_START_PROCEDURE
* source/pp/ppcore.c
+ Added predefined macro __HB_MAIN__. The macro is undefined or holds the
value of HARBOUR_START_PROCEDURE depending on the compiler.
Use this code to make your Harbour startup procedure platform/compiler
independent:
#ifndef __HB_MAIN__
#define __HB_MAIN__ AppMain /* Or whatever you wish to call it */
#endif
FUNCTION __HB_MAIN__()
2003-08-02 12:00 UTC+0200 Przemyslaw Czerpak <druzus@polbox.com>
* xharbour/make_tgz.sh
* xharbour/xharbour.spec
* xharbour/source/vm/hvm.c
* small modification in support for automatic detection of first
function in linked modules for Linux
if first char of s_pszLinkedMain is '@' then start procedure were
set by programmer explicitly and should have the highest priority
in other case it's then name of first public function in first
linked moudule which is used if there is no HARBOUR_START_PROCEDURE
in code
I am not sure about it, either. I am just showing you what I found. Look for HARBOUR_START_PROCEDURE
* source/pp/ppcore.c
+ Added predefined macro __HB_MAIN__. The macro is undefined or holds the
value of HARBOUR_START_PROCEDURE depending on the compiler.
Use this code to make your Harbour startup procedure platform/compiler
independent:
#ifndef __HB_MAIN__
#define __HB_MAIN__ AppMain /* Or whatever you wish to call it */
#endif
FUNCTION __HB_MAIN__()
2003-08-02 12:00 UTC+0200 Przemyslaw Czerpak <druzus@polbox.com>
* xharbour/make_tgz.sh
* xharbour/xharbour.spec
* xharbour/source/vm/hvm.c
* small modification in support for automatic detection of first
function in linked modules for Linux
if first char of s_pszLinkedMain is '@' then start procedure were
set by programmer explicitly and should have the highest priority
in other case it's then name of first public function in first
linked moudule which is used if there is no HARBOUR_START_PROCEDURE
in code
- Enrico Maria Giordano
- Posts: 8728
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Startup function
It doesn't work or I don't know how to use it.
- Antonio Linares
- Site Admin
- Posts: 42256
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Startup function
Me neither as function @Name() is not supported by the compiler...
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Startup function
Sometimes I used @<funcname>() like this:
works exactly like
Code: Select all | Expand
p := ( @XBROWSE() )
? P
HB_ExecFromArray( p, { "STATES.DBF" } )
Code: Select all | Expand
p := ( @XBROWSE() )
Code: Select all | Expand
p := HB_FuncPtr( "XBROWSE" )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Enrico Maria Giordano
- Posts: 8728
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Startup function
Yes, it is the "address of" operator. But it has nothing to do with my request.
Re: Startup function
Good morning Enrico. I don't quite understand what you want, wouldn't it be this:
https://www.hamor.ro/distr_ext/Doc/xHb/ ... re.en.html
??
Regards, saludos.
https://www.hamor.ro/distr_ext/Doc/xHb/ ... re.en.html
??
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Enrico Maria Giordano
- Posts: 8728
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Startup function
No. Look: Harbour uses MAIN() as the startup function even if it is not in the main PRG. xHarbour uses MAIN() only if it is in the main PRG. If it is not, xHarbour calls the first function defined in the main PRG. How to force xHarbour to call MAIN() even if it is not in the main PRG?
Re: Startup function
I'm sorry. I've never seen anything like this. Why do you need this? What is the purpose?
Regards, saludos.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Enrico Maria Giordano
- Posts: 8728
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Startup function
I just want that MAIN() is always executed at startup even if it is not in the main PRG, just like Harbour already does.
Re: Startup function
Enrico, I learned it like this:
How to create an EXEcutable:
It is mandatory to have a FUNCTION MAIN() within your system, you already know this, but in xHarbour, even if you are compiling a single PRG, you will need to start with FUNCTION MAIN() too!
Enrico, lo aprendí así:
Cómo crear un ejecutable:
Es obligatorio tener una FUNCTION MAIN() dentro de su sistema, ya lo sabe, pero en xHarbour, incluso si está compilando un solo PRG, ¡también necesitará comenzar con FUNCTION MAIN()!
I've never seen any other way.
Regards, saludos.
How to create an EXEcutable:
It is mandatory to have a FUNCTION MAIN() within your system, you already know this, but in xHarbour, even if you are compiling a single PRG, you will need to start with FUNCTION MAIN() too!
Enrico, lo aprendí así:
Cómo crear un ejecutable:
Es obligatorio tener una FUNCTION MAIN() dentro de su sistema, ya lo sabe, pero en xHarbour, incluso si está compilando un solo PRG, ¡también necesitará comenzar con FUNCTION MAIN()!
I've never seen any other way.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Enrico Maria Giordano
- Posts: 8728
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Startup function
No, it is not mandatory to have a FUNCTION MAIN()! If you do not define it, the first function defined in the first linked PRG is executed at startup. But if you define it then the Harbour and xHarbour behaviour is different: Harbour executes it even if it is not in the first linked PRG while xHarbour execute it only if it is defined in the first linked PRG, otherwise it executes the first function defined in the first linked PRG, ignoring the MAIN() defined in another PRG. I don't know how to explain it better, sorry.
Re: Startup function
If I understand you correctly... Is that +-?
Regards, saludos.
Code: Select all | Expand
// C:\FWH\SAMPLES FUNCMAIN.PRG
#include "FiveWin.ch"
STATIC oWnd
FUNCTION Principal() // INIT PROCEDURE Principal // Main
? "I am the Principal() function"
Main()
RETURN NIL
FUNCTION Main()
? "I am the Main() function"
RETURN NIL
// FIN / END
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341