+= and -= missing from manual? [MODS-PLEASE MOVE TO TECH]

Started by Trent R, Thu 06/11/2008 07:46:58

Previous topic - Next topic

Trent R

At first I wasn't sure if the += and -= operators wouldn't work, so I checked in the manual. But they're not there!

However, they do work (because they didn't show a compile error and I used Display checks). So how come they're not a part of the manuals entry on all of the other operators? There's even the bitwise ones included.


~Trent
PS-This seems like a Beginner question, so I posted here.
[Edit]: Requesting that this gets moved to the tech to become an official suggestion.
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

monkey0506

I can't say for sure why the += and -= shortcut operators aren't included in the documentation (but yet, as you say, the binary operators are...).

Definitely I'd say it would be useful for new members to know about.

It is notable that at the moment there are no *=, /=, or %= operators however.

As for the forum, I'd say that as a "suggestion" maybe the Tech Forum would've been a better fit? I'd say it's a toss-up, but don't cross-post. If needed the moderators can make sure it's in the right place. ;)

DoorKnobHandle

While we're talking about these, I have often noticed the lack of *= and /* respectively and thus would welcome their addition. Can't imagine it can be much of a time investment to implement them?

Buckethead

They do get explained in the manual: scripting turorial 1  ;)

beomoud

what do *=, /=, or %= operators do? i've never seen them before

DoorKnobHandle

Code: ags

int a, b;

a += b; // is the same as a = a + b

a -= b; // is the same as a = a - b

a *= b; // is the same as a = a * b

a /= b; // is the same as a = a / b;

a %= b; // is the same as a = a % b;


I personally never saw a use for %= though.

SSH

Quote from: dkh on Tue 11/11/2008 16:13:29
I personally never saw a use for %= though.

Code: ags

// Make x position wrap around at screen edge
x++;
x%=System.Viewport_Width;

12

DoorKnobHandle

#7
I should have phrased that better, I know what it does and when it's useful, it's just that I really use the remainder operator % so rarely that it's not a big hassle to type in the few more characters. I use *= and /= often though!

Of course, if Chris implements *= and /=, it wouldn't be a problem (I suspect this should be pretty easy to get into AGS) to just add the %= as well, at the very least for consistency's sake!

SMF spam blocked by CleanTalk