Re: [NEWBIE-ISH] [DG SCRIPTS]

From: Mikael Segercrantz (segercra@CS.HELSINKI.FI)
Date: 09/29/98


On Tue, 29 Sep 1998, Del Minturn wrote:

> > As far as I knew, that _was_ an if statement due to the if above it...
> > If there ship number is greater than/equal to 0, they have a ship.  I
> > have them stored in a file, similar to clans...
>
> I have never seen an if statement do this "if (x = y >= z)". I will bet
> if you change that, you will get some better results.
> If someone knows that this can be done or show me an application that
> does this, I would like to see it or understand what it is actually
> trying to compare. seems like your better off doing x = y && x >= z or
> x = y && y >= z

What the 'if (x = y >= z)' or 'if ((x = y) >= z)' does is that it ASSIGNS
the value of y to x, and then compares it against z.  This is a shortcut
some people use, like

        if ((new_fd = accept(...)) == -1)
        {
           printf("Couldn't get new connection: %s", sys_errlist[errno]);
           exit(1);
        }
        /* do something using new_fd, which now contains the file
           descriptor to the connection */

Basically, what it does is that it combines two different steps into
one, as the above if can be written as

        new_fd = accept(...);
        if (new_fd == -1)
        {
           ...

Hope this clarifies this a little.

Mikael


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST