CALL

The CALL function is used in a circuit code file to run test functions (see Function Scopes) in device files.

Syntax

The function takes three sets of parameters in brackets: the first specifies the device and the function to call, the second the input arguments and the third the output arguments. The second and third arguments are identical to how a function is normally called when it is called directly. If there are no output arguments, then the third set of brackets may be omitted.

CALL( STRING deviceReference, STRING functionName )
  ( variableType inputParm, ... )
  ( variableType outputParm, ... );

Parameters

deviceReference

A device reference in the form 'board.device'. The board name is optional, but the device reference must uniquely identify the device; if there is any ambiguity, then the board name must be supplied.

functionName
The name of the function to call in the device file associated with deviceReference.

Errors

A compile-time error can occur in the following circumstances:

  • The deviceReference supplied is not a constant string.
  • The deviceReference supplied does not match any test device in the project.
  • The deviceReference supplied does not contain a board name and matches more than one device.
  • A function named functionName does not exist in the test device file for the specified device.

Example

GLOBAL Test()(INT result)
  INT debugLevel := 0;
  FILE dataFile;

  dataFile := FOPEN("test.dat", "r");
  IF (FERROR()) THEN
    PRINT("ERROR: Error opening file test.dat");
    EXIT;
  END;

  CALL("MainBoard.U1", "RunTests")(debugLevel, dataFile)(result);

  FCLOSE(dataFile);

  IF result != 0 THEN
    PRINT("Tests on U1 failed to execute correctly.");
    result := RESULT_FAIL;
  ELSE
    result := RESULT_PASS;
  END;
END;