ANY-maze Help > The ANY-maze reference > The Protocol page > The elements of a protocol > Testing > Procedures > Running procedures

Running procedures

Introduction

Procedures will start to run when the test is 'ready'.

A test will not start if there are any procedures that contain errors. If you need to run a test anyway, and for some reason don't need a procedure to be working, you can disable it on the procedure's settings page.

Within a procedure, there are two sections: statements that are run before the test starts (where the background of the procedure editor is shaded) and statements that are run after the test starts (where the background is not shaded).

Statements that run before the test starts will be executed when the test becomes 'ready'. This is usually immediately after the previous test ended. All statements in the first section of the procedure will run, and then the procedure will wait for the test to start.

Note that this could cause unexpected effects, because tests can become 'ready' in multiple situations - for example, when the user makes an edit to the protocol and then switches back to the Tests page. If the statements that run before the test starts are set to choose a random arm of a radial maze and then dispense a pellet into that arm, for example, then if the test become ready multiple times, multiple pellets will get dispensed. One way round this would be to wait for the Test is waiting to start event before dispensing the pellet (although this event only happens if Automatic starting of tests is turned on).

  

As soon as the test starts (either using the button, or automatically, when the animal is put into the apparatus), the statements in the second section of the procedure will start to run.

The following procedure initialises some I/O before the test starts:

  

  

Figure 1. An example of a procedure that runs some statements before the test starts (to initialise a variable, and set up some I/O) and some statements after the test starts (waiting for the animal to press a lever)

Running multiple procedures

If you've defined multiple procedures in a protocol, they will all run simultaneously.

What this means in practice is that each procedure will be given a chance to run - up to the point where it ends, or needs to wait for an event - and then the next procedure will get the chance to do the same.

This means that the order of the procedures may be important, since the first procedures defined will get the chance to run before the others. This is especially true if the procedures contain any variables that are shared between procedures.

In future versions of ANY-maze, procedures will be able to be re-ordered by dragging and dropping them in the protocol list.

Technical stuff

You can ignore this section unless you want a deeper understanding of how procedures work.

As ANY-maze performs a test, it tracks the animal in real-time and also monitors the I/O ports set up in the protocol. Whenever anything changes (for example the animal's position, or the state of an I/O port), then internally to the software, a 'test event' will be generated. These 'test events' are loosely (but not exactly) what you'll see on the Test data report.

A test event might be due to a change of animal position, zone entry/exit, lever press, etc. and several of these occur every second.

As a procedure runs, it will take the current test event (the very first one will be a Test is waiting to start event) and pass it to the first statement of the first procedure. The procedure statement will be executed based on that event.

Usually, this will cause a series of statements to be run until the current statement is a Wait until statement. If the event that the statement is waiting for is not the test event that is being processed, then the procedure will temporarily stop running and the 'test event' will be passed to each other procedure, in turn, until they've all had a go. If any procedure's current statement is a Wait until statement, and it's waiting for this specific event to occur, then it will continue running statements until it reaches another Wait until statement (or the end of the procedure).

It therefore follows that a procedure that doesn't contain any Wait until statements, but contains a loop where it continually runs the same sequence of statements, won't give any other procedures the chance to run. (In fact, ANY-maze tries to detect such a situation, and tries to ensure that all procedures are given a chance, but this is an inefficient way to run a procedure). This is why you should usually have at least one Wait until statement in a procedure).

See also:

 Procedure statements 
 The Wait until statement  

© Copyright 2003-2026 Stoelting Co. All rights reserved

ANY-maze help topic T0467