SRL Archive - OSR Help

Is this the best way to do this?


Thick As Blood

2007-03-11 23:31:52

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…


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


and i get this error..

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 :)

Smartzkid

2007-03-11 23:35:31

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

Thick As Blood

2007-03-11 23:39:00

the error, stated by SCAR is located here..

 if (CheckBox11.State = cbChecked) then
begin
[B] RunDir = 'N';[/B] //here
end else

Smartzkid

2007-03-11 23:42:32

Ok. Try this:


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;

Infantry001

2007-03-11 23:42:44

Make it RunDir := 'N';

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

Thick As Blood

2007-03-11 23:50:47

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??


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;
[B]CheckBox12.State := cbChecked;[/B]
CheckBox12.TabOrder := 23;


it just looks like this right now..

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;

Smartzkid

2007-03-12 00:01:56

You did call procedure RunAwayy; before SetupSRL, right?

Thick As Blood

2007-03-12 00:06:08

yes, and i still get



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


any ideas anyone? :(

Avaphi

2007-03-12 02:35:32

Shouldnt you use a radio button for the run dir?

Thick As Blood

2007-03-12 14:38:45

could you explain that to me?

Ron

2007-03-12 17:10:37

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


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:

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.

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 :)