Re: Newcomer with a problem
- Posted by Tom Eklvf <darkspace at HOTMAIL.COM> Jan 25, 1998
- 581 views
>Hello, everyone. I'm new to Euphoria, and have been having a problem >that I can't seem to find the answer to in the documentation. It's >probably there, I'm just horrible at finding things like that. > >I'm wondering about function and procedure declaration. Currently, >I've got a function and a procedure. They both call the other at one >point in their block, but because one appears before the other, the >interpreter says the second one is undefined (and therefore will not >continue running the program). > >I know that C++ has function prototypes. Does Euphoria have anything >similar that allows for function/procedure/type declarations? > >Here's a sample of the code for the function and procedure, although >I don't feel it will be relevant (and yes, I do realize it's probably >not done in the most efficient manner. I'm new, after all!): > >procedure check_menu_input(integer x) > if x < 1 or x > 2 then > menu() >-- The line above is the problem causing line. The interpreter says >-- menu() has not yet been declared. And the interpreter's right :) You see, you _HAVEN'T_ declared menu() yet. *SNIP* >function menu() <---- This is where you declare menu() *SNIP* >end function So, all you have to do is to declare menu() before check_menu_input() like so: function menu() codecodecode end function procedure check_menu_input() codecodecode end procedure I think you could also use routine_id() to get over the problem, but I don't know how to use it, so you'll have to consult library.doc for more help. -Tom ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com