Commit 94ec4e11 authored by Jesse Heckman's avatar Jesse Heckman
Browse files

updated initialization

parent aa59842c
Pipeline #14575 failed with stages
in 45 seconds
No preview for this file type
No preview for this file type
%% PBToolbox %%
% these lines will add the PBToolbox functions to your userpath
% and initialize your matlab during startup.
pbpath = '/Users/jjheckman/Documents/Code/Gitlab/pbtoolbox';
addpath(genpath(pbpath));
pb_initialize;
\ No newline at end of file
......@@ -8,27 +8,38 @@ function pb_initializetoolbox()
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
if is_initialized(); return; end %check if not already initialized
supath = which('testup.m');
if isempty(supath)
supath = userpath;
fid = fopen(supath,'wt');
fprintf(fid,'');
cdp = cd;
startupf = 'startup.m';
fstartup = which(startupf);
clc; disp('Initializing ProgrammeerBeerToolbox...');
pbpath = strrep(which('pb_initializetoolbox.m'),'pb_initializetoolbox.m','');
text = fileread([pbpath 'documentation/templates/template_startup.txt']);
disp([newline ' - localising startup.m']);
if isempty(fstartup)
cd(userpath);
fid = fopen(startupf, 'wt+');
fprintf(fid,'%s\n', text);
fclose(fid);
end
PBT = [];
addline = "new_path = cd('[ROOT]');\naddpath(genpath(new_path));\n";
addline = replace(addline, '[ROOT]',PBT);
else
startuptext = fileread(fstartup);
if ~contains(startuptext,text)
fid = fopen(fstartup, 'at+');
fprintf(fid,'\n\n');
fprintf(fid,'%s\n', text);
fclose(fid);
end
end
disp(' - writing startup.m');
startup;
cd(cdp);
clc; disp(['ProgrammeerBeerToolbox was succesfully initialized...' newline])
end
function bool = is_initialized()
bool = true;
end
......
......@@ -8,10 +8,12 @@
\f0\fs24 \cf0 Steps to start working with the Programmeer Beer Toolbox:\
\
1) Store \'91PBToolbox\'92 in the directory of your choice.\
2) Open Matlab, navigate to directory, select add folder an subfolders to path.\
3) Type in command window: \'91pb_initializeToolbox\'92\
\
2) Open \'91pb_initializeToolbox\'92 in matlab and run.\
\
(c) Jesse J. Heckman, j.heckman@donders.ru.nl\
\
Jesse J. Heckman,\
Programmeerbeer @ pbtoolbox,\
j.heckman@donders.ru.nl\
\
}
\ No newline at end of file
No preview for this file type
function bool = pb_fexist(fn)
function bool = pb_fexist(fn,varargin)
% PB_FEXIST()
%
% PB_FEXIST() ...
......@@ -7,7 +7,9 @@ function bool = pb_fexist(fn)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
bool = exist(fn, 'file') == 2;
searchType = pb_keyval('type', varargin,'file');
bool = exist(fn,searchType) == 2;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......
......@@ -14,7 +14,7 @@ function pb_writefun(path,fname)
if exist(fpath,'file'); return; end % safety break
tpath = '/Users/jjheckman/Documents/Code/Gitlab/pbtoolbox/documentation/templates/';
tpath = [pb_userpath 'documentation/templates/'];
template = 'template_pbfun.txt';
tText = fileread([tpath template]);
......
......@@ -15,7 +15,7 @@ function pb_writescript(path,fname)
if exist(fpath,'file'); return; end % safety break
tpath = '/Users/jjheckman/Documents/Code/Matlab/PBToolbox/documentation/templates/';
tpath = [pb_userpath 'documentation/templates/'];
template = 'template_pbscript.txt';
tText = fileread([tpath template]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment