Computer Science Canada

processes

Author:  shoobyman [ Tue Nov 21, 2006 6:38 pm ]
Post subject:  processes

I was just wondering if you can have something running in the background and waiting for a get statement simultaneously without using a process (cuz i tried and it messed it up really badly.)

btw, it is because i am trying to get matrix text to run in the background while the user is entering text

Author:  DKNiGHTX [ Tue Nov 21, 2006 7:56 pm ]
Post subject: 

Well, if you need help using a process, here is some example code which you can stick your matrix function in to apply it. I just used a very annoying prompt for this example. (It uses a process to demonstrate how to use them)

code:
View.Set ("graphics:max;max")

var Stop := false
var userName : string := ""

process myProcess ()

    const TEMP_FONT := Font.New ("Impact:20")
   
    loop
   
        Font.Draw ("Enter something kthx", Rand.Int (-100, maxx), Rand.Int (0, maxy div 3), TEMP_FONT, black)
        Time.DelaySinceLast(80)
        exit when (Stop)
       
    end loop
   
    Font.Free (TEMP_FONT)
    Draw.FillBox (0, maxy div 2, maxx, 0, white)
   
end myProcess

put "Please enter your username.  " ..

fork myProcess () %This starts our process

get userName : *

Stop := true

put "Thankyou!"

Author:  ericfourfour [ Tue Nov 21, 2006 8:27 pm ]
Post subject: 

Let's not get hasty here. Processes should not be used for a task like this. Look up Input.hasch and Input.getchar. That way you can simply check if there is input in the buffer and if there is you can get it. If there is not you do not have to get it. If you are curious hasch stands for "has character" and getchar stands for "get character".


: