HP Forums

Full Version: How to use a forward function declaration in a program ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know this must be obvious can't figure it out. I have a subroutine called by a main program that I want to move to the end of the end of the main program as follows:

EXPORT Sub1;

EXPORT Main_prog
Begin

Sub1;

End;

Sub1
Begin

End;

I'm getting a syntax error just before the Begin after the Sub1. What am I doing wrong?
First export isn't necessary, but "()" is needed otherwise is a variable.

Code:
Sub1();

EXPORT Main_prog
Begin

Sub1;

End;

Sub1
Begin

End;
That doesn't work either. Now I get a syntax error after the ) on the first line.

Edit, it does work w/o the EXPORT, but gives the syntax error with the EXPORT.
I would try:
Code:
Sub1();

EXPORT Main_prog()
Begin

Sub1();

End;

Sub1()
Begin

End;
Or
Code:
EXPORT Sub1();

EXPORT Main_prog()
Begin

Sub1;

End;

EXPORT Sub1()
Begin

End;
Or
Code:
Sub1()
Begin

End;

EXPORT Main_prog()
Begin

Sub1();

End;
by the way, be consistent with EXPORT
This works, thanks guys:

PHP Code:
Sub1();

EXPORT Main_prog
Begin

Sub1
;

End;

Sub1
Begin

End

Reference URL's