MIT App Inventor Control Blocks

文章推薦指數: 80 %
投票人數:10人

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.



請為這篇文章評分?