Phantom Documentation

[Help Home] [Phantom Home]
include

Syntax:

include "sFile";

Where,

sFile - The name of the file containing Phantom script commands.

Description:
The include statement opens a file containing Phantom script commands. The file will be run just as if the commands were placed inline where the include statement is called. Any variables and function declarations in the script will be created as if it were placed directly in the code. This is useful for calling other scripts from within a script as well as loading common global variables and used defined functions.

Sample script to be included (saved as 'sample.fun')

Example Code

# Declare some variables
int i = 10;
string s = "Hello";

# Declare some user functions
function void hello(){
  disp(s);
}

function int add_to_i(int j){
  return i = i + j;
}



Sample script using include

Example Code

include "sample.fun";

# Show the global variables
who();

# Show the user functions
what("User Defined");

# Call user functions
hello();
int k = add_to_i(32);
disp(k);
disp(i);



The output from the above example is:

Output
Variable Type Value
------------------------------------------------------------
i int 10
s string Hello
Package 'User Defined'
Function Names Return Parameters
------------------------------------------------------------
add_to_i int int
hello void
Hello
42
42


See Also: User Defined Functions



Copyright 2000-2011 Phantom Automated Solutions