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

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




PostPosted: Thu Jan 15, 2004 12:02 pm   Post subject: fork statement

Can someone show me how to use the fork statement? a description a few examples would be greatly appreciated. thanks!
Sponsor
Sponsor
Sponsor
sponsor
DanShadow




PostPosted: Thu Jan 15, 2004 1:52 pm   Post subject: (No subject)

Im not sure too much how to use the "fork" statement, but it seems ill have to learn sooner than later. An example where I used it was:
code:

var counter:=30
process music
play(">6cvc<2ftalin")
end music

loop
locate(1,1)
put "Nothing here, just to put text..",counter
counter:=counter-1

fork music
end loop

That should give you an idea of how it works...but when I play longer "play" commands than that, it cuts it off like a second after it starts and goes back into the loop.
shorthair




PostPosted: Thu Jan 15, 2004 5:00 pm   Post subject: (No subject)

We all learn that process are not a good idea unless you need somthing running in the background , if you just need something to run from a commad then use a procedure or a proc , but please let me know what the process is being used for
Thuged_Out_G




PostPosted: Thu Jan 15, 2004 5:06 pm   Post subject: (No subject)

shorthair wrote:
procedure or a proc


that would be the same thing Laughing
and procedures cannot be forked, only processes...process suck because when you fork them they go in random order, but i think i might have a solution for it...i dunno..lets see

code:

var flag:boolean:=false

process text
if flag=false then
put "1"
flag:=true
end if
end text

process text1
if flag:=true then
put "2"
flag:=false
end if
end text1

loop
fork text1
fork text2
end loop


that should make it so the second process wont do anything unless the first one has gone, and the first one wont go again until the second one goes....so it should go like
1
2
1
2

without that, it may go
1
1
2
1
2
2
who kows...completely random lol
shorthair




PostPosted: Thu Jan 15, 2004 5:08 pm   Post subject: (No subject)

i stated that you cant fork the procedure and proc , and they are not the exact same thing at all , rad the help file in turing , what i told him was that he might not need to use a process , becuase they hog memory and cpu processing , and there not very useful for things other that music or animation.
AsianSensation




PostPosted: Thu Jan 15, 2004 7:33 pm   Post subject: (No subject)

shorthair is right. I constantly see alot of people forking commands, like forking the two paddles of a pong game. The fact is that process is very inaccurate, and most of the time, not in sync with the rest of your program. Especially when you are doing some precise calculation or not, it will almost guarentee to mess your program up.

Mazer is one of the only person that I know that has successfully used processes, it was in his EM game. But he did so with the help of his Draw-Check thingie.
DanShadow




PostPosted: Thu Jan 15, 2004 8:48 pm   Post subject: (No subject)

Hey Asian, how would I go about using a fork or proces...or whatever to make the "play" command play a set of sounds in the background of a program, without compromising user control and speed???? Please PM me the answer if you can, I might forget to ch eck here. Laughing
AsianSensation




PostPosted: Thu Jan 15, 2004 9:35 pm   Post subject: (No subject)

the problem is, you can't. You need the fork and process to play background music. But music doesn't need to be all that precise, and when I say precise, I mean it involves complicated manipulation or calculation of some sort. But as you can also tell, the reason that no one has made a success DDR game in turing is because the music is not exactly in sync with the rest of your program (or they are just too lazy to find a solution Razz )
Sponsor
Sponsor
Sponsor
sponsor
DanShadow




PostPosted: Thu Jan 15, 2004 10:03 pm   Post subject: (No subject)

Oh I see....well that kind of sucks, I was hoping I could add some BG music without it playing the music, waiting for a command, (if none was issued) then retrning to the music...oh well.
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  [ 9 Posts ]
Jump to:   


Style:  
Search: