Editing class method without opening the class


Hi Hema.,
      I've done the same in a form...
      Check this code it might be useful....

static void addingcodeatruntime(Args _args)
{
    TreeNode    treeNode;
    #AOT
    str         oldsource;
    str         newsource;
    str         LineString;
    int         pos;
    container   con;

    int         childCount;
    ;
    TreeNode = TreeNode::findNode(#FormsPath + "\\Form1");    // "Form1" --
Form  Name
    treeNode = treeNode.AOTfindChild("Designs");              //Designs Node
    treeNode = treeNode.AOTfindChild("Design");              
    treeNode = treeNode.AOTfindChild("[Tab:Tab2]");
    treeNode = treeNode.AOTfindChild("[TabPage:TabPage]");
    treeNode = treeNode.AOTfindChild("[ButtonGroup:ButtonGroup]");
    treeNode = treeNode.AOTfindChild("CommandButton:CommandButton");
    treeNode = treeNode.AOTfindChild("Methods");
    treeNode = treeNode.AOTfindChild("clicked");

    oldsource = treeNode.AOTgetSource();
   
    con = str2con(oldsource, "\n");
    LineString = conpeek(con,5);

    pos = strscan(oldsource,LineString,1,strlen(oldsource));
    pos += strlen(LineString);
    newSource = strins(oldsource," \n \\Diwakar ",pos);  //new line to be
inserted

    treeNode.AOTsetSource(newsource);
    treeNode.AOTcompile(1);
    treeNode.AOTsave();

}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.