Results 1 to 8 of 8

Thread: Need Help Whit A Form

  1. #1
    Join Date
    Jun 2007
    Posts
    71
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Need Help Whit A Form

    Hello..Im trying to make a form were i can edit how many loads my script shall do but its keep saying Line 18: [Error] (18:17): Type mismatch in script then im running it pleace look at this script and tell me why and how to fix it

    Thanks yoo

    SCAR Code:
    program Im_Still_A_Noob;

    var
      frmDesign : TForm;
      Edit1 : TEdit;
      StartButton : TButton;
      Loads: String;
      i: Integer;


         procedure StartClick(sender: TObject);
                                      begin
    {                                           What the F*** To do??
    }

                                           Loads := Edit1.Text;
                                           i:= 0;
                                           repeat
                                           i:= i + 1;
                                           wait(100+random(100))
                                           until(i >= Loads);
         end;
    procedure InitForm;
    begin
    frmDesign := CreateForm;
    frmDesign.Left := 275;
    frmDesign.Top := 122;
    frmDesign.Width := 350;
    frmDesign.Height := 243;
    frmDesign.Caption := 'Im A Noob...';
    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;
    Edit1 := TEdit.Create(frmDesign);
    Edit1.Parent := frmDesign;
    Edit1.Left := 113;
    Edit1.Top := 68;
    Edit1.Width := 70;
    Edit1.Height := 21;
    Edit1.Hint := 'Loads Here';
    Edit1.ParentShowHint := False;
    Edit1.ShowHint := True;
    Edit1.TabOrder := 8;
    StartButton := TButton.Create(frmDesign);
    StartButton.Parent := frmDesign;
    StartButton.OnClick := @StartClick;
    StartButton.Left := 112;
    StartButton.Top := 155;
    StartButton.Width := 50;
    StartButton.Height := 20;
    StartButton.Caption := 'Start';
    StartButton.TabOrder := 10;
    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.

  2. #2
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    Loads := Edit1.Text;

    Should be:

    SCAR Code:
    Loads := StrToInt(Edit1.Text);

    Why, you may ask? You've declared loads as an integer, correct? When we retrieve information from an edit box in SCAR, it returns as a string, not an integer. Therefore, we use the conversion 'StrToInt' which stands for 'String To Integer' to convert into an integer.
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  3. #3
    Join Date
    Jun 2007
    Posts
    71
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Dident worket...."Line 18: [Error] (18:18): Type mismatch in script"

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    until(i >= Loads);

    Loads is a string, you cant compare it like that with an integer.

    until(i >= StrToIntDef(Loads, 0));
    Administrator's Warning:


  5. #5
    Join Date
    Jun 2007
    Posts
    71
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks alot both of you but Sumlilon you will have to tell me what dos
    until(i >= StrToIntDef(Loads, 0));
    Means..

    StrToInt means String into Integer but what about StrToIntDef? And what dos the 0 means in (Loads, 0));

  6. #6
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    StrToIntDef means String To Integer Default, so if the integer is invalid, like it has a couple of letters, it sets it as 0.
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  7. #7
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Santa_Clause View Post
    StrToIntDef means String To Integer Default, so if the integer is invalid, like it has a couple of letters, it sets it as 0.
    Thats exactly what it does.
    Administrator's Warning:


  8. #8
    Join Date
    Jun 2007
    Posts
    71
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. i need help whit script!
    By linusgr in forum OSR Help
    Replies: 9
    Last Post: 07-02-2008, 09:53 AM
  2. Help whit includes?
    By Siikanen in forum OSR Help
    Replies: 3
    Last Post: 10-27-2007, 01:31 PM
  3. help whit auto fisher
    By robeike in forum OSR Help
    Replies: 8
    Last Post: 03-15-2007, 06:20 PM
  4. Problems whit MSN
    By Home in forum News and General
    Replies: 5
    Last Post: 04-12-2006, 12:55 PM

Posting Permissions

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