|
FreeMat
|
Section: Input/Ouput Functions
Displays the contents of a file or a function to the screen or console. The syntax for its use is
type filename
type('filename')
or
type function
type('function')
in which case the function named 'function.m' will be displayed.
Here we use type to display the contents of itself
--> type('type')
% DOCBLOCK io_type
function type(filename)
fp = fopen(filename,'r');
if (fp == -1)
f = which(filename);
if (isempty(f)), return; end
filename = f;
fp = fopen(filename,'r');
end
if (fp == -1), return; end
while (~feof(fp))
printf('%s',fgetline(fp));
end
fclose(fp);