MIT App Inventor Control Blocks
文章推薦指數: 80 %
break CreateApps! About AboutAppInventor OurTeam MasterTrainers AppoftheMonth ReleaseNotes TermsofService Educators Teach Tutorials News Inthenews Events Storiesfromthefield Resources GetStarted Documentation Forums Tutorials AppInventorBooks OpenSourceInformation Research HourofCode AdditionalResources Blogs AppInventorBlog Donate if&elseif foreachnumberfromto foreachiteminlist foreachkeywithvalueindictionary while ifthenelse dowithresult evaluatebutignoreresult openanotherscreen openanotherscreenwithstartvalue getplainstarttext getstartvalue closescreen closescreenwithplaintext closescreenwithvalue closeapplication break if&elseif Testsagivencondition.Iftheconditionistrue,performstheactionsinagivensequenceofblocks;otherwise,theblocksareignored. Testsagivencondition.Iftheconditionistrue,performstheactionsinthe-thensequenceofblocks;otherwise,performstheactionsinthe-elseequenceofblocks. Testsagivencondition.Iftheresultistrue,performstheactionsinthe-thensequenceofblocks;otherwiseteststhestatementinthe-elseifsection.Iftheresultistrue,performstheactionsinthe-thensequenceofblocks;otherwise,performstheactionsinthe-elsesequenceofblocks. Theanimationbelowshowshowtousetheifelsemutatorblock. foreachnumberfromto Runstheblocksinthedosectionforeachnumericvalueintherangestartingfromfromandendingatto,incrementingnumberbythevalueofbyeachtime.Usethegivenvariablename,number,torefertothecurrentvalue.Youcanchangethenamenumbertosomethingelseifyouwish. foreachiteminlist Runstheblocksinthedosectionforeachiteminthelist.Usethegivenvariablename,item,torefertothecurrentlistitem.Youcanchangethenameitemtosomethingelseifyouwish. foreachkeywithvalueindictionary Runstheblocksinthedosectionforeachkey-valueentryinthedictionary.Usethegivenvariables,keyandvalue,torefertothekeyandvalueofthecurrentdictionaryentry.Youcanchangethenameskeyandvaluetosomethingelseifyouwish. while Teststhe-testcondition.Iftrue,performstheactiongivenin-do,thentestsagain.Whentestisfalse,theblockendsandtheactiongivenin-doisnolongerperformed. ifthenelse Testsagivencondition.Ifthestatementistrue,performstheactionsinthethen-returnsequenceofblocksandreturnsthethen-returnvalue;otherwise,performstheactionsintheelse-returnsequenceofblocksandreturnstheelse-returnvalue.Thisblockissimilartotheternaryoperator(?:)foundinsomelanguages. dowithresult Sometimesinaprocedureoranotherblockofcode,youmayneedtodosomethingandreturnsomething,butforvariousreasonsyoumaychoosetousethisblockinsteadofcreatinganewprocedure. evaluatebutignoreresult Providesa“dummysocket”forfittingablockthathasaplugonitsleftintoaplacewherethereisnosocket,suchasoneofthesequenceofblocksinthedopartofaprocedureoranifblock.Theblockyoufitinwillberun,butitsreturnedresultwillbeignored.Thiscanbeusefulifyoudefineaprocedurethatreturnsaresult,butwanttocallitinacontextthatdoesnotacceptaresult. openanotherscreen Opensthescreenwiththeprovidedname. ThescreenNamemustbeoneoftheScreenscreatedusingtheDesigner.The screenNameshouldbeselectedfromtheconnectedscreennamedropdownblock. Ifyoudoopenanotherscreen,youshouldcloseitwhenreturningtoyourmainscreentofreesystemmemory.Failuretocloseascreenuponleavingitwilleventuallyleadtomemoryproblems. AppdevelopersshouldnevercloseScreen1orusethisblocktoreturntoScreen1.Usetheclosescreenblockinstead. openanotherscreenwithstartvalue Opensanotherscreenandpassesavaluetoit. getplainstarttext Returnstheplaintextthatwaspassedtothisscreenwhenitwasstartedbyanotherapp.Ifnovaluewaspassed,itreturnstheemptytext.Formultiplescreenapps,usegetstartvalueratherthangetplainstarttext. getstartvalue Returnsthestartvaluegiventothecurrentscreen. Thisvalueisgivenfromusingopenanotherscreenwithstartvalueorclosescreenwithvalue. closescreen Closesthecurrentscreen. closescreenwithplaintext Closesthecurrentscreenandpassestexttotheappthatopenedthisone.Thiscommandisforreturningtexttonon-AppInventoractivities,nottoAppInventorscreens.ForAppInventorScreens,asinmultiplescreenapps,useclosescreenwithvalue,notclosescreenwithplaintext. closescreenwithvalue Closesthecurrentscreenandreturnsavaluetothescreenthatopenedthisone. closeapplication Closestheapplication. break Whenloopingusingtheforrange,foreach,orwhileblocksitissometimesusefultobeabletoexittheloopearly.Thebreakallowsyoutoescapetheloop.Whenexecuted,thiswillexittheloopandcontinuetheappwiththestatementsthatoccuraftertheloopintheblocks.
延伸文章資訊
- 1Is there "break" control instruction in AI2? - Google Groups
to MIT App Inventor Forum. I think I am used to solve loop problem use break instruction in gener...
- 2App inventor 教學講義chapter2 - SlideShare
條件選擇(Control 控制指令) 程式中的選擇(selection) 就是依. 程式區1; break; case value2: 程式區2; break; . for each ...
- 3MIT App Inventor Control Blocks
break
- 4想用MIT APP Inventor 做一個app連到esp8266 wifi模組控制 ...
在MIT APP Inventor那邊,較好的做法是[發了一個http request,等收到相關的http response後,才容許發出下 ... break; case '2': acti...
- 5Engineering and Debugging an App - AppInventor.org
Design the logic for your app before beginning to code. ... So, in designing this app, you might ...