Computer Science Canada

Ending a process

Author:  Mephi [ Wed Jun 18, 2003 9:37 pm ]
Post subject:  Ending a process

how do you stop a process? im sure this has been posted before, but theres 14 pages of threads and theres no way im gonna search em all:P theres just too many! plz help

Author:  Blade [ Wed Jun 18, 2003 9:40 pm ]
Post subject: 

Quote:
Syntax A quitStatement is:
quit [ guiltyParty ] [ : quitReason ]



Description The quit statement causes a program (or concurrent process) to fail. The failure (called an exception) either aborts the program (or process) or causes control to be passed to an exception handler.

Example In the inputLines procedure, halt the program if end of file is encountered before the string "stop" is read. Note that a return statement in the procedure would terminate the procedure but not the entire program.

var line : array 1 .. 50 of string

procedure inputLines
var i : int := 0
loop
if eof then
put "Missing 'stop' in input"
quit % Halt entire program
end if
i := i + 1
get line ( i )
exit when line ( i ) = "stop"
end loop
end inputLines

inputLines

quote from the turing help file

Author:  AsianSensation [ Wed Jun 18, 2003 9:46 pm ]
Post subject: 

quit quits the entire program

however, return will work for processes and procedures

Author:  Mephi [ Wed Jun 18, 2003 9:46 pm ]
Post subject: 

duznt quit close the program? or can u do like
quit process
or sumthin

Author:  Blade [ Wed Jun 18, 2003 9:48 pm ]
Post subject: 

Quote:
Description The quit statement causes a program (or concurrent process) to fail. The failure (called an exception) either aborts the program (or process) or causes control to be passed to an exception handler.


quote again from the turing help file... causes the program (or concurrent process) to fail.

Author:  Mephi [ Wed Jun 18, 2003 9:50 pm ]
Post subject: 

ok im confused heres my problem:
i have many music files, each is supposed to play at a specific time. it looks like this:
code:
process playMusic (music : string)
    loop
        Music.PlayFile (music)
    end loop
end playMusic


to change music i use

code:
Music.SoundOff
    fork playMusic ("World.MID")

however, when that music ends, it goes back to the old one. basically, it plays once then reverts bak to the old music. how do i stop this

Author:  AsianSensation [ Wed Jun 18, 2003 9:51 pm ]
Post subject: 

code:
process Blah
blah blah blah
return
end Blah


this will work, return works the same way for processes as well as for procedures.

Author:  Mephi [ Wed Jun 18, 2003 10:02 pm ]
Post subject: 

but its looped music....so it cant end when its done...cuz itsa loop....and i want it to play more than once....just to end when i want the music to change

Author:  AsianSensation [ Thu Jun 19, 2003 9:11 am ]
Post subject: 

have a flag
code:

var flagstop:=false

during the process:

code:
process Music
loop
if flagstop=true then
return
end if
Music.PlayFile("music.mp3")
end loop


so when you want to exit the process sometimes in your program, turn flagstop true, and then it should stop.

Author:  Blade [ Thu Jun 19, 2003 11:41 am ]
Post subject: 

why dont you use Music.PlayFileStop? it stops the currently playing file..
code:
process play1
    loop
        Music.PlayFile ("fileone")
    end loop
end play1

process play2
    loop
        Music.PlayFile ("filetwo")
    end loop
end play2

fork play1
%do yer stuff then when you get to the second sound
Music.PlayFileStop
fork play2

Author:  Mephi [ Thu Jun 19, 2003 6:16 pm ]
Post subject: 

does Music.PlayFileStop = Music.SoundOff? cuz i tried Music.SoundOff and it duznt work..still goes bak to the original music...

Author:  Andy [ Thu Jun 19, 2003 9:02 pm ]
Post subject: 

no u can't stop a music while its playing, i dun think

Author:  Mephi [ Thu Jun 19, 2003 9:25 pm ]
Post subject: 

Music.SoundOff stops music

Author:  AsianSensation [ Thu Jun 19, 2003 10:09 pm ]
Post subject: 

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


straight from the help thingie

anyways, i agree with blade, use Music.PlayFileStop. have the flag triggers the Music.PlayFilewStop command.

Author:  AsianSensation [ Thu Jun 19, 2003 10:12 pm ]
Post subject: 

actually, don't need to use return at all, i was being stupid...

code:
var flag := false

process BackMusic
    loop
        exit when flag = true
        Music.PlayFile ("music.mp3")
    end loop
end BackMusic

fork BackMusic

blah, blah, blah

flag := true
Music.PlayFileStop

Author:  Andy [ Fri Jun 20, 2003 9:39 am ]
Post subject: 

what's with the exit when flag= true? that's completely useless since that statement only get ran when the music finishes and replays itself

Author:  Mazer [ Fri Jun 20, 2003 10:06 am ]
Post subject: 

that's for when you music.playfilestop right before setting flag to true

Author:  AsianSensation [ Mon Jun 23, 2003 9:58 pm ]
Post subject: 

Music.PlayFile only stops all currently playing music, it doesnt prevent future playing of music. Having the exit when flag will ensure that the music doesn't start playing again.

Author:  Andy [ Tue Jun 24, 2003 10:35 am ]
Post subject: 

ooo ic, kk but that stops all the music from playing, is it possible to stop only one? without using Time.Elapse to check how long the other music have been playing then stop all the music then play the rest from where u left off?


: