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

Username:   Password: 
 RegisterRegister   
 stop a certain fork?
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
gamer




PostPosted: Fri May 28, 2004 3:42 pm   Post subject: stop a certain fork?

hi i just wanna ask if this is possible: lets say i got fork#1 and fork#2 going on at the sametime. let say both are music.playfileloop, is there anyway to stop fork #1 but hav #2 keep going? cuz i kno music.PlayFileStop stops everything
Sponsor
Sponsor
Sponsor
sponsor
guruguru




PostPosted: Fri May 28, 2004 3:46 pm   Post subject: (No subject)

First off... Music.PlayFileLoop is already a process-type, you don't need to put it in another process. But maybe for this you do...

Hmm... thats interesting. I don't find anything regarding stopping a process. If anybody knows, please let us now :p!
AsianSensation




PostPosted: Fri May 28, 2004 9:01 pm   Post subject: (No subject)

return
guruguru




PostPosted: Fri May 28, 2004 9:53 pm   Post subject: (No subject)

Return? I don't believe that works. That is used for exiting functions/procedures and loops. I just tested it and its a no go.

An idea (not great but meh). If a user decides to stop on song, you stop all the songs, and then you start the songs that havent been stopped again. Just and idea...
gamer




PostPosted: Fri May 28, 2004 9:53 pm   Post subject: (No subject)

lol dats no good either guru
Dan




PostPosted: Fri May 28, 2004 11:13 pm   Post subject: (No subject)

1st off, what are u using process for? The odds are there is a better way to do it with out them unless you are doing somting realy advaced or odd.

Basilky turnings mutlyterading sucks so i do not know if they even put in a way of stoping a process.

but what you could do is somting like:

process:
if flag then
my code
end if
end process

where flag is a boolean var that is set to true to start and then u just turn it to flase to stop it. Kind of a cheap way of doing it but not much you can do if there is no stop comand for a fork and return dose not work.

P.S. if you got a loop in the process u whould have to add exit when not flag in the loop
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
AsianSensation




PostPosted: Sat May 29, 2004 9:44 am   Post subject: (No subject)

trust me, return will automatically exit a process or procedure

straight from the turing manual:

Quote:
A return must not appear as a statement in (the outermost level of) a module, nor can it appear in a function.


so anything such as procedures and processes are fine, because they are not a function, or in the outermost level of a module.

code:
var num := 0
process Crap
    loop
        num += 1
        put num
        if num >= 100 then
            return
        end if
    end loop
end Crap

fork Crap
guruguru




PostPosted: Sat May 29, 2004 10:11 am   Post subject: (No subject)

Oh sorry my bad. I thought you meant to use use the fork outside of the process... like you fork it and then return... me so stupide Laughing . Asians way works well, except you may want a boolean instead of the counter. When the user types exit or something, than the boolean variables is put to true. The process has a little if statement that executes if the boolean is false.

code:
v
var stopProcess : boolean := false

process Crap
    loop
        % play the music
        if stopProcess then
            return
        end if
    end loop
end Crap

fork Crap

if %test for user to say he wants to exit% then
    stopProcess := true
end if


Just a slight mod of AsianS's ingenious code Smile .
gamer




PostPosted: Sat May 29, 2004 4:59 pm   Post subject: (No subject)

ok i think return would be good
btw would it be like:

code:
process play
Music.PlayFileLoop ("nameofsong.mp3")
if flag then
return
end if
end play


would it still work that way?? cuz it seems its just gonna stay at the Music.PlayFileLoop line forever without checking the flag
whereas in:
code:
process play
loop
if flag then
return
end if
Music.PlayFile ("nameofsong.mp3")
end loop

this would work for sure, but then again i cant use music.playfilestop (something like this command)
guruguru




PostPosted: Sat May 29, 2004 7:20 pm   Post subject: (No subject)

Dam, I tried many versions and for the life of me I can not get it working Sad .

I am lost now... I even tried Music.PlayFile and that dint work. Maybe someone else knows...
Dan




PostPosted: Sat May 29, 2004 8:21 pm   Post subject: (No subject)

That is b/c Music.PlayFile is a bolcking fuction witch means it will not contion on with the code till it is done playing the song.

If you uses Music.PlayFileLoop insted you will not need a process and could stop it at any time in the programe with Music.PlayFileStop.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
guruguru




PostPosted: Sat May 29, 2004 9:31 pm   Post subject: (No subject)

We gots that... but he want to play multiple songs at the same time, and then stop a single one.

From Turing documentation...
Quote:
The Music.PlayFileStop procedure is used to to stop all music files currently playing.


That is where the problem resides... Wink
gamer




PostPosted: Sat May 29, 2004 10:09 pm   Post subject: (No subject)

yup, guru gets my point
Dan




PostPosted: Sat May 29, 2004 11:38 pm   Post subject: (No subject)

guruguru wrote:
We gots that... but he want to play multiple songs at the same time, and then stop a single one.


I dont think that is posable in turing. When i tryed it whould stop playing the 1st song and then play the 2nd.

If you did get that working could u post the code i whould like to see it.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
guruguru




PostPosted: Sun May 30, 2004 12:07 am   Post subject: (No subject)

Ok its not possible then... even HackerDan couldnt get it! :p
A thought just occured, why do you want two songs going at the same time? Is it just curiosity, or do you want to use it in a program? If the latter, can u explain why!?!?
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 2  [ 22 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: