yab | yet another Basic for HAIKU
Let's switch out that colon! - Printable Version

+- yab | yet another Basic for HAIKU (https://yab.orgfree.com/forum)
+-- Forum: installing / troubleshooting / feature requests (https://yab.orgfree.com/forum/forumdisplay.php?fid=5)
+--- Forum: feature requests / bug fixes (https://yab.orgfree.com/forum/forumdisplay.php?fid=11)
+--- Thread: Let's switch out that colon! (/showthread.php?tid=55)



Let's switch out that colon! - clasqm - 03-18-2016

When we start a new project in the IDE we see the following
Code:
        switch(msg$(everyCommand))
            case "_QuitRequested":
            case "MainWindow:_QuitRequested":
                leavingLoop = true
                break
            default:
                break
        end switch
Every case and default statement is terminated by a colon ":" That colon has been there as long as I remember

Now I've done a lot of switch loops and sometimes I've left off the colon at the end of a case statement by mistake. Those programs ran flawlessly. Also, yab does not throw up an error if they are missing So, why is it there and what is it supposed to do? the help in the IDE shows that you can do this
Code:
input a
switch(a)
    case 1:print "one":break
    case 2:print "two":break
    default:print "more"
end switch
but that can be done with any set of commands. It is just another way of writing
Code:
input a
switch(a)
    case 1
        print "one"
        break
    case 2
        print "two"
        break
    default
        print "more"
end switch
(BTW shouldn't there be a "break" after "default")

It's a small thing, but every small thing helps make yab a little easier for beginners. If that colon is not actually doing anything, then let's get it out of the templates.


RE: Let's switch out that colon! - bbjimmy - 03-18-2016

OK, I never noticed it.

All I need to do is modify the template file.


RE: Let's switch out that colon! - bbjimmy - 03-19-2016

Done! https://github.com/bbjimmy/YAB/commit/576d42f4caae94e83924e08bf88e8e52d8bcb8ab


Free Web Hosting