FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Startup function
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Startup function
Posted: Wed Oct 30, 2024 05:53 PM
No, it is this:

First PRG:
Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION TEST()

    ? "TEST()"

    RETURN NIL
Second PRG:
Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    ? "MAIN()"

    TEST()

    RETURN NIL
Results:

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

Is it clear now?
Posts: 302
Joined: Fri Apr 23, 2010 04:30 AM
Re: Startup function
Posted: Wed Oct 30, 2024 05: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Startup function
Posted: Wed Oct 30, 2024 06:00 PM

A sample, please. I just want to execute MAIN() in my sample even with xHarbour.

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Startup function
Posted: Wed Oct 30, 2024 06: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 (fw): Select all Collapse
// 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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Startup function
Posted: Wed Oct 30, 2024 06:49 PM

Sorry, but you can't replicate the problem using only one PRG.

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Startup function
Posted: Wed Oct 30, 2024 08:12 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Startup function
Posted: Wed Oct 30, 2024 08:15 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Startup function
Posted: Wed Oct 30, 2024 08:17 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Startup function
Posted: Wed Oct 30, 2024 08:24 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Startup function
Posted: Wed Oct 30, 2024 08:31 PM

Please use my simple test.

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Startup function
Posted: Wed Oct 30, 2024 08: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
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Startup function
Posted: Wed Oct 30, 2024 08: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 (fw): Select all Collapse
#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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 231
Joined: Fri Jul 20, 2012 01:49 AM
Re: Startup function
Posted: 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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Startup function
Posted: Fri Nov 01, 2024 09: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.

Continue the discussion