DEFINE CLASS cmd AS commandbutton Caption = "Command1" Name = "cmd" PROCEDURE Click ExecScript(Evaluate(This.Parent.Parent.RecordSource + ".ccode")) ENDPROC ENDDEFINE2. Following is a form definition you can use to test with.
************************************************** *-- Form: form1 (c:\misc\test.scx) *-- ParentClass: form *-- BaseClass: form *-- Time Stamp: 06/30/04 10:19:12 PM * DEFINE CLASS form1 AS form Top = 0 Left = 0 Height = 443 Width = 592 DoCreate = .T. ShowTips = .T. Caption = "Form1" Name = "Form1" ADD OBJECT grid1 AS grid WITH ; ColumnCount = 1, ; Height = 390, ; Left = 12, ; RecordSource = "tmp", ; Top = 12, ; Width = 570, ; Name = "Grid1", ; Column1.ControlSource = "", ; Column1.Name = "Column1" ADD OBJECT form1.grid1.column1.header1 AS header WITH ; Caption = "Header1", ; Name = "Header1" ADD OBJECT form1.grid1.column1.text1 AS textbox WITH ; BorderStyle = 0, ; Margin = 0, ; ForeColor = RGB(0,0,0), ; BackColor = RGB(255,255,255), ; Name = "Text1" PROCEDURE Load Create Cursor tmp (cCaption c(25), cToolTip c(128), cName c(25), cCode m) Append Blank Replace cCaption With "Hello!", ; cToolTip With "Hello and Goodbye", ; cName With "Hello", ; cCode With 'messagebox("Goodbye. :(")' Append Blank Replace cCaption With "Try it...", ; cToolTip With "Try it... You will like it!", ; cName With "TryIt", ; cCode With 'messagebox("you will like it!")' Append Blank Replace cCaption With "VFP 9", ; cToolTip With "VFP 9 Beta", ; cName With "VFP9", ; cCode With 'messagebox("Beta")' Append Blank Replace cCaption With "Dynamic Controls", ; cToolTip With "Dynamic controls rock!", ; cName With "Dynamic", ; cCode With 'messagebox("dynamic controls rock!")' in tmp ENDPROC PROCEDURE Form1.Grid1.Column1.Init Local lnSelect, ; loCmd lnSelect = Select(0) Select Distinct cName, cCaption, cToolTip ; From (This.Parent.RecordSource) ; Into Cursor tmp_cur Select tmp_cur *- You will have to adjust the file location of the .prg file Scan This.NewObject("cmd" + AllTrim(cName), "cmd", "c:\misc\test.prg") loCmd = Evaluate("This.cmd" + AllTrim(cName)) loCmd.Caption = AllTrim(cCaption) loCmd.ToolTipText = AllTrim(cToolTip) loCmd.Visible = .T. EndScan USE In tmp_cur This.DynamicCurrentControl = "'cmd' + AllTrim(tmp.cName)" This.Sparse = .F. Select (This.Parent.RecordSource) Go Top Select (lnSelect) ENDPROC ENDDEFINE * *-- EndDefine: form1 **************************************************Hope this helps!