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

Username:   Password: 
 RegisterRegister   
 is there a way to exit a fork.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
the_avenger




PostPosted: Mon Jan 30, 2006 6:45 pm   Post subject: is there a way to exit a fork.

is there a way to exit a fork?
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Mon Jan 30, 2006 7:32 pm   Post subject: (No subject)

Several possibilities:
- Don't use processes. They're not well handled in Turing and require a great deal of skill to pull off.
- If you must, I'm guessing that the one in question has a loop in it. You could create an exit condition that would be satisfied by a global variable, that could be changed by another proc.
- Look into wait, signal, and possibly monitor. AFAIK, there are no tuts available for these, since they are so rarely used (as we try to discourage the use of processes as much as possible, for the above mentioned reasons).
Martin




PostPosted: Mon Jan 30, 2006 7:33 pm   Post subject: (No subject)

It'll exit whenever the process is finished running.

code:

var killProcess : boolean := false

process myProcess
   loop
      exit when killProcess
      put "process!"
   end loop
end process

fork myProcess
delay (2000)
killProcess := true


But yeah, using processes is a bad idea - they will result in you having bad and slow code that is difficult to debug.
redrenagade




PostPosted: Thu Feb 02, 2006 4:54 pm   Post subject: (No subject)

You would always try to declare a string type variable.
Then in the loop within the process, type "exit when string_variable := " stop". Then, when u want the process to stop, simply have a line of code that looks like this:
string_variable := "stop"
This should stop the process effectively, atleast it did for my program anyway.
Cervantes




PostPosted: Thu Feb 02, 2006 6:04 pm   Post subject: (No subject)

redrenagade wrote:
Then in the loop within the process, type "exit when string_variable := " stop".

Except, Turing uses "=" for comparison, and ":=" for assignment.

The bottom line is, "Most should avoid processes".
jrblast




PostPosted: Wed Feb 08, 2006 2:53 pm   Post subject: (No subject)

Cervantes wrote:
redrenagade wrote:
Then in the loop within the process, type "exit when string_variable := " stop".

Except, Turing uses "=" for comparison, and ":=" for assignment.

The bottom line is, "Most should avoid processes".


From my experience, and the above linked tutorial, NEVER use turing processes for anything other than music or other sounds.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: