HP Forums
How to use a forward function declaration in a program ? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: How to use a forward function declaration in a program ? (/thread-197.html)



How to use a forward function declaration in a program ? - Michael de Estrada - 12-21-2013 09:19 PM

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?


RE: How to use a forward function declaration in a program ? - eried - 12-21-2013 09:54 PM

First export isn't necessary, but "()" is needed otherwise is a variable.

Code:
Sub1();

EXPORT Main_prog
Begin

Sub1;

End;

Sub1
Begin

End;



RE: How to use a forward function declaration in a program ? - Michael de Estrada - 12-21-2013 10:01 PM

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.


RE: How to use a forward function declaration in a program ? - patrice - 12-21-2013 10:05 PM

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


RE: How to use a forward function declaration in a program ? - Michael de Estrada - 12-21-2013 10:11 PM

This works, thanks guys:

PHP Code:
Sub1();

EXPORT Main_prog
Begin

Sub1
;

End;

Sub1
Begin

End