
-----------------------------------
be natural*
Sun Jun 01, 2003 7:34 pm

declaring a procedure in a procedure
-----------------------------------
Is it possible to declare a procedure in a procedure?
Not calling for it, but declaring... :roll:

-----------------------------------
Tony
Sun Jun 01, 2003 7:37 pm


-----------------------------------
why would you want to declear a procedure inside a procedure? Thats just doesnt make any sence...

each time that procedure is called, the same one inside it is decleared over and over again.

-----------------------------------
be natural*
Sun Jun 01, 2003 7:45 pm


-----------------------------------
because i have this problem...

there are 5 procedures and i will call them 1,2,3,4 and 5

inside the procedure 1, i'm calling 2 and 4
in the procedure 2, i'm calling 1 and 2
in the procedure 3, i'm calling 2
in the procedure 4, i'm calling 1 and 5
in the procedure 5, i'm calling 4

if i do this, this won't run because when i'm calling 2 in 1 then 2 has to be declared before 1 and when i also call 1 in 2 then it has to be before 2 which can't be done :( 

how can i solve this out :?:

-----------------------------------
PaddyLong
Sun Jun 01, 2003 7:47 pm


-----------------------------------
I would say you need to think of a different way... a driver procedure that will have the logic to call any of the procedures based on something that may happen within one of the procedures or whatever...

might I ask exactly what you're trying to do here?  like what kidn of program?

-----------------------------------
be natural*
Sun Jun 01, 2003 7:54 pm


-----------------------------------
i'm making a bubble shooting game and this is the part where i'm controling the arrow that shoots the bubble.

so the first procedure draws the arrow that is pointing right up, and if i press right arrow then it will call the procedure that rotates the arrow to the right, and if i press left arrow then it will call the procedure that rotates the arrow to the left........so on and so forth

@_@~

-----------------------------------
PaddyLong
Sun Jun 01, 2003 7:59 pm


-----------------------------------
yeah, definately have a seperate driver procedure that is getting all of your keyboard input and calling the rotate procedures...

something like


declare all your rotate procedures up here blah blah blah

procedure main
 var input : string (1)
 loop
  if hasch then
   getch (input)
   if input = rightarrow then
    do the rotate to the right procedure
   elsif input = leftarrow then
    do the rotate to the right procedure
   end if
  end if
 end loop
end main
main


-----------------------------------
be natural*
Sun Jun 01, 2003 8:08 pm


-----------------------------------
i don't really get it :cry: 
can u explain a bit more?
thx

-----------------------------------
Catalyst
Sun Jun 01, 2003 8:09 pm


-----------------------------------
forward lets you use procedures like that (all meshed together)
look it up in help for more info[/code]

-----------------------------------
wrectify
Wed Jun 04, 2003 1:02 pm


-----------------------------------
why can't you just use a process and fork?

-----------------------------------
krishon
Wed Jun 04, 2003 1:34 pm


-----------------------------------
ye, lol, that's a good question, process and fork shouldn't be too hard

-----------------------------------
Blade
Wed Jun 04, 2003 10:29 pm


-----------------------------------
processes i consiter bad programming, because it lags like a freak. so i would not reccomend using processes... but calling a procedure from inside another procedure will work but of course the procedure you are calling has to be written above the other... like this:
procedure one
lots of code in here
and more code with stuff
end one

procedure fifty_million
one
end fifty_million

-----------------------------------
Catalyst
Wed Jun 04, 2003 10:47 pm


-----------------------------------
processes are a lazy and dirty way to program (at least in turing's case)

here how you would do procs that are intertwined


forward proc One
forward proc Two
forward proc Three

body proc One
put "Hello"
end One

body proc Two
Three
end Two

body proc Three
One
One
end Three


