Page 1 of 1

Procedures before the calls?

Posted: Sun Jun 07, 2020 10:14 pm
by AMpos
I have a program with a procedure:

Code: Select all

PROCEDURE TEST()
 debug("Test")
ENDPROCEDURE

TEST()
This code works, but this one, does not:

Code: Select all

TEST()

PROCEDURE TEST()
 debug("Test")
ENDPROCEDURE
I used (on other languages) to place PROCEDURES at the end of the source, for easier readiblity, but this has no sense for me. Is this really how PB works, or it is just me missing something?

My real problem/program is that now I have a proyect with multiples sources (listed in this order in proyect window)

SIDE1.pb
MAIN.pb
SIDE2.pb

Main can call procedures in SIDE1, but not in SIDE2 (and SIDE1 can not call procedures in SIDE2). Also, I dont know how to change the "order of compilation". If I add another source to my proyect, it is added in the last position, making it useless for the rest of the sources...

Re: Procedures before the calls?

Posted: Sun Jun 07, 2020 10:43 pm
by Kiffi
Declare is your friend:
PB-Help wrote:Sometimes a procedure need to call another procedure which isn't declared before its definition. This is annoying because the compiler will complain 'Procedure <name> not found'. Declare can help in this particular case by declaring only the header of the procedure. Nevertheless, the Declare and real Procedure declaration must be identical (including the correct type and optional parameters, if any).

Code: Select all

Declare TEST()

TEST()

PROCEDURE TEST()
 debug("Test")
ENDPROCEDURE

Re: Procedures before the calls?

Posted: Sun Jun 07, 2020 10:56 pm
by AMpos
Thanks! Good to know.