HyperMath

Including Files

Including Files

Previous topic Next topic Expand/collapse all hidden text  

Including Files

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  
hmtoggle_plus1greyb,e = Include(filename)

Includes the specified file so that its contents are executed at that location. In case of errors occurred while executing the file, the error is printed, the file is exited and execution continues.

filename

A string of the filename.  If no path is specified, it searches in the added search paths (see table below on how to specify the paths).

b

A Boolean status indicating success (true) or failure (false) of the operation.

e

A string containing the error encountered while execution the specified file. This is set only when b is false.

 

Specifying Search Paths

 

Description

Example

Absolute Path

The entire path needs to be specified with folder names separated by a forward slash, (/) or (\\).

C:/hmath/demo/file.hml.

Relative Path

To look in all search paths, only the filename is needed. The first folder in the path list containing the file gets selected.

file.hml.

To look in the paths below the search paths, specify the subordinate path starting with a forward slash (/) or (\\).  The path is searched beneath all current search paths.  The first folder in the path list containing the file is selected.

To search in the demo folder beneath current search paths, use /demo/file.hml.

To look in the paths not beneath the search paths, use two dots followed by a slash, (../), to specify each step up from the current search paths.  The first folder in the path list containing the file gets selected.

To search in the test folder at the same level as the search paths, use ../test/file.hml.

To search in two folders levels above the search paths, use

../../file.hml.

b,e = Include("c:/file.hml"); // An example of using absolute path

 if (b == false) then print(e) end;

The file is executed only at the Base scope level (see Scoping Rules) regardless of where it is included.

Once a file is included, its contents are available in memory.  This allows other files to have access to those contents without having to include the file in them.