Award
Congratulations DJ Sures, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

How Can Two Commands Be Run At The Same Time?

Assistance Requested

Help bhouston with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

bhouston claims to have checked these sources:
 
#1

I am trying to get two commands to run at the same time ( without success ).
For example:

Code:


Left(1,2000)
ControlCommand("Auto Position", AutoPositionFrame, "Stretch Left", 10,1,1)


The program runs the first line, once that is completed then the next line runs. Is there a way to have them run simultaneously?

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

First, we'll change your question to "how to run two commands consecutively without delay". This is because a computer runs instructions one at a time. A program is a list of instructions. Each instruction is read and then run. That's how computers work. What you don't see is the small lag between commands/instructions, which gives the appearance of "things happening at the same time".

So let's now look at your code...

The first command is specified Left to run for 2,000 ms (which is two seconds). You're asking the command to run for two seconds. This means you can't expect the next command to execute until the first command has completed, which will take 2 seconds.

Perhaps what you can do is this...

Code:


left(1)
ControlCommand("Auto Position", AutoPositionFrame, "Stretch Left", 10,1,1)
Sleep(2000)
Stop()

#3

Thanks DJ.
That added some clarity, it's the order of the commands as well. This is giving me what I am looking for;

Code:


ControlCommand("Auto Position", AutoPositionFrame, "Stretch Left",10,1,1)
left()
Sleep(3000)
Stop()