Hi Norm,
of course, you are totally right. I've failed to even consider this possibility.
However, the code does it and doesn't do it at the same time. From what I can tell at first glance, there are two caveats:
1- "Properties.All Supported Properties" doesn't return the full property name. I mean, take XControl, it contains "Is XControl?" and a cluster of "Container Bounds". I thought the property returned "XControl:Is XControl?" and "XControl:Container Bounds". Rather, it returns "IsXControl?" and "Container Bounds"... so in the successive for loop, I get values for the property "control/Container Bounds" instead of "control/XControl:Container Bounds" and therefore gets the wrong property value for all properties that share the same datatype. This wil happen in hierarchies like Cursors, Plot, XControl, and so on... (Name collisions)
2- And the same "Properties.All Supported Properties" returns the property names inside hierarchical structures up to the first separator. We can see that from the "Caption" property.
The first property is "reference", and then the first separator. So this is all that gets thrown in the file: a reference number which is totally worthless the next time you would load the application. Here, I guess I should try to detect the reference type and add it to the list of "control references" to sort though. There would most probably be issues with naming convention in the file to prevent name collisions here as well.
I don't see how this can be done safely without using recursivity.
To tell the truth, this is more of a fun experiment in scripting than it is a real need (for me anyway). Like Chris mentioned, save the control directly to a file ad save yourself a lot of trouble!