Results 1 to 11 of 11

Thread: Making a form

  1. #1
    Join Date
    Jul 2009
    Posts
    132
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Making a form

    I've been using a tutorial...

    And this is what I have

    Code:
    var
      frmDesign: TForm;
      Button1: TButton;
    
    Procedure ButtonClick(Sender: TObject);
    Begin
    
    End;
    
    procedure InitForm;
    begin
    
      { The TForm; part }
    
      frmDesign := CreateForm;          // This will create your form. MUST be called first.
      frmDesign.Left := 100;            // How many pixels from the left must the form be vissible?
      frmDesign.Top := 100;             // How many pixels from the top must the form be vissible?
      frmDesign.Width := 500;           // The width of you form in pixels
      frmDesign.Height := 500;          // The height of you form in pixels
      frmDesign.Caption := 'ChopNDrop!';     // The name of your form? This will be shown in the upper left balk
      frmDesign.Color := ClWhite;       // The background color of your form ("ClWhite", "ClBlack" ect, or just an color like: 123456)
      frmDesign.Font.Color := ClBlack;        // The color of the text (Tlabels) when you have those
      frmDesign.Font.Name := 'Comic Sans MS'; // The name of the font you want the Tlabels to be
    
      { The TButton; part }
    
      Button1 := TButton.Create(FrmDesign);   // This will create the button. Must be called.
      Button1.Parent := FrmDesign;            // The parent is very important. Without the parrent set to the formname the button won't be visible
      Button1.Left := 10;                     // how many pixels from the left
      Button1.Top := 425;                     // how many pixels from the top
      Button1.Height := 30;                   // the height of the button
      Button1.Width := 100;                   // the width of the button
      Button1.Caption := 'Chop it!';        // The text on the button!
      Button1.OnClick := @ButtonClick;
    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;        // those 2 function are the action form setup. Thise one creates your form
      SafeShowFormModal;  // and this one makes it visible
    end.
    K I want it to open up a script when I click the button on the form... How? lol
    NOTE: I am a complete noob at forms. I just started looking at them.

  2. #2
    Join Date
    Sep 2006
    Posts
    322
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    "I want it to open up a script when I click the button on the form"

    Isn't the user supposed to do this on the scar client anyway?
    "SRL is the best SCAR community in the World, with the most talented programmers: adjust your volume."
    -Wizzup?

  3. #3
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Code:
    function OpenFile(Path: string; Shared: Boolean): Integer;
    Opens file for reading and returns file number if successful or negative number if failed. If shared = true then attempts to open files used by other applications as read-only.
    So it would be like...
    SCAR Code:
    OpenFile(Desktop\scarprerelease\Scripts\Script name,false)

    How it's done. Open up your scar scripts folder and copy the address on the top and paste it in openfile. Then enter the script name exactly.

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

    Default

    Quote Originally Posted by Junkj View Post
    Code:
    function OpenFile(Path: string; Shared: Boolean): Integer;
    Opens file for reading and returns file number if successful or negative number if failed. If shared = true then attempts to open files used by other applications as read-only.
    So it would be like...
    SCAR Code:
    OpenFile(Desktop\scarprerelease\Scripts\Script name,false)

    How it's done. Open up your scar scripts folder and copy the address on the top and paste it in openfile. Then enter the script name exactly.
    That doesn't actually open the file itself, it just allows you to manipulate it with scar.

    Are you wanting the button to start/run the script ? Or load it into a textbox so you can see it ?

  5. #5
    Join Date
    Jul 2009
    Posts
    132
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by r!ch!e View Post
    That doesn't actually open the file itself, it just allows you to manipulate it with scar.

    Are you wanting the button to start/run the script ? Or load it into a textbox so you can see it ?
    Yeah I want it to run the script

  6. #6
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    Procedure ButtonClick(Sender: TObject);
    Begin
    frmDesign.ModalResult:= mrOk; // closes the form
    End;

    Like so?

  7. #7
    Join Date
    Jul 2009
    Posts
    132
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Junkj View Post
    SCAR Code:
    Procedure ButtonClick(Sender: TObject);
    Begin
    frmDesign.ModalResult:= mrOk; // closes the form
    End;

    Like so?
    yes but instead i want it to run a script instead of closing the form

  8. #8
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You can't run a script on a script. You can either use API calls to open a new SCAR window and run the script from there or wait for Simba since it's able to run multiple scripts at once.


  9. #9
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Just any script? or just the script that goes with this? if its a single script, then just include it at the top of the script and turn the main procedure in that script into a procedure and call it from this one. If its just a random script, then since there is no eval, i doubt you can really do it

    Also - (shortened it a bit and made it less crashy if you do anything bad when coding)
    though if thats the only point of your form, then its kind of silly to have a form at all.
    SCAR Code:
    var
      frmDesign: TForm;
      Button1: TButton;

    Procedure ButtonClick(Sender: TObject);
    Begin
      frmDesign.ModalResult:= mrOk;
    End;

    procedure InitForm;
    begin
      { The TForm; part }
      frmDesign := CreateForm;          // This will create your form. MUST be called first.
      frmDesign.SetBounds(100,100,500,500);
      frmDesign.Caption := 'ChopNDrop!';     // The name of your form? This will be shown in the upper left balk
      frmDesign.Color := ClWhite;       // The background color of your form ("ClWhite", "ClBlack" ect, or just an color like: 123456)
      frmDesign.Font.Color := ClBlack;        // The color of the text (Tlabels) when you have those
      frmDesign.Font.Name := 'Comic Sans MS'; // The name of the font you want the Tlabels to be

      { The TButton; part }
      Button1 := TButton.Create(FrmDesign);   // This will create the button. Must be called.
      Button1.Parent := FrmDesign;            // The parent is very important. Without the parrent set to the formname the button won't be visible
      Button1.SetBounds(10,425,100,30);
      Button1.Caption := 'Chop it!';        // The text on the button!
      Button1.OnClick := @ButtonClick;
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

    var v: TVariantArray;
    begin
      try
        setarraylength(V, 0);
        ThreadSafeCall('InitForm', v);
        setarraylength(V, 0);
        ThreadSafeCall('ShowFormModal', v);
      except
        Writeln(ExceptionToString(ExceptionType, ExceptionParam));
      end;
    end.

    Simba isnt going to be the answer for everything. Just because it can run more than 1 script at a time, means nothing in this case really unless you can eval in Simba. AFAIK
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  10. #10
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Dan Cardin View Post
    Just any script? or just the script that goes with this? if its a single script, then just include it at the top of the script and turn the main procedure in that script into a procedure and call it from this one. If its just a random script, then since there is no eval, i doubt you can really do it
    You can't include scripts during runtime...


  11. #11
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    thats why i said, if he's making this form for a specific script...then he can just include the script in this one from the start. Otherwise it cant really be done.
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


Thread Information

Users Browsing this Thread

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

Posting Permissions

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