1. step_two() has not been declared ???

Hi  i'm writting a program but I'm getting a strange
err when I try to run the first stage. Euphoria keeps
telling me that a procedure has'nt been declared, but,
everything looks right??? I wrote the program below.

------------
include keyread.e

object a, b, c
atom x
x = 0



-- Step one (waiting for change)
procedure step_one()
while x = 0 do
a = get_keys()
 for t = 1 to 50000 do
 c = 1
 end for
b = get_keys()
x = compare(a, b)
end while
x = 0
step_two()
end procedure
-- Step one Done



procedure step_two()

print(1, "A =")
print(1, a)
print(1, "B =")
print(1, b)
step_one()
end procedure

step_one()

---- end of program---

new topic     » topic index » view message » categorize

2. Re: step_two() has not been declared ???

-----Original Message-----
From: timmy <tim781 at PACBELL.NET>
To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU>
Date: Saturday, January 15, 2000 10:33 PM
Subject: step_two() has not been declared ???


>Hi  i'm writting a program but I'm getting a strange
>err when I try to run the first stage. Euphoria keeps
>telling me that a procedure has'nt been declared, but,
>everything looks right??? I wrote the program below.
>
>------------
>include keyread.e
>
>object a, b, c
>atom x
>x = 0
>
>
>
>-- Step one (waiting for change)
>procedure step_one()
>while x = 0 do
>a = get_keys()
> for t = 1 to 50000 do
> c = 1
> end for
>b = get_keys()
>x = compare(a, b)
>end while
>x = 0
>step_two()
>end procedure
>-- Step one Done
>
>
>
>procedure step_two()
>
>print(1, "A =")
>print(1, a)
>print(1, "B =")
>print(1, b)
>step_one()
>end procedure
>
>step_one()
>
>---- end of program---

Hi Timmy,

    I'm not a great Euphoria programmer but I think if you swap your
procedures around it will work. At the moment you're asking your first
procedure to call another procedure that I don't think Euphoria has seen
yet.

Mark Brown

new topic     » goto parent     » topic index » view message » categorize

3. Re: step_two() has not been declared ???

----- Original Message -----
From: timmy <tim781 at PACBELL.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Saturday, January 15, 2000 1:07 PM
Subject: step_two() has not been declared ???


> Hi  i'm writting a program but I'm getting a strange
> err when I try to run the first stage. Euphoria keeps
> telling me that a procedure has'nt been declared, but,
> everything looks right??? I wrote the program below.
>
> ------------
> include keyread.e
>
> object a, b, c
> atom x
> x = 0
>
>
>
> -- Step one (waiting for change)
> procedure step_one()
> while x = 0 do
> a = get_keys()
>  for t = 1 to 50000 do
>  c = 1
>  end for
> b = get_keys()
> x = compare(a, b)
> end while
> x = 0
> step_two()
> end procedure
> -- Step one Done
>
>
>
> procedure step_two()
>
> print(1, "A =")
> print(1, a)
> print(1, "B =")
> print(1, b)
> step_one()
> end procedure
>
> step_one()
>
> ---- end of program---
>

Euphoria can't call a function or procedure when that procedure above it...
-- Wrong TEST --
test()
procedure test()
end procedure
-- End --

-- Right TEST --
procedure test()
end procedure
-- End --

If you want the effect you putted in that program, you have to make 2
different include file, calling eachother...

-- INCLUDE1.E --
include INCLUDE2.E
include keyread.e

procedure step_one()
 while x = 0 do
  a = get_keys()
  for t = 1 to 50000 do
    c = 1
   end for
   b = get_keys()
   x = compare(a, b)
  end while
  x = 0
 step_two()
end procedure
-- End INCLUDE1.E --

--

new topic     » goto parent     » topic index » view message » categorize

4. Re: step_two() has not been declared ???

-----Original Message-----
From: timmy <tim781 at PACBELL.NET>
To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU>
Date: Saturday, January 15, 2000 10:33 PM
Subject: step_two() has not been declared ???


>Hi  i'm writting a program but I'm getting a strange
>err when I try to run the first stage. Euphoria keeps
>telling me that a procedure has'nt been declared, but,
>everything looks right??? I wrote the program below.
>
>------------
>include keyread.e
>
>object a, b, c
>atom x
>x = 0
>
>
>
>-- Step one (waiting for change)
>procedure step_one()
>while x = 0 do
>a = get_keys()
> for t = 1 to 50000 do
> c = 1
> end for
>b = get_keys()
>x = compare(a, b)
>end while
>x = 0
>step_two()
>end procedure
>-- Step one Done
>
>
>
>procedure step_two()
>
>print(1, "A =")
>print(1, a)
>print(1, "B =")
>print(1, b)
>step_one()
>end procedure
>
>step_one()
>
>---- end of program---

Hi timmy (again),

    my suggestion to you wont work (that will teach me not to look at the
code before running to my keyboard!). You are calling one procedure from the
other and back again. I can't think how to solve that (if you do as i
suggested you'll get the same error, it will just be the other proc). Might
I suggest calling the procedures from a main loop instead :-

eg.......

x=0

while x=0 do
    step_one()
    step_two()

    -- some condition here so you can exit
    -- this loop

end while

or alternatively you could keep calling step_two from step_one (so long as
step two is declared ahead of step_one) but call step_one from the main
loop.

Hope this helps

Mark

new topic     » goto parent     » topic index » view message » categorize

5. Re: step_two() has not been declared ???

On Sat, 15 Jan 2000, timmy wrote:
> Hi  i'm writting a program but I'm getting a strange
> err when I try to run the first stage. Euphoria keeps
> telling me that a procedure has'nt been declared, but,
> everything looks right??? I wrote the program below.

You could probably do  what you want by using routine_id.
However, before you try it, consider this: I don't know about Euphoria, but
in most programming languages, code such as the following will create a new
instance of the routine on the stack each time routine one callls routine two,
and another each time routine two calls routine one,
eventually filling all available memory with procedure calls which leads to a
nasty crash.

In other words, its better to do this in some other way. As someone suggested,
a while 1 do ... end while loop would work.

Regards,
Irv

------------ > include keyread.e
>
> object a, b, c
> atom x
> x = 0
>
>
>
> -- Step one (waiting for change)
> procedure step_one()
> while x = 0 do
> a = get_keys()
>  for t = 1 to 50000 do
>  c = 1
>  end for
> b = get_keys()
> x = compare(a, b)
> end while
> x = 0
> step_two()
> end procedure
> -- Step one Done
>
>
>
> procedure step_two()
>
> print(1, "A =")
> print(1, a)
> print(1, "B =")
> print(1, b)
> step_one()
> end procedure
>
> step_one()
>
> ---- end of program---

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu