The ?: Operator

For questions about using Classic.

Post » Mon Dec 29, 2008 2:08 am

I'm trying to use the ?: operator in my game, but it causes an error on startup. The temp.exe file crashes causing the Windows error reporting service to trigger. This happens in XP and Vista.
Here the expression as I'm using it in the code.

[code:397z7hxl]
PlayerDeck.Value('num_cards')<0 ? 52 : 0[/code:397z7hxl]

It's in an action that attempts to increment the value of PlayerDeck.Value('num_cards') by either 52 or 0

Am I using the expression correctly?
B
3
S
2
G
4
Posts: 271
Reputation: 2,017

Post » Mon Dec 29, 2008 2:17 am

I think it's a bit buggy. You might want to throw brackets around every operand:

(PlayerDeck.Value('num_cards') < 0) ? (52) : (0)

If that doesn't help, it's probably totally broken, so ditch it and use subevents instead.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,554

Post » Mon Dec 29, 2008 5:17 am

I tried brackets everywhere and even took out the spaces:
[code:2q11itv5]((PlayerDeck.Value('num_cards'))<0)?(52):(0)[/code:2q11itv5]
It still gave the same error so I guess I'll have to go with the subevents.

Thanks
B
3
S
2
G
4
Posts: 271
Reputation: 2,017

Post » Mon Dec 29, 2008 4:05 pm

I added the bug to the tracker, so hopefully it'll be fixed soon.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,554

Post » Fri Jan 02, 2009 3:51 pm

ooh, thanks. I still haven't even gone through and learned how to submit a bug report. :oops:
You people are too nice.
B
3
S
2
G
4
Posts: 271
Reputation: 2,017


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests