If-Then statments

ramtha
05 Jun 2006, 17:54
so, I was wondering if there was some sort of cap in QDK when you make an if- then statement. What i was trying to do was if- something, then- (another if-then statement)
When it goes into the second if-then, it seems to not work... is it just something i'm doing, or is it the programs limit?

James2
05 Jun 2006, 19:44
Using QDK, then as you 'nest' more if..then..else statements then it reaches a character limit and ruins the ends of the nested statements. I have not tested for this limit, but it appears that two if..then..else's in a main if..then..else cause the problem you are seeing.

If you edit you file in a text editor then it appears there is no limit to the complexity.

My advice would be to make you code simpler by doing the first if..then..else but setting flags in the 'then' and 'else'. Then write a stand-alone second (third....) if..then..else (i.e. not nested) which tests the flags and perform the operations you want.

Cryophile
05 Jun 2006, 21:47
I had that problem almost a year ago, but last I heard it had been fixed. For nested ifs use a text editor.

ramtha
05 Jun 2006, 22:17
damn.... i'm so bad at all of that coding... oh well. I have a small way of getting around it...(by making a timer) but its just seems inefficient... oh well.

steve the gaming guy
12 Jun 2006, 19:43
I'm about a week late replying to this but I thought I should add my 2 cents.

I know exactly what issue you are referring to. It generally happens within the IF/THEN window. First you create your IF bit, then fill in what happens in the THEN window but if you add another if statement within the ELSE window, you most likely will get an error. Today I was working on one where I had

IF flag “whatever” is set, 
THEN
[If player has whatever object,
THEN…whatever, whatever
ELSE…whatever, whatever]
ELSE
Type message “whatever, whatever”
Turn on flag “whatever”

Ok that’s pretty generic but I hope you understand what I’m saying. The above scenario did not work. Before closing all the windows out, I could see red font which means an error is sitting in there. What finally worked was putting what I had in the ELSE window as a procedure and just calling that procedure instead of putting all the commands there (which confuses the IF/THEN system). But in the following scenario that worked, I changed some things around and even started with “if the flag was off”…

IF flag “whatever” is NOT set,
THEN
Run “new” procedure (which originally was my ELSE message.)
ELSE
[If player has whatever object,
THEN…whatever, whatever
ELSE…whatever, whatever]


And separately, I have my “new” procedure…

Type message “whatever, whatever”
Turn on flag “whatever”



Make sense at all? If not, I can try to be more detailed and give an exact step-by-step how I made mine work.