
-----------------------------------
ne7work
Wed Dec 12, 2007 3:45 pm

Running two loops at the same time.
-----------------------------------
Is there any way possible to run two loops at the same time in two different windows? For example, running a loop saying "cheese" all the time in one window and another running a loop saying "pie" in another window?

Thanks.

-----------------------------------
Tony
Wed Dec 12, 2007 3:59 pm

RE:Running two loops at the same time.
-----------------------------------
one loop is most certainly enough for this example

loop
   say cheese in window 1
   say pie in window 2
end loop


-----------------------------------
ne7work
Wed Dec 12, 2007 9:39 pm

RE:Running two loops at the same time.
-----------------------------------
Even though you are trying to help me, I don't see how you even helped me one bit. Instead of saying put you put say, and you didn't even give me the module for "window"

Here is what I tried. (using your logic)

var winID : int
winID := Window.Open ("position:top;center,graphics:200;200")
var winID2 : int
winID2 := Window.Open ("position:top;center,graphics:200;200")
var test :int

loop
put "pie" in winID
get test
put "cheese" in winID2
end loop

What I am trying to achieve is that it continually says cheese in one window, while it continually says pie and asks for a interger in the other. WITHOUT it stopping (not stopping if nothing is inputed at the get)

I then get errors. Well, can anyone else help me please?

-----------------------------------
poirier4
Wed Dec 12, 2007 9:50 pm

Re: Running two loops at the same time.
-----------------------------------
I dont have any experience using different windows, but what i would suggest trying is using process and fork commands. i suggest this because one can have multiple processes operating simultaneously.

here is a very simple example


process pie
var y:int
y:=1
loop
put "pie"
delay (500)
y:=y+1
exit when y=50
end loop
end pie
process pie2
var x:int
x:=1
loop
put "mmm..."
delay(500)
x:=x+1
exit when x=50
end loop
end pie2
fork pie2
fork pie

point being that you can run multiple loop at the same time using processes. this might help with the whole get while using a put issue

what you want for your pie is similar to this
var pie : string
process pie2
    pie = "no"
    loop
        put "haha"
        exit when pie = "Hi"
        delay (500)
    end loop
end pie2
process pie3
    loop
        get pie
        exit when pie = "Hi"
        end loop
    end pie3
    fork pie2
    fork pie3
it will keep posting pie until the string Hi is entered

-----------------------------------
Clayton
Wed Dec 12, 2007 10:34 pm

RE:Running two loops at the same time.
-----------------------------------
What Tony posted was pseudo-code. Not actual code. No it doesn't compile, but it doesn't just give you the answer either. Use what you know to apply it to what Tony supplied.

-----------------------------------
Tony
Thu Dec 13, 2007 1:22 am

Re: RE:Running two loops at the same time.
-----------------------------------
I dont have any experience using different windows, but what i would suggest trying is using process and fork commands.
processes would not work with multiple windows. You will end up with cheese and pie in both windows. The examples requires focus of the active window and the matching put statement, but multiple processes cannot guarantee that another loop will not change the focus before the put statement.


Here is what I tried. (using your logic)

The logic is right, but your code is way off :lol: You should probably read the documentation on using multiple windows first, before trying to do weird things.

While at it, you're looking for hasch / getch, or better yet - Input.KeyDown, instead of get (the latter stops the program until it reads in the input).

I would also suggest keeping this all in a single window. Unless you absolutely must be able to move windows around, change their sizes, or whatever else windows do... it sounds like a single window app is quite sufficient for the cause. You can position text on the screen with locate or by using Font.Draw

-----------------------------------
poirier4
Thu Dec 13, 2007 7:26 am

Re: Running two loops at the same time.
-----------------------------------
i like the way you think. instead of looking for a specific string go more basic and look for the key to be pressed.

-----------------------------------
Nick
Thu Dec 13, 2007 7:28 am

Re: Running two loops at the same time.
-----------------------------------
i like the way you think.

everyone likes the way Tony thinks :P

-----------------------------------
Tony
Thu Dec 13, 2007 2:57 pm

RE:Running two loops at the same time.
-----------------------------------
hey, strings are made up of basic keys ;)
