Page 2 of 2

Re: Startup function

Posted: Wed Oct 30, 2024 5:53 pm
by Enrico Maria Giordano
No, it is this:

First PRG:

Code: Select all | Expand

#include "Fivewin.ch"


FUNCTION TEST()

    ? "TEST()"

    RETURN NIL
Second PRG:

Code: Select all | Expand

#include "Fivewin.ch"


FUNCTION MAIN()

    ? "MAIN()"

    TEST()

    RETURN NIL
Results:

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

Is it clear now?

Re: Startup function

Posted: Wed Oct 30, 2024 5:58 pm
by nnicanor
Hi

Use INIT PROCEDURE your_function() to execute before main

best

Re: Startup function

Posted: Wed Oct 30, 2024 6:00 pm
by Enrico Maria Giordano
A sample, please. I just want to execute MAIN() in my sample even with xHarbour.

Re: Startup function

Posted: Wed Oct 30, 2024 6:33 pm
by karinha
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

// 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.

Re: Startup function

Posted: Wed Oct 30, 2024 6:49 pm
by Enrico Maria Giordano
Sorry, but you can't replicate the problem using only one PRG.

Re: Startup function

Posted: Wed Oct 30, 2024 8:12 pm
by karinha
Image

Re: Startup function

Posted: Wed Oct 30, 2024 8:15 pm
by karinha
Image

Re: Startup function

Posted: Wed Oct 30, 2024 8:17 pm
by karinha
Image

Re: Startup function

Posted: Wed Oct 30, 2024 8:24 pm
by karinha
Download completo aqui:

https://mega.nz/file/MIdwSQAK#aRhteCww5 ... 5HmcXty-vM

Regards, saludos.

Re: Startup function

Posted: Wed Oct 30, 2024 8:31 pm
by Enrico Maria Giordano
Please use my simple test.

Re: Startup function

Posted: Wed Oct 30, 2024 8:35 pm
by karinha
Enrico, I used it, I only created two FUNCTIONS: ENRICO.PRG and ENRICO2.PRG, download it and see.

Regards, saludos.

Re: Startup function

Posted: Wed Oct 30, 2024 8:39 pm
by karinha
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

#ifdef __XHARBOUR__

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

      MYRUN( Main() )

      CLEAR MEMORY

      ? [Enrico, que pasa? ]

      __QUIT()

   RETURN

#endif
 
Regards, saludos.

Re: Startup function

Posted: Wed Oct 30, 2024 10:09 pm
by Enrico Maria Giordano
Yes, I know.

Re: Startup function

Posted: Thu Oct 31, 2024 11:48 pm
by Lailton
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

Re: Startup function

Posted: Fri Nov 01, 2024 9:23 am
by Enrico Maria Giordano
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.