Set a variable with the name of your field or UDF and use macro-substitution or Evaluate() depending on your needs...
Local lcMyVar
lcMyVar = iif(llSwitch, "MyTable.MyField", "MyUDF()"
? &lcMyVar
? Evaluate(lcMyVar)
...not exactly sure what all you are trying to do, but ExecScript() method may also prove useful for you -- it's in the VFP help file.
Then there's the suggestion that Sergey gave you, but depending on the amount of code it might be a real maintenance nightmare to copy and paste all the code that is almost exactly the same save for where the value comes from (UDF or Table Field).
>Does anyone know if its possible to programmatically change the code that executes when a control's refresh event fires?
>
>I have a custom class line shape that contains code to set the height and position when it is refreshed. These parameters are based on values contained in the table. I'd like to programmatically change the field pointer
>from the table to instead be a UDF and then back at the click of a button.
>
>Any suggestions?
>
>- Don