Log in

View Full Version : Case - If not working



stylen
05-24-2007, 05:55 PM
Hey,

I have the following code and it refuses to work.

case TeleportUntil of
'Certain Level' : begin; if CurrentLevel := Achieve then writeln('Certain level'); end;
end;


Can someone please tell me whats wrong with it.
Seems fine with me.

If I get rid of the if statement it works.

The error i get is:
Line 106: [Error] (18475:42): 'THEN' expected in script

Please help Im trying to get this script out ASAP. And this small little problem is stopping me.

Thanks

Killerdou
05-24-2007, 06:13 PM
remove the semicolon after begin.... and the begin and end are not needed...

stylen
05-24-2007, 06:26 PM
changed to:

case TeleportUntil of
'Certain Level' : if CurrentLevel := Achieve then writeln('Certain level');
end;


But its still not working.

Killerdou
05-24-2007, 06:28 PM
whats the error, and post the rest of the script aswell please... i got a nasty feeling you have an unended if statement before this piece of code...

stylen
05-24-2007, 06:44 PM
Hey,

Here's the full script.
I started this the night before and its my first script so its a little messy and newbish.


REMOVED!


The case is in the teleport procedure

Thanks

---Edit
I found it.
The achieve variable is a string and currentlevel is a integer.

Killerdou
05-24-2007, 06:49 PM
should have seen it before... its not := but =.... := means that what is on the left side gets the same value as what is on the right side whereas = checks weather or not left and right are equal and i believe that you need more then 1 different possibilities, but not sure...

stylen
05-24-2007, 06:51 PM
I removed the : and it gave me a type mismatch so i realised the string/integer thing.

Just searching to convert a string to int, and will post if it works.

Thanks for the help :D

Killerdou
05-24-2007, 06:55 PM
but why do you actually do that... try this

if achieve <> 0 then //if achieve is 0 then it will continue for ever(<> means if left is not equel to right)
if CurrentLevel >= achieve then WriteLn('Required lvl achieved!.');// i guess this is what you want right?

stylen
05-24-2007, 07:26 PM
Hey,

got it to work using strtoint.

For some reason when i enter the achive as 0 it gives the message.
but when i set the achive as 1 it crashes out (i think)

I changed it to >= like you said, = would have made it keep going forever and rendered the limit useless.

I was editing the form and managed to kill it.
Doesnt want to load up now. :'(


edit----

Fixed it.
Working with no problem :D
Gonna finish the script very soon and release it :P