I don't know *exactly* what you want to do, so let me cover all the bases I can think of.
You can just use CreateDictionary() to create an empty dictionary and then add scripts to it. The tricky part is how to add the scripts. You can't build scripts on the fly (sadly). But as long as the scripts you want to add are known ahead of time, then it's just a question of where you store them before adding them to the dictionary.
One way is like this:
sd2 = NewDictionary()
script => {
msg("This is scriptA")
}
dictionary add(sd2, "scriptA", script)
script => {
msg("This is scriptB")
}
dictionary add(sd2, "scriptB", script)
You have to assign the script to a variable first, and then assign. But I think that it's easier just to have a holder object that holds all the possible scripts.
<object name="ScriptHolder">
<scriptA type="script">
msg ("This is scriptA")
</scriptA>
<scriptB type="script">
msg ("This is scriptB")
</scriptB>
</object>
Then the dictionary builder would use:
sd2 = NewDictionary()
dictionary add(sd2, "scriptA", ScriptHolder.scriptA)
dictionary add(sd2, "scriptB", ScriptHolder.scriptB)
If you really did want to create custom scripts on-the-fly (e.g. programmatically change what's in the script), then you can't do that. Scripts have to be known up front. They are not generated from strings, so you have no way to feed customized script code into an attribute or dictionary. But there should be a more data-driven way to do it, if you need that sort of customization. If that's the case, I can help if you can provide more details about what you're trying to do.