Forward statement or function
I just start using statements/functions.
(f.e. to write a small function to calculate "atan2") From all info I found and all I tried the function has to be written above the function call in the code, to be found. Is it possible to forward functions and statements (so they are found even at the end of the code)? |
Define them in a separate file and include them at the top of your main file
|
Yes, that was my PlanB too.
A pity there's no "forward". Thanks E-Penguin, stay safe! |
Quote:
Code:
int foo(int arg1,double arg2); ... int bar(..) { foo(1,42.0); /* use foo */ } ... int foo(int arg1,double arg2) { /* implement foo */ } |
Quote:
For bigger projects, I tend to keep functions in a separate file as suggested and include it near the top of the main source file. Alternatively, if you want to keep the definitions in the main file, you can add labels to the code so it's easy to skip past the function declarations. For example: Code:
Function MyFunc.b{var.w} |
Sorry for the late answer but real life (and Revision) got in the way.
I was asking mainly because I was surprised because contrary to functions, "Gosub" finds subroutines no matter where they are. Guess that's one of the reasons why Gosub is more often used :laughing Anyway, just checked out INCLUDE and XINCLUDE. They work nicely, so that's a good possibility to include statements/functions. Thanks for the clarification! :) |
All times are GMT +2. The time now is 16:51. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.