Hi, Pete -
Since scripts are compiled, PowerScript code (events & functions) is quite different from changing object properties as you showed in your sample - so scripts cannot be defined dynamically. However, there is a simple way to accomplish what you want to do:
Unless there already exists at some point in this window's ancestor hierarchy, a PFC window by default does NOT contain a pfc_Retrieve event.
Via of_SendMessage(), the pfc_MessageRouter event in pfc_w_master will first attempt to execute the requested "pfc_retrieve" event to the window. If that fails (and it typically does fail silently since a window does not normally contain an event named "pfc_retrieve"), then the event request is sent to the GraphicObject that has focus. If that fails, the event is triggered in the last active DataWindow. If that fails, no action is performed.
All you should need to do to accomplish what you want to do is add an unmapped user event (which takes no argument parameters) in the window named pfc_retrieve. In that event script, code the custom logic you wish to have performed.
If for some reason any of the window's ancestors already contains a pfc_Retrieve event, override the ancestor script.
Best regards,
John