Results 1 to 11 of 11

Thread: Is this the best way to do this?

  1. #1
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Is this the best way to do this?

    Code:
    procedure RunAwayy;
    begin
     if (CheckBox11.State = cbChecked) then
    begin
      RunDir = 'N';
    end else
     if (CheckBox12.State = cbChecked) then
    begin
      RunDir = 'S';
    end else
     if (CheckBox13.State = cbChecked) then
    begin
      RunDir = 'E';
    end else
     if (CheckBox14.State = cbChecked) then
    begin
      RunDir = 'W';
    end else
     end;
    end;

    i want to use it here...


    Code:
    9 : if FindFight then
                  begin
                    Result := True;
                    RunTo(RunAwayy, True);
                    Wait(5000+random(120));
                    RunBack;
                  end;

    and i get this error..

    Code:
    Line 164: [Error] (17825:13): Type mismatch in script

    i'll mess with it more, and probably figure it out. i've figured out all of my form problems on my own, by trial and error for the last 2 hours, but if anyone has any ideas or wants to help with this problem, it's greatly appreciated
    Thick As Blood

  2. #2
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Code:
    9 : if FindFight then
                  begin
                    Result := True;
                    RunTo(RunDir, True);
                    Wait(5000+random(120));
                    RunBack;
                  end;
    Interested in C# and Electrical Engineering? This might interest you.

  3. #3
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    the error, stated by SCAR is located here..

    Code:
     if (CheckBox11.State = cbChecked) then
    begin
      RunDir = 'N'; //here
    end else
    Thick As Blood

  4. #4
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Ok. Try this:

    Code:
    procedure RunAwayy;
    begin
     if (CheckBox11.State = cbChecked) then
      RunDir = 'N';
     if (CheckBox12.State = cbChecked) then
      RunDir = 'S';
     if (CheckBox13.State = cbChecked) then
      RunDir = 'E';
     if (CheckBox14.State = cbChecked) then
      RunDir = 'W';
    end;
    Interested in C# and Electrical Engineering? This might interest you.

  5. #5
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Make it RunDir := 'N';

    Btw, you can use the .Checked state, so it would be like:
    SCAR Code:
    if CheckBox11.checked then RunDir := 'N';

  6. #6
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Line 162: [Error] (17823:40): Type mismatch in script


    hmm. do i have to do anything to my form settings?

    do i have to change this at all to correspond??


    Code:
    CheckBox12 := TCheckBox.Create(frmDesign);
    CheckBox12.Parent := frmDesign;
    CheckBox12.Left := 150;
    CheckBox12.Top := 56;
    CheckBox12.Width := 34;
    CheckBox12.Height := 17;
    CheckBox12.Caption := 'S';
    CheckBox12.Checked := True;
    CheckBox12.State := cbChecked;
    CheckBox12.TabOrder := 23;

    it just looks like this right now..

    Code:
    procedure RunAwayy;
    begin
     if CheckBox11.Checked then RunDir:= 'N';
     if CheckBox12.Checked then RunDir:= 'S';
     if CheckBox13.Checked then RunDir:= 'E';
     if CheckBox14.Checked then RunDir:= 'W';
    end;
    Thick As Blood

  7. #7
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    You did call procedure RunAwayy; before SetupSRL, right?
    Interested in C# and Electrical Engineering? This might interest you.

  8. #8
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yes, and i still get



    Line 162: [Error] (17823:40): Type mismatch in script


    any ideas anyone?
    Thick As Blood

  9. #9
    Join Date
    May 2006
    Location
    West Coast
    Posts
    820
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Shouldnt you use a radio button for the run dir?

  10. #10
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    could you explain that to me?
    Thick As Blood

  11. #11
    Join Date
    Apr 2006
    Location
    I live in NH
    Posts
    611
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    For form checkboxes you don't have to put in cbChecked or whatever. Just use this...

    Code:
      if(CheckBox1.Checked)then
        WriteLn('CheckBox one is checked!');
    fyi to make 1 command if statements with else statements without begin/ends, you have to get rid of the semicolon.

    Example of working code without semicolons:
    Code:
    program WorkingOneLineIfStatementWithElsesWithoutBeginAndEnds;
    
    var
      Number : Integer;
    
    begin
      ClearDebug;
      Number := Random(5);
      if(Number = 0)then
        WriteLn('Number equals Zero!')
      else if(Number = 1)then
        WriteLn('Number equals One!')
      else if(Number = 2)then
        WriteLn('Number equals Two!')
      else if(Number = 3)then
        WriteLn('Number equals Three!')
      else if(Number = 4)then
        WriteLn('Number equals Four!')
    end.
    Example of not working code with semicolons.
    Code:
    program NotWorkingOneLineIfStatementWithElsesWithoutBeginAndEnds;
    
    var
      Number : Integer;
    
    begin
      ClearDebug;
      Number := Random(5);
      if(Number = 0)then
        WriteLn('Number equals Zero!');
      else if(Number = 1)then
        WriteLn('Number equals One!');
      else if(Number = 2)then
        WriteLn('Number equals Two!');
      else if(Number = 3)then
        WriteLn('Number equals Three!');
      else if(Number = 4)then
        WriteLn('Number equals Four!');
    end.
    ~Ron

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
  •