Main Index : Reference :

include


Description

Inserts a file into the code.

Usage

include "filename"

Program Structure

include inserts the contents of the file filename into the current file at the position of the include statement. This can be useful to distribute long plug-ins in several files. One can also put function prototypes, forward declarations, in separate header files this way. When the main file is read in, all the other files are inserted automatically by include statements.

Remember: Only the main file should be named .cof. Otherwise CINEMA 4D tries to read in all the files separately on startup. The included files can be named anything but .coh or .col is customary.

Compiling a plug-in, i.e. making it into a .cob file, always results in one file regardless of how many files the code is distributed in.

Example

// In the file "myplugin.coh":
// (a function prototype header)

Calculate(x, y);


// In the file "math.col":
// (a custom math library)

coth(x) 
{
  return 1/tanh(x);
}


// In the file "myplugin.cof":
// (the main file)

include "math.col"
include "myplugin.coh"

main(doc)
{
  // Calculate can be used here, even though it's
  // below main in the file, since it's declared
  // as a prototype in the header file.
  
  var x = Calculate(3, 4);
  x = coth(x);
  
  println(x);
}

Calculate(x, y)
{
  return x + y;
}


// This is what the compiler sees:

coth(x) 
{
  return 1/tanh(x);
}

Calculate(x, y);

main(doc)
{
  var x = Calculate(3, 4);
  x = coth(x);
  
  println(x);
}

Calculate(x, y)
{
  return x + y;
}