Startup function

Re: Startup function

Postby Enrico Maria Giordano » Wed Oct 30, 2024 5:53 pm

No, it is this:

First PRG:

Code: Select all  Expand view  RUN
#include "Fivewin.ch"


FUNCTION TEST()

    ? "TEST()"

    RETURN NIL


Second PRG:

Code: Select all  Expand view  RUN
#include "Fivewin.ch"


FUNCTION MAIN()

    ? "MAIN()"

    TEST()

    RETURN NIL


Results:

Harbour: MAIN() TEST()
xHarbour: TEST()

Is it clear now?
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Startup function

Postby nnicanor » Wed Oct 30, 2024 5:58 pm

Hi

Use INIT PROCEDURE your_function() to execute before main

best
Nicanor Martinez M.
Auditoria y Sistemas Ltda.
MicroExpress Ltda.
FW + FWH + XHARBOUR + HARBOUR + PELLES C + XDEVSTUDIO + XEDIT + BCC + VC_X86 + VCC_X64 + MINGW + R&R Reports + FastReport + Tdolphin + ADO + MYSQL + MARIADB + ORACLE
nnicanor@yahoo.com
nnicanor
 
Posts: 302
Joined: Fri Apr 23, 2010 4:30 am
Location: Colombia

Re: Startup function

Postby Enrico Maria Giordano » Wed Oct 30, 2024 6:00 pm

A sample, please. I just want to execute MAIN() in my sample even with xHarbour.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Startup function

Postby karinha » Wed Oct 30, 2024 6:33 pm

Enrico, I would do it this way, of course there are other easier ways. But it's beyond my limited knowledge at the moment. hahahaha.

Enrico, yo lo haría así, claro que hay otras formas más sencillas. Pero por el momento está más allá de mis conocimientos limitados. jajajaja.

Code: Select all  Expand view  RUN

// C:\FWH\SAMPLES\FUNCMAIN.PRG

#include "Fivewin.ch"

#ifdef __XHARBOUR__

   INIT PROCEDURE Principal

      MYRUN( Main() )

      CLEAR MEMORY

      __QUIT()

   RETURN

#endif

FUNCTION TEST()

    ? "TEST() 2"

RETURN NIL

// #include "Fivewin.ch"

FUNCTION MAIN()

    ? "MAIN() 1"

    TEST()

RETURN NIL

Function MYRUN( cComando )

   ***************************
   Local oShell, RET, lOk:=.T.

   TRY
      #IFDEF __XHARBOUR__
         oShell := CreateObject( "WScript.Shell" )
      #ELSE
         oShell := Win_OleCreateObject( "WScript.Shell" )
      #ENDIF

   CATCH

      TRY
         #IFDEF __XHARBOUR__
            oShell := CreateObject( "WScript.Shell" )
         #ELSE
            oShell := Win_OleCreateObject( "WScript.Shell" )
         #ENDIF

      CATCH

         lOk:=.F.

        END
   END

   IF lOk

      TRY

          //.F. = Nao espera a aplicacao fechar, .T. espera.
          oShell:Run( "%comspec% /c " + cComando, 0, .T. )

      CATCH

          lOk:=.F.

      END

      oShell := NIL

   ENDIF

   //--   RET := oShell:Run( "%comspec% /c " + cComando, 0)  //, .T. )

RETURN lOk

// FIN / END
 


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

Re: Startup function

Postby Enrico Maria Giordano » Wed Oct 30, 2024 6:49 pm

Sorry, but you can't replicate the problem using only one PRG.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Startup function

Postby karinha » Wed Oct 30, 2024 8:12 pm

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

Re: Startup function

Postby karinha » Wed Oct 30, 2024 8:15 pm

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

Re: Startup function

Postby karinha » Wed Oct 30, 2024 8:17 pm

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

Re: Startup function

Postby karinha » Wed Oct 30, 2024 8:24 pm

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

Re: Startup function

Postby Enrico Maria Giordano » Wed Oct 30, 2024 8:31 pm

Please use my simple test.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Startup function

Postby karinha » Wed Oct 30, 2024 8:35 pm

Enrico, I used it, I only created two FUNCTIONS: ENRICO.PRG and ENRICO2.PRG, download it and see.

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

Re: Startup function

Postby karinha » Wed Oct 30, 2024 8:39 pm

Enrico, without this it won't work. Then, you need to talk to the team that takes care of HARBOUR, see how to change XHARBOUR to work like HARBOUR.

Enrico, sin esto no funcionará. Luego, debes hablar con el equipo que se encarga de HARBOUR y ver cómo cambiar XHARBOUR para que funcione como HARBOUR.


Code: Select all  Expand view  RUN

#ifdef __XHARBOUR__

   // main / Principal tanto faz.. Main/Principal.
   INIT PROCEDURE Principal

      MYRUN( Main() )

      CLEAR MEMORY

      ? [Enrico, que pasa? ]

      __QUIT()

   RETURN

#endif
 


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


Re: Startup function

Postby Lailton » Thu Oct 31, 2024 11:48 pm

I think that it is to replace the main function with something else, not his case.
he want to use the main function but his build list the first one dont contains the main function and it is inside second or so on.

Is it Enrico?

Does it works on Harbour?

Antonio Linares wrote: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
Regards,
Lailton Fernando Mariano
User avatar
Lailton
 
Posts: 156
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil

Re: Startup function

Postby Enrico Maria Giordano » Fri Nov 01, 2024 9:23 am

Lailton wrote:I think that it is to replace the main function with something else, not his case.
he want to use the main function but his build list the first one dont contains the main function and it is inside second or so on.

Is it Enrico?


Yes, perfect.

Lailton wrote:Does it works on Harbour?


Yes, it does. Harbour seems to search the MAIN() function in all the linked PRGs.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 44 guests