Results 1 to 2 of 2

Thread: Script Freezes while using forms

  1. #1
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default Script Freezes while using forms

    when i make a form, the script doesnt continue until i close the form.
    SCAR Code:
    SafeInitForm
    SafeShowForm
    writeln('Hello')
    i wont get the 'Hello' until i close the form window,

    is there a way for the script to carry on even though the form is open, so you can have a form open the whole time the script is running, something like..
    SCAR Code:
    frmdesign.stopscript:=true //switch to false

    i think this could be useful to show the report in a TEdit or a TMemo as well as the debug log
    Join the Official SRL IRC channel. Learn how to Here.

  2. #2
    Join Date
    Oct 2006
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry there is no way for the script to execute while it is running.

    EDIT: actually if you have a button in your form

    below this:
    SCAR Code:
    Button1 := TButton.Create(frmDesign);

    add this:
    SCAR Code:
    Button1.OnClick := @ButtonClick;

    then above the InitForm part add:
    SCAR Code:
    procedure ButtonClick(sender: TObject);
    begin
    WriteLn('Hello');
    frmDesign.Caption:= frmDesign.Caption + '.';
    frmDesign.ModalResult:= mrOk;
    end;

    that should get the hello to come when you press the button.

    try this:

    SCAR Code:
    program Yakman;

    var
    frmDesign : TForm;
    Button1 : TButton;

    procedure ButtonClick(sender: TObject);
    begin
    WriteLn('Hello');
    frmDesign.Caption:= frmDesign.Caption + '.';
    frmDesign.ModalResult:= mrOk;
    end;

    procedure InitForm;
    begin
    frmDesign := CreateForm;
    frmDesign.Left := 250;
    frmDesign.Top := 114;
    frmDesign.Width := 263;
    frmDesign.Height := 180;
    frmDesign.Caption := 'Helper';
    frmDesign.Color := clBtnFace;
    frmDesign.Font.Color := clWindowText;
    frmDesign.Font.Height := -11;
    frmDesign.Font.Name := 'MS Sans Serif';
    frmDesign.Font.Style := [];
    frmDesign.Visible := False;
    frmDesign.PixelsPerInch := 96;
    Button1 := TButton.Create(frmDesign);
    Button1.OnClick := @ButtonClick;
    Button1.Parent := frmDesign;
    Button1.Left := 79;
    Button1.Top := 99;
    Button1.Width := 75;
    Button1.Height := 25;
    Button1.Caption := 'Click Me';
    Button1.TabOrder := 1;
    end;

    procedure SafeInitForm;
    var
    v: TVariantArray;
    begin
    setarraylength(V, 0);
    ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
    frmDesign.ShowModal;
    end;

    procedure SafeShowFormModal;
    var  v: TVariantArray;
    begin  setarraylength(V, 0);
    ThreadSafeCall('ShowFormModal', v);
    end;

    begin
    SafeInitForm;
    SafeShowFormModal;
    end.

    or if you want the form to continue running remove the:
    SCAR Code:
    frmDesign.Caption:= frmDesign.Caption + '.';
    frmDesign.ModalResult:= mrOk;

    from:
    SCAR Code:
    procedure ButtonClick(sender: TObject);
    begin
    WriteLn('Hello');
    frmDesign.Caption:= frmDesign.Caption + '.';
    frmDesign.ModalResult:= mrOk;
    end;

    hope that helped

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Script freezes while finding a stove
    By Cazax in forum OSR Help
    Replies: 2
    Last Post: 01-25-2008, 01:48 PM
  2. Replies: 3
    Last Post: 01-25-2008, 08:46 AM
  3. Script freezes when nextplayer is called
    By Killerdou in forum OSR Help
    Replies: 0
    Last Post: 09-04-2007, 08:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •