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

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]);
......
function pb_genaxes(varargin)
% PB_GENAXES(VARARGIN)
function pb_clean(varargin)
% PB_CLEAN(varargin)
%
% Creates a template plot for .
%
% PB_GENAXES(VARARGIN) ...
% PB_CLEAN(varargin) cleans up your matlab. Closes all open figures,
% empties the command window, and clears all vars in base workspace.
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
fig = pb_keyval('fig',varargin,true);
empty = pb_keyval('clc',varargin,true);
clr = pb_keyval('clr',varargin,true);
if fig; close all; end
if empty; clc; end
if clr; evalin('base','clear'); end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......
function pb_delete(varargin)
% PB_DELETE()
% PB_DELETE(varargin)
%
% PB_DELETE() ...
% PB_DELETE(varargin) deletes the last handle from a graphic object.
%
% See also ...
% See also PB_FOBJ
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
......@@ -16,7 +16,7 @@ function pb_delete(varargin)
len = length(h);
for iH = 1:len
if contains(h(iH).Type,'axes') || contains(h(iH).Type,'Figure')
if contains(h(iH).Type,'Axes') || contains(h(iH).Type,'Figure')
cnt = cnt+1;
end
end
......
......@@ -14,9 +14,8 @@ function pb_edit(varargin)
%% Initialization
pbt_D = '/Users/jjheckman/Documents/Code/Gitlab/pbtoolbox/'; %
default_D = '/tmp/defaultbin/';
cd(pbt_D);
default_D = '/tmp/defaultbin/';
cd(pb_userpath);
%% Body
......@@ -28,7 +27,7 @@ function pb_edit(varargin)
fname = varargin{1};
path = which(fname);
if isempty(path)
path = [pbt_D default_D];
path = [pb_userpath default_D];
else
edit(path);
return
......@@ -38,7 +37,7 @@ function pb_edit(varargin)
if varargin{2}(end) ~= filesep
varargin{2} = [varargin{2} filesep];
end
path = [pbt_D varargin{2}];
path = [pb_userpath varargin{2}];
case 3
error('Error: Too much input arguments.');
end
......
......@@ -10,7 +10,7 @@ function pb_script(varargin)
%% Initialization
pbt_D = '/Users/jjheckman/Documents/Code/Matlab/PBToolbox/analyses/scripting/';
pbt_D = [pb_userpath 'analyses/scripting/'];
cd(pbt_D);
switch nargin
......
function pb_initialize()
% PB_INITIALIZE()
%
% PB_INITIALIZE() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
global PBT_ROOT
PBT_ROOT = pb_userpath;
INIT_ARCH = computer('arch');
INIT_DIR = strcat(PBT_ROOT,'/utilities/system/initialize/init');
INIT_ARCH_DIR = strcat(PBT_ROOT,'/utilities/system/initialize/init/',INIT_ARCH);
INIT_CWD = cd;
% Run generic commands
cd(INIT_DIR);
INIT_FILES = dir('*.m');
for n = 1:size(INIT_FILES);
[~,INIT_CMD,~] = fileparts(INIT_FILES(n).name);
eval(INIT_CMD);
end
% Run architecture specficic commands
cd(INIT_ARCH_DIR);
INIT_FILES = dir('*.m');
for n = 1:size(INIT_FILES);
[~,INIT_CMD,~]=fileparts(INIT_FILES(n).name);
eval(INIT_CMD);
end
cd(INIT_CWD);
clear n INIT_*;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function whitespace()
% WHITESPACE()
function path = pb_userpath
% PB_USERPATH()
%
% WHITESPACE() ...
% PB_USERPATH() returns the userpath for pbtoolbox.
%
% See also ...
% See also pb_initializetoolbox
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
path = strrep(which('pb_userpath.m'),'utilities/system/initialize/pb_userpath.m','');
end
......
Markdown is supported
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