Re: Declaring a Function Before it is used
- Posted by "Greg Haberek" <g.haberek at comcast.net> Oct 29, 2003
- 388 views
> wait a sec...i thought this language was supposed to be EASIER to use...then > why would you have to go through all of this for a simple "declare a > function before it's used"? it has to do with how the interpreter works on the internal level. from my understanding, it parses the routines one-by-one, and checks the code as it goes. if a routine is called before it is declared, it produces an error, since the interpreter does not know where, if at all, that routine is actually declared. this helps speed up error checking, since the whole program doesn't need to be parsed twice, once for routines and code, and again for errors. the use of routine_id() may be somewhat complicated, but it is probably the most ingenius method for working around undeclared routines. you'll find that routine_id() is used extensively with Win32Lib for setting event handlers for controls. once you get used to using routine_id() and understand how your program flows, it does become a lot easier. and sometimes using routine_id() may be avoided by re-thinking the flow of a program. ~Greg