zhangwj000@nbip.net

edited 5:04PM in FastScript
I wrote the code as following, but when compiled, an error of "Event handler must be a procedure" occured! Can some one help me ?
/***********
form1.ScriptMemo.Lines.Append('procedure click1(Sender:TButton); ');
form1.ScriptMemo.Lines.Append('begin showmessage(''hello''); end;');
form1.ScriptMemo.Lines.Append(' begin ');
form1.ScriptMemo.lines.Append(' GForm.button1.OnClick:=@click1; ');
form1.ScriptMemo.Lines.Append(' end.');
/***********

Comments

  • edited 5:04PM
    Works well for me.
  • edited 5:04PM
    I solved it! But another question comes out...

    I add the following line to the program
    Form1.fsScript1.AddForm(GForm);
    GForm is a dynamically generated form in a procedure.
    then , I invoke the GForm object in the script. But it told me "undeclared variable GForm";

    if I add the line as following
    Form1.fsScript1.Parent:=fsGlobalUnit;
    Form1.fsScript1.Parent.AddForm(GForm);
    I can access GForm for the first time , but at the second time, an access violation error occured!

    Thanks for helping me!


    ====================================
    procedure GlobalCreateForm(ModID:integer);
    var
    GForm:TForm;
    button1:TRESMButton;//derived button class
    i:integer;
    begin
    GForm := TForm.Create(nil);

    GForm.Parent := nil;
    GForm.Caption := 'test form';
    GForm.Name:='GForm';

    for i:=1 to 5 do
    begin
    button1 := TRESMButton.Create(GForm);
    button1.Parent:=GForm;
    button1.Left:=10;
    button1.Top:=20*i+10;
    button1.Name:='button'+inttostr(i);
    button1.Caption:=button1.Name;
    button1.Height:=20;
    button1.Width:=100;
    button1.m_note:='note';
    end;

    Form1.fsScript1.Parent.AddForm(GForm);
    // Form1.fsScript1.Parent.RemoveComponent(GForm);


    form1.ScriptMemo.lines.Clear;
    form1.ScriptMemo.Lines.Append('procedure click1(Sender:TButton); ');
    form1.ScriptMemo.Lines.Append('begin showmessage(GForm.button1.m_note); end;');
    form1.ScriptMemo.Lines.Append(' begin ');
    form1.ScriptMemo.Lines.Append(' GForm.button1.m_note:=''test note''; ');
    form1.ScriptMemo.lines.Append(' GForm.button1.OnClick:=@click1; ');
    form1.ScriptMemo.Lines.Append(' end.');

    if(form1.RunScript<>0)then
    begin
    GForm.Free;
    Exit;
    end;

    GForm.ShowModal;
    GForm.Free;
    end;


Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.