Q: I would like to be able to build frames dynamically and have my application create the name of the slot in the frame dynamically as well. For instance, something like this:
MyFrame:= {}; theSlotName := "Slot_1";
At this point is there a way to then create the following?... MyFrame.Slot_1
A: The function Intern
takes a string and returns a symbol. There is also a mechanism called path expressions (see the NewtonScript Reference), that allows you to specify an expression or variable to evaluate, in order to get the slot name. You can use these things to access the slots you want:
MyFrame := {x: 4}; theXSlotString := "x" ; MyFrame.(Intern(theXSlotString)) := 6 theSlotName := "Slot_1"; MyFrame.(Intern(theSlotName)) := 7; // myFrame is now {x: 6, Slot_1: 7}