Functions

Best practice is to put all code into functions:

function MyCustomFunction(/**string*/ param1, /**number*/ param2, /**boolean*/ param3)
{
    // place your code here
}

If you are going to use this function in RVL -  specify parameter types as shown above.

Global Variables

If you plan to declare a global variable accessible from any place in a test - do it outside any function. To distinguish a global variable from variables with limited scope we recommend to prefix its name with g_

g_myGlobalVariable = 10

Restrictions

User.js content is loaded both on recording and playback. Since global objects (e,g, Global, Tester, File, etc...) are not available upon recording it is not recommended to use them outside functions.

g_recording

If you need to exclude some code from execution upon recording put it inside the following block:

if (!g_recording)
{
    // code that should be executed during playback only
}