Appendix 1 - Sample loader.oml Script

%==========================================================================
% OML Script used to load and register the DEMOLIBRARY library functions
%==========================================================================
try
function DEMOLIBRARY_loader()
	% path to this loader.oml
	library_path = [fileparts(omlfilename('fullpath'))];
	% loader.oml should delete library.ini if it exists.
	% Recreate library.ini if the library is OK to run in the environment.
	library_ini = [library_path,'/library.ini'];
	if exist(library_ini) == 2
		delete(library_ini)
	end
	
%===========================================================================
% Use librarymanager('scriptlist') function to create a list of 
% ALL oml scripts in the scripts directory to the list of functions

library_scriptspath1 = [library_path,'/scripts/oml/'];
library_scriptspath2 = [library_path,'/scripts/oml/SUBFOLDER'];
library_scriptspath3 = [library_path,'/scripts/oml/SUBFOLDER/SUBFOLDER2'];
library_scriptspath4 = [library_path,'/scripts/oml/HIDDENSUBFOLDER'];
		
library_functionlist1 = librarymanager('scriptlist', library_scriptspath1);
library_functionlist2 = librarymanager('scriptlist', library_scriptspath2);
library_functionlist3 = librarymanager('scriptlist', library_scriptspath3);
library_functionlist4 = librarymanager('scriptlist', library_scriptspath4);

%===========================================================================
% Call to the function to register the library's function list

registerpath(library_scriptspath1, library_functionlist1);    
registerpath(library_scriptspath2, library_functionlist2);    
registerpath(library_scriptspath3, library_functionlist3);    
addhiddenpath(library_scriptspath4);    
		
%===========================================================================
% Load the binary libraries and handle paths (if needed)

if ( ispc() )
	current_system_path = getenv('PATH');
	newlibrary_binary_directory = [library_path '\bin\win64;'];
	new_system_path = [current_system_path ';' newlibrary_binary_directory];
	setenv('PATH', new_system_path);
	addlibrary bcidemo 
elseif ( isunix() )
	%%% library_binary = [library_path '/bin/linux64/libbcidemo.so'];
	% The full path to the library binary file on Linux.
	% addlibrary(bcidemo)
end
		
%===========================================================================
% Naming and Versioning
% The name of the directory containing loader.oml will be the library name
		
library_name = librarymanager('libraryname', library_path);
library_name = 'DEMOLIBRARY';
library_version='0.1';  
library_shortdescription = 'DEMOLIBRARY Compose library';
library_longdescription = 'DEMOLIBRARY Compose library developed by Altair’; 
library_inicell = {
	library_path, 			% Full path to library - required
	library_name, 			% Library Directory Name - required
	library_version, 		% Library Version Number - required 
	library_shortdescription,	% Library Description - optional 
	library_longdescription	% Library Description - optional
	};
		
if(librarymanager('saveini', library_inicell))
	printf('Library %s Version %s loaded.\n', library_name, library_version)
else
	printf('Error loading library %s Version %s.\n', library_name, library_version)
end
end

DEMOLIBRARY_loader()
	
% Clear this function which should only be used to load this library.
clear DEMOLIBRARY_loader

catch
	printf('Error loading library %s Version %s\n', library_name, library_version)
	clear DEMOLIBRARY_loader
end