Skip to first unread message

Robert Barion

unread,
Jul 1, 2018, 7:15:40 AM7/1/18
to mitappinv...@googlegroups.com

Kann man sowas in App Inventor umsetzen?

<?php
$spielerA= 16;
$spielerB= 17;

switch ($spielerA - $spielerB) {
    case 2:
        $gewinner = $spielerA;
        break;
    case -2:
        $gewinner = $spielerB;
        break;
    default:
        $gewinner = "KEINER";
        break;
}

echo "Der Gewinner ist " . $gewinner;
?>

Danke für eine Antwort
VG

SteveJG

unread,
Jul 1, 2018, 7:59:05 AM7/1/18
to MIT App Inventor Forum
App Inventor does not have the php switch, case, break or default instructions Robert.

Instead, the Block 'language',provides conditional statements from which a developer can program something similar to what you described

There is no break command.  App Inventor processes instructions asynchronously.  If one does indeed requires a 'pause', one uses the Clock component.  There is no wait or break.


You can learn about the various App Inventor commands here 

or using these resources to help you learn to use the AI2 tools  A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  

How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .




Regards,
Steve

Chris Ward

unread,
Jul 1, 2018, 8:22:36 AM7/1/18
to MIT App Inventor Forum
Hello Robert

Switch (or Select, depending on language) is indeed more elegant than a series of If/ElseIf statements. Java of course has a Switch statement so hopefully at some time in the future App Inventor can be enhanced.

Would be a nice project for one of the extension developers.......
Reply all
Reply to author
Forward
0 new messages