if else if - SOLVED

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

if else if - SOLVED

Post by Chaky »

I believe that I found a new bug in 2315.

this code:

Code: Select all

if (0 < oolite.compareVersion("1.72"))
    {
    // code
    }
else if (0 < oolite.compareVersion("1.73"))
    {
    // code
    }
else
    {
    // code
    }
would break at "else if" line. That wasn't the case with earlier trunk that I used (2312)

workaround, so far, has to be

Code: Select all

if (0 < oolite.compareVersion("1.72"))
    {
    // code
    }
else
    {
    if (0 < oolite.compareVersion("1.73"))
        {
        // code
        }
    else
        {
        // code
        }
    }
Last edited by Chaky on Fri Aug 28, 2009 11:26 am, edited 1 time in total.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Personally I'd say the upper one is sloppy coding anyway, I'd always code it as per the lower one.
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

I agree, but the thing is 2315 logs it as syntax error and breaks the script. 2312 didn't.
I think that it is sloppy, but valid.
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6311
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Post by Diziet Sma »

I don't know if this particular issue has been fixed or not, but Ahruman has made a couple of changes and it's now up to 2317. I've uploaded a new trunk-installer.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

I've alredy downloaded it :-)

Just about to install...

P.S. It would be great if the uninstallation process didn't delete configuration. I have to configure my joystick every time... (Not really.. I back it up every time)
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

2317 seems to be working fine with this "else if" business.
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6311
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Post by Diziet Sma »

Chaky wrote:
P.S. It would be great if the uninstallation process didn't delete configuration. I have to configure my joystick every time... (Not really.. I back it up every time)
I agree... however, that is beyond my control, unfortunately.. In a discussion I had with another_commander, he remarked that the reason behind this was to have as clean an uninstall as possible. From what I have seen I believe that even if it was left intact, the new installation would over-write the file anyway, the first time it was run. (I may be was wrong about this)
Last edited by Diziet Sma on Thu Aug 27, 2009 3:29 pm, edited 2 times in total.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6311
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Post by Diziet Sma »

Chaky wrote:
2317 seems to be working fine with this "else if" business.
8)
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

You're wrong. First run leaves it intact.

Regarding original topic... well... I can't explain it.

I've tried to recreate the error with 2317, and failed to do so.
That wouldn't be too wiered, it I didn't reinstall 2315 and failed to recreate the same error there too..

.. and I've spent better part of the morning trying to figure a way around that "error". (as, it is not a misunderstood log entry)

I'm a loss here...
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

Chaky wrote:
Regarding original topic... well... I can't explain it.
Maybe you have broken the scope with comments

Code: Select all

if(condition)
// comment
else ...
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

Nah.. there were no comments whatsoever.

Anyway, I figured how to break a script with comments the other day. Just don't leave any space between the commands and //.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

It's one of them mysteries wrapped into enigmas. Just saw this topic, and I'm pretty sure the javascript parser hasn't been touched between those versions.

On occasions a stray semicolon would confuse things for the parser, and maybe that's what happened here: I haven't actually tested this theory, since I'm away from my Oolite computer atm, but if, at any point, you had

Code: Select all

if (0 < oolite.compareVersion("1.72"))
    {
    // code
    };
else if (0 < oolite.compareVersion("1.73"))
    {
    // code
    }
else
    {
    // code
    }
the extra ; before else if should tell the parser that the if statement is definitely over with, and generate a syntax error when the parser sees the else immedieately following it, which would now appear to be totally on its own...

In any case, since everything is ok now, could you please edit the subject on your first post, so now it says '- SOLVED' (or 'never mind', etc..) at the end?
Thanks in advance! :)
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

Done.
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6311
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Post by Diziet Sma »

Chaky wrote:
It would be great if the uninstallation process didn't delete configuration. I have to configure my joystick every time... (Not really.. I back it up every time)
In light of the news that .GNUstepDefaults can remain intact after running a fresh install, I took another look over the installer scripting and have experimentally disabled deletion of the GNUstep folder during the uninstall routine. If all works as it seems to on my system, after this it should no longer be necessary to back up your .GNUstepDefaults file to preserve joystick/screen/shader settings across upgrades.

If anyone experiences strange behaviour as a result of this, please contact me asap.

(Testing on my system indicates that, for some reason, it may not preserve the GNUstep folder the first time you use the new installer, but after that, things work as advertised.)

I have uploaded the newly modified SVN2318 installer in place of the 2318 installer I placed there earlier today.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
Post Reply