Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 declaring a procedure in a procedure
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
be natural*




PostPosted: Sun Jun 01, 2003 7:34 pm   Post subject: declaring a procedure in a procedure

Is it possible to declare a procedure in a procedure?
Not calling for it, but declaring... Rolling Eyes
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Jun 01, 2003 7:37 pm   Post subject: (No subject)

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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
be natural*




PostPosted: Sun Jun 01, 2003 7:45 pm   Post subject: (No subject)

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 Sad

how can i solve this out Question
PaddyLong




PostPosted: Sun Jun 01, 2003 7:47 pm   Post subject: (No subject)

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*




PostPosted: Sun Jun 01, 2003 7:54 pm   Post subject: (No subject)

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




PostPosted: Sun Jun 01, 2003 7:59 pm   Post subject: (No subject)

yeah, definately have a seperate driver procedure that is getting all of your keyboard input and calling the rotate procedures...

something like

code:

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*




PostPosted: Sun Jun 01, 2003 8:08 pm   Post subject: (No subject)

i don't really get it Crying or Very sad
can u explain a bit more?
thx
Catalyst




PostPosted: Sun Jun 01, 2003 8:09 pm   Post subject: (No subject)

forward lets you use procedures like that (all meshed together)
look it up in help for more info[/code]
Sponsor
Sponsor
Sponsor
sponsor
wrectify




PostPosted: Wed Jun 04, 2003 1:02 pm   Post subject: (No subject)

why can't you just use a process and fork?
krishon




PostPosted: Wed Jun 04, 2003 1:34 pm   Post subject: (No subject)

ye, lol, that's a good question, process and fork shouldn't be too hard
Blade




PostPosted: Wed Jun 04, 2003 10:29 pm   Post subject: (No subject)

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:
code:
procedure one
lots of code in here
and more code with stuff
end one

procedure fifty_million
one
end fifty_million
Catalyst




PostPosted: Wed Jun 04, 2003 10:47 pm   Post subject: (No subject)

processes are a lazy and dirty way to program (at least in turing's case)

here how you would do procs that are intertwined

code:

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

Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: