FAQ  •  Register  •  Login

ELSIF

<<

einar

Posts: 84

Joined: Sun Apr 08, 2012 9:33 pm

Post Wed Mar 27, 2013 2:46 am

ELSIF

For instance, suppose a game with 5 levels of difficulty, that needs to perform certain tasks depending on this. In ZX BASIC it will look like this:

  Code:
IF level = 1 THEN
    ...
ELSE
    IF level = 2 THEN
        ...
    ELSE
        IF level = 3 THEN
            ...
        ELSE
            IF level = 4 THEN
                ...
            ELSE
                ...
            END IF
        END IF
    END IF
END IF


My suggestion is to add a new keyword "ELSIF", so the code above could be simplified as follows:

  Code:
IF level = 1 THEN
    ...
ELSIF level = 2 THEN
    ...
ELSIF level = 3 THEN
    ...
ELSIF level = 4 THEN
    ...
ELSE
    ...
END IF


I know this is not an important feature (the kind of stuff they call "syntactic sugar"), but since this is probably very easy to implement in the compiler and should be very convenient for several programs, I'm suggesting it anyway :)
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Wed Mar 27, 2013 8:32 am

Re: ELSIF

This already exists, following FreeBasic convention. It's called ELSEIF.
I choose this name instead of ELSIF or ELIF because we decided to follow FreeBasic dialect ;)
<<

einar

Posts: 84

Joined: Sun Apr 08, 2012 9:33 pm

Post Wed Mar 27, 2013 2:01 pm

Re: ELSIF

So that's the reason I could not find it!

Thanks :)
<<

britlion

Posts: 766

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Sun Mar 31, 2013 11:49 pm

Re: ELSIF

The list of reserved words is your friend.

http://www.boriel.com/wiki/en/index.php ... dentifiers
<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Mon Apr 01, 2013 10:46 pm

Re: ELSIF

I never heard about ELSIF before.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Apr 02, 2013 7:17 am

Re: ELSIF

:shock:
Well, it's ELSEIF not ELSIF. It was implemented long ago.

Return to Wishlist

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO