SRL Archive - RS3 Help

If Else not cooperating


Clutch

2015-03-08 23:44:21

Trying to input an if else statement. Basically I can use either the random age or the typical typesend age. It won't let me put an else at the end of it. I've spent hours trying to figure this out and am beyond frustrated at this point. Ideas?
  if USERNAME = '0' then                                    //Generating Character Name
mouseBox(IntToBox(649,216,755,236), MOUSE_LEFT)
else
typesend (USERNAME);

ageBox := intToBox(497,322,538,313); //inserts default age else inserts random age thanks to @KeepBotting with this
mouseBox(ageBox, MOUSE_LEFT);
wait(1000);
if (AGE) = '' then
tmpStr:= '10';
randomize;
for i:= 1 to 2 do
tmpStr :=tmpstr + RNDINT[random(10)+1];
typeSend (tmpStr)
else
typeSend (AGE);
Error: Found unexpected token "else", expected "End" at line 65
Compiling failed.
I don't want to put an END; I want it to detect that it is an else after that. If this isn't an option I can switch the way it is called but I need a way to do the following

If (AGE) = an integer (ex. character creation screen, if they input ANY integer for their age it'll input it (this is a contsant) but if they leave it blank it'll give a random age)
then typeSend (AGE)

rj

2015-03-08 23:53:54

Why do you have an else there? You have no condition, else what?

bg5

2015-03-08 23:55:01

block after if

if (AGE) = '' then
begin
tmpStr:= '10';
randomize;
for i:= 1 to 2 do
tmpStr :=tmpstr + RNDINT[random(10)+1];
typeSend (tmpStr);
end
else
typeSend (AGE);

Clutch

2015-03-09 00:07:19

From: bg5
block after if

if (AGE) = '' then
begin
tmpStr:= '10';
randomize;
for i:= 1 to 2 do
tmpStr :=tmpstr + RNDINT[random(10)+1];
typeSend (tmpStr);
begin
else
typeSend (AGE);
@bg5; still get unexpected token else
@rj; If I tell it AGE = 0 that doesn't make any difference either if it = 0 then do this else do this, still get the same error though?

If it helps here is what I had originally

ageBox := intToBox(497,322,538,313);                    //inserts default age else inserts random age  thanks to @KeepBotting with this
mouseBox(ageBox, MOUSE_LEFT);
wait(1000);
typeSend (AGE);
(AGE) is a constant I am trying to make it so that you can either put in a "0" for the field in which case it will randomize it with the above code, if they don't put in a "0" it will do a typeSend of whatever (AGE) = at the top where I made it a constant.

bg5

2015-03-09 00:40:38

From: OzoneClutch
…



Lol, I made a typo in my fix ( begin..begin instead of begin..end )

try again:


if (AGE) = '' then
begin
tmpStr:= '10';
randomize;
for i:= 1 to 2 do
tmpStr :=tmpstr + RNDINT[random(10)+1];
typeSend (tmpStr);
end
else
typeSend (AGE);

Clutch

2015-03-09 01:01:08

From: bg5
Lol, I made a typo in my fix ( begin..begin instead of begin..end )

try again:


if (AGE) = '' then
begin
tmpStr:= '10';
randomize;
for i:= 1 to 2 do
tmpStr :=tmpstr + RNDINT[random(10)+1];
typeSend (tmpStr);
end
else
typeSend (AGE);

@bg5;

Thanks I actually just realized that I didn't do that as I am doing more if then else statements for another part of the script and was having issues with it until I did exactly what you said. That should do the trick will let you know! That did the trick thanks so much for the help!