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

Username:   Password: 
 RegisterRegister   
 Exiting Fork
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
freakysnots




PostPosted: Mon May 19, 2008 6:24 pm   Post subject: Exiting Fork

Hi guys.

I made this game which requires several fork commands running. When the game finishes, the fork commands are still running causing massive lag, and the game cannot go back to the main screen.

I was wondering if there was a way to end the fork commands when the program is running like a "end fork" or something to that effect.

Thanks.
Sponsor
Sponsor
Sponsor
sponsor
freakysnots




PostPosted: Mon May 19, 2008 6:30 pm   Post subject: Re: Exiting Fork

Here is the game just in case anyone was wondering what I was talking about.


menu.t
 Description:
pong

Download
 Filename:  menu.t
 Filesize:  16.01 KB
 Downloaded:  80 Time(s)

Sean




PostPosted: Mon May 19, 2008 6:41 pm   Post subject: RE:Exiting Fork

Change the Processes to Procedures. The only need for Processes is for Music. And you don't even need it for that.
freakysnots




PostPosted: Mon May 19, 2008 6:51 pm   Post subject: RE:Exiting Fork

It gives an error "fork argument must be a process"
andrew.




PostPosted: Mon May 19, 2008 7:30 pm   Post subject: RE:Exiting Fork

Take out fork.

e.g.
Turing:
procedure DoThis
    blah blah blah
end DoThis

DoThis


instead of

Turing:
process DoThis
    blah blah blah
end DoThis

fork DoThis
freakysnots




PostPosted: Mon May 19, 2008 11:09 pm   Post subject: RE:Exiting Fork

That doesn't work since I want the process running at the same time as the main game.

It will freeze the gameplay and loop that specific code nonstop.
Insectoid




PostPosted: Tue May 20, 2008 7:49 am   Post subject: RE:Exiting Fork

You don't use individual loops, try one big loop.

code:

proc movesomething
     x += 1
     y += 1
end movesomething

proc movesomethingelse
    otherx -= 1
    othery -= 1
end movesomethingelse

loop
     movesomething
     movesomethingelse
     View.Update
end loop
isaiahk9




PostPosted: Tue May 20, 2008 4:10 pm   Post subject: RE:Exiting Fork

I don't think a fork can be exitted (85% sure).
Sponsor
Sponsor
Sponsor
sponsor
gitoxa




PostPosted: Tue May 20, 2008 8:56 pm   Post subject: RE:Exiting Fork

In proper coding conventions, a program (subprograms included [procedures, funtions, processes]) are supposed to end when they're reached the bottom of code.

Your process will stop running once it runs out of code to run.
isaiahk9




PostPosted: Wed May 21, 2008 5:48 am   Post subject: RE:Exiting Fork

I think freakysnots meant if there was just an exit fork command.

AS far as i know, there isn't (besides gitoxa's way which won't work for infinite loops, like music in the main menu). You could put the process in a procedure and exit the procedure.
gitoxa




PostPosted: Wed May 21, 2008 6:06 am   Post subject: RE:Exiting Fork

You know, there's this crazy command, I'm not sure if you've heard of it, but it exits loops.

There's also this other one, that (get this) stops music!
Clayton




PostPosted: Wed May 21, 2008 8:28 am   Post subject: RE:Exiting Fork

return
Sean




PostPosted: Wed May 21, 2008 10:49 am   Post subject: RE:Exiting Fork

And Clayton comes to the rescue. Processes end the same as procedures and loops. You have the two options, return or exit, however return.

When the condition is met in the process then use the return function there.
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  [ 13 Posts ]
Jump to:   


Style:  
Search: