3 if nargin < 1
robolog('A class name must be specified.', 'ERR'); end
4 if nargin < 2
robolog('A class version must be specified.', 'ERR'); end
6 roboRoot = varargin{1};
8 roboRoot = getpref(
'robochameleon',
'roboRootFolder',
'NULL');
9 if strcmp(roboRoot,
'NULL')
13 if ~isnumeric(version)
15 % If the command is called as '
createRoboUnit MyClassName 1' the version is passed as
string 16 version = str2double(version);
20 if ~isnumeric(version) || version<0 || version/round(version) ~= 1
21 robolog('The version must be an integer positive number', 'ERR');
23 isOk = regexp(className, '^[a-zA-Z0-9]+$' ,'start');
25 robolog('The class name can only contain the following characters [a-z] [A-Z] [0-9]', 'ERR');
27 fullClassName = sprintf('%s_v%d', className, version);
28 fullClassName(1) = upper(fullClassName(1));
30 dstFile = sprintf('./%s.m', fullClassName);
32 s = fileread(srcFile);
34 s = strrep(s, '%', '%%'); %Escape percentage symbol
35 s = strrep(s, '\', '\\'); %Escape escape symbol
36 fid = fopen(dstFile, 'w');
function robolog(in msg, in varargin)
This function allows the user to print log messages in a standard way.
A short description of the class.
function robochameleon(in varargin)
Add robochameleon related directories to the MATLAB path.
function createRoboUnit(in className, in version, in varargin)
Creates a new unit with the given name and version.