I kinda understand what are you trying to do, I just don't understand how are you going to treat your parameters to make it an all around tool. I mean if you want square based figures, you can add tons of parameters to change the square parts like corners, etc. But how are you going to use these same parameters for figures that are totally different. A tool to creating only regular polygons from triangles to megagons wouldn't be that difficult to do. But going from regular polygons to that bridge is a huge step.
My suggestion in using CreateCurve was because you can assign coordinates (x,y,z) per point, and the command will create a curve in those coordinates so you can use an array to gather your coordinates, and at the very last, use one command to create the entire curve. But I didn't noticed that more or less you are doing the same but in 2 commands so my advice is kinda pointless, sorry
My comment about Python and JScript was because JScript isn't good with multidimensional arrays, and the CreateCurve command wanting to have the 3 coordinates inside parenthesis. JScript won't be able to translate arrays properly, it will always "look" like a single dimensional array, so you would have to convert that array into a string that CreateCurve likes. Not that hard to do though.
But !
I didn't notice that you are not using arrays but a big string, so that should work good enough as long as you get a string that Softimage likes.
Just to elaborate what I was trying to say. You can create a JScript array with arrays inside like this:
positions = [[0,0,0], [0,1,0], [1,1,0], [1,0,0], [0,0,0]]
but it will always log:
LogMessage ( positions )
// INFO : 0,0,0,0,1,0,1,1,0,1,0,0,0,0,0
So you would have to convert it to something CreateCurve likes with a function, adding parenthesis every 3 characters in your array.
In Python you would just convert it to string and strip the brackets easily.
positions = [(0,0,0), (0,1,0), (1,1,0), (1,0,0), (0,0,0)]
LogMessage ( positions )
# INFO : [(0, 0, 0), (0, 1, 0), (1, 1, 0), (1, 0, 0), (0, 0, 0)]
So you could make it easily CreateCurve friendly like this:
LogMessage ( str(positions)[1:-1] )
# INFO : (0, 0, 0), (0, 1, 0), (1, 1, 0), (1, 0, 0), (0, 0, 0)
If you are starting to script, and you can choose your language I'd recommend Python.
Probably a little harder to start with, but with a lot more tools to play with in the future, when you have accumulated more knowledge. Being able to using it in other packages like Maya or Max, and having tons of free sample code around the internet is also a big plus.
The only problem with Python is that it isn't very good handling Softimage Collection Objects. It is very slow at it. Besides that, you'll have way more weapons than JScript.
In this specific case though, Python per se won't give you any extra super power, it will only be a little easier to write.
And another suggestion, in your code you are using a different variable for every loop. Since you are separating them with "ifs", you don't need to name them differently, just copy & paste the code and make the modifications.