>HI ,
>
>Help me Please .
>
>I use 'Execscript' to run a code which is stored in a table . But an error appeared :'THISFORM can only be used within a method'
>
>with a macro substitution there's no problem . But I want to use 'Execscript'
Macro executes as part of the code in the method - as if it was written within it. ExecScript(), however, is a piece of code called, it's basically a little .prg compiled on-the-fly, so its context is not that of a method.
To add to the techniques mentioned by others in this thread, here's the way I do this: you can have your script accept a parameter. Just add a "lparameter oThisform" to your script, and replace all of "thisform" with "oThisForm" in your script. And since the script is just a string, you don't really need to go into all of the code snippets in your table, you can just do it while calling:
cScript=yourtable.scriptmemo
cScript=strtran(cScript, "thisform","othisform")
cScript="lparameters oThisform"+chr(13)+cScript
execscript(cScript, thisform)