Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 41 - 2501_KVS_C-4
P. 41

    Gowri: Dear Aryan, there is one more way to write the same codes, using “if..then..else” block
                        with “forever“ block rather than “repeat until” block

                        Aryan: Please tell me dear how, I could write this code.

                        Gowri: Let’s learn it also dear. See fig. 3.11 and 3.12 to see another method to write the same
                        above code on First sprite (Fish) and code on second sprite (Fish2).

                           Fig. 3.11: Script on first sprite “Fish”         Fig. 3.12: Script on second sprite “Fish2”

                        Aryan: Oh Yes! Same coding with two different methods. So, it means  “if…then…else” block is
                        also used for conditions. Please tell me something about this.
                        Gowri: Yes, dear Aryan! This block is used to check conditions and to take decisions based on
                        that condition. This block has different options and their meanings. Let’s understand this now: -

                     3.5  IF BLOCK— “CONTROL” BLOCK

                     These blocks are also known as “c-block”.

                     3.5.1 “If   condition? Then” block
                     This block, is used for asking the questions and returning the answer in true or

                     false. If the condition is true, then the blocks written inside this c-block will be
                     executed, otherwise not.

                     3.5.2 “If   condition? Then…else” block

                     This block, is used for asking the questions and returning the answer in true or false.
                     If condition is true, then the blocks written inside this c-block will be executed,

                     otherwise the blocks written inside the “else” block will be executed.

                     3.6 “WAIT UNTIL…” BLOCK —“CONTROL” BLOCK
                     Like “if” block, condition  is also  written  in  this block and  here it will wait till
                     the condition is false. When the condition becomes true, then the next block of

                     instructions will be executed. This is also known as “c-block”.

                                                                                          Scratch                       39

| 36 37 38 39 40 41 42 43 44 45 46 |