maximum number of && and || in one statement?

Started by EnterTheStory (aka tolworthy), Mon 31/03/2008 15:28:39

Previous topic - Next topic

EnterTheStory (aka tolworthy)

If there a maximum number of && and || in an if statement? And what about using brackets? For example, if I was to write this, would it work? I'm not planning to (yet!) but I like to know how far I can push the envelope...
Code: ags

if((((A==1)&&(B==2))||((C!=3)&&(D!=-4))||E)||F||G||(H>I)||(J<=K)||((M&&N&&O&&!P)||(Q+1==R))||(S==null)||(bla(T))||U||V||(W&&X&&!Z)){Display("whew!");}

Radiant

Not that I have encountered. That means, for all practical purposes there probably isn't.

But, to avoid making things illegible for yourself, I'd recommend against writing things like this.

EnterTheStory (aka tolworthy)

Thanks. My reason for asking is I have over 600 items that can be clicked on, and I'm writing the dialogue for each. Multiply those 600 by up to 200 different characters, and the task becomes a little crazy! So I'm grouping similar objects together, e.g.
Code: ags

if((what="house")||(what="big house")||(what="small house")||(what="home")||(what="apartment")||(what="hovel")||(what="yellow house")||(what="building with two bedrooms")||(what="cosy cottage")||etc., etc., etc.)
character[who].Say("What a nice house.");

From what you say it should not matter if my lists get a little but long. :)
Thanks again.

SSH

Code: ags

String possibilities="housebig housesmall househomeapartmenthovelyellow housebuilding with two bedroomscosy cottage";

if (possibilities.Contains(what)) {
 // do stuff
}

12

EnterTheStory (aka tolworthy)

Contains, eh? Now there's an idea. Thanks.

I take it there's no performance hit with adding another long string? I don't know how AGS compares strings, but I have a vague recollection that checking character by character can be CPU intensive. Of course, I'm maybe thinking back to the days of the 286 here... :)

Khris

A check like that wouldn't be performed every loop, would it?
So there shouldn't be any performance issue.

SMF spam blocked by CleanTalk