Iterate parts of string (path) / String Split

Hi, I want to make a tag in SVN, hence create none or several directories using the SVN MkDir action.

The starting point is a string with the destination path in SVN:
"svn://c++/tags/project/version/project"

So logically I need to create the following directories (I know "c++/tags" exists):
1. "svn://c++/tags/project"
2. "svn://c++/tags/project/version"
3. "svn://c++/tags/project/version/project"

The challenge is to find and easy way to iterate the different folders (or put sub folders onto a stack variable). I can not find any easy way of extracting the folders from the string containing the full path.

I was looking for a "String Split" action that could create a stack/queue/list that I could iterate, but failed to find any suitable actions to solve my challenge...

Hi Eirik,

Sorry for the delay in getting back to you.

This is quite a hard problem, and there’s no “out of the box” FB solution for it. What I would do is something like this:

1) Suppose the destination path in SVN is stored in FinalBuilder project variable called SVNPath.

2) Create three new FinalBuilder project variables called (say) PathSegments, RebuildPath and Segment.

3) Use a Run Script action to split the SVNPath up into sections, something like this:

(Script language type = JScript, use the OnExecute event on the Script Editor tab for the Run Script action)

var temp = SVNPath.split(’/’); // Create an array from the elements of the path
RebuildPath = temp.shift(); // First segment is the “svn://c++” part of the path. Shift it out of the array
PathSegments = temp.join(’\r\n’);

4) Add a List Iterator action after the Run Script action. Set the content to %PathSegments% and the ‘variable to set’ to Segment.

5) Add the SVN MkDir action as the child of the List Iterator

6) In the SVN Action’s BeforeAction script event, put the following JScript:

RebuildPath = RebuildPath + ‘/’ + Segment

7) Configure the SVN action to use RebuildPath as the path to recreate.


… this is pretty tricky, and I haven’t actually tested it myself. Let me know if you’d like me to mock up a demonstration project instead.

Regards,

Angus