09-07-2009 07:52 PM
I have on my machine a folder full of mathscript commands and functions. This folder is beginning to get quite large and I'd like to be able to clean it up a bit by grouping the files into sub-folders. For example, I'd like to create the following folders;
Of course, this would be fine if I was to set the path to every folder individually. What I want to do though, is to set my path manually to C:\MatrixXTools and then put a command in there called 'import'. The 'import' command would be responsible for searching the current path for a given folder and then adding it to the path when it finds it. So to import the StringTools, I would just call
All of my base scripts would go into C:/MatrixXTools and then if a script needed to use the StringTools, I could just call the import function.
The problem I have is that I can't find a command that will return me the path into a string vector. Is there some way of doing this? 'SHOW PATH' doesn't do what I want it to because it just shows the path and doesn't give me a way of programmatically viewing it.
Is there a better method of getting everything into sub-folders all together?
I realise that I could also do this using the startup script, however I have the tools in revision control (svn) so that other people can use them - I don't want to have to get everyone to change their startup script every time I make a new folder - I should be able to do this in the scripts.
Note: we are still on v62.2 and we are looking into upgrade options.
Solved! Go to Solution.
09-08-2009 01:05 PM
You can get the show path output into a string using === operator.
[showPathStr,] === show path;
You can break up the showPathStr on the new line characters
into a string vector using the split function.
The split function was added in MATRIXx 7.1.9. The split function internally
uses the index and stringex functions to create the split string vector.
showPathVector = split(""n",showPathStr);
If you try out the split function and look at the algorithm you will need to
download and eval MATRIXx 7.1.9 or higher.
Also, instead of changing startup.ms everytime you add a tools directory, why not
have startup.ms execute another script (i.e. execute file = toolsetup.ms) and you
would only update toolsetup.ms when adding a new tools directory.
09-08-2009 11:58 PM
Thanks for the quick and very helpful feedback. [showPathStr,] === show path; seems to be working just fine in v62.2, however split(""n",showPathStr); does not (as you said). I'm fairly certain that I can split up the string as I need to. I'll probably just write another getPathStringVector function that does all this for me.
I do actually currently use the startup.ms script to execute different startup environments for different projects that I'm working on. The problem with using that here is that when using set path, the path needs to be absolute. I need to be able to specify a relative path, because as we're using SVN, different people can check out the MatrixXTools directory anywhere they want on their machine. So I won't know (in a script) where that directory is until the path is actually set.